Sat, 06 Oct 2012 13:00:07 +0200
server can reload configuration
1 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2011 Olaf Wintermann. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
31 | ||
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
32 | #include "../public/nsapi.h" |
1 | 33 | |
34 | #include "sessionhandler.h" | |
35 | #include "httprequest.h" | |
36 | #include "httpparser.h" | |
37 | ||
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
38 | typedef struct _event_http_io { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
39 | HTTPRequest *request; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
40 | HttpParser *parser; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
41 | } EventHttpIO; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
42 | |
1 | 43 | SessionHandler* create_basic_session_handler() { |
44 | BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); | |
45 | handler->threadpool = threadpool_new(8); | |
46 | handler->sh.enqueue_connection = basic_enq_conn; | |
47 | ||
48 | ||
49 | return (SessionHandler*)handler; | |
50 | } | |
51 | ||
52 | void basic_enq_conn(SessionHandler *handler, Connection *conn) { | |
53 | BasicSessionHandler *sh = (BasicSessionHandler*)handler; | |
54 | conn->session_handler = handler; | |
55 | threadpool_run(sh->threadpool, basic_run_session, conn); | |
56 | } | |
57 | ||
58 | void* basic_run_session(void *data) { | |
59 | Connection *conn = (Connection*)data; | |
60 | ||
61 | HTTPRequest *request = http_request_new(); | |
62 | request->connection = conn; | |
63 | ||
64 | // read request | |
65 | netbuf *buf = malloc(sizeof(netbuf)); | |
66 | buf->rdtimeout = 120; | |
67 | buf->pos = 0; | |
68 | buf->cursize = 0; | |
69 | buf->maxsize = 2048; | |
70 | buf->sd = &conn->fd; | |
71 | buf->inbuf = malloc(2048); | |
72 | buf->errmsg = NULL; | |
73 | ||
74 | request->netbuf = buf; | |
75 | ||
76 | HttpParser *parser = http_parser_new(request); | |
77 | int state; | |
78 | int r; | |
79 | r = read(conn->fd, buf->inbuf + buf->pos, buf->maxsize - buf->pos); | |
80 | if(r == -1) { | |
81 | // TODO: error handling | |
82 | fprintf(stderr, "%s\n", "Error: Cannot read from socket"); | |
83 | return NULL; | |
84 | } | |
85 | buf->cursize += r; | |
86 | while((state = http_parser_process(parser)) != 0) { | |
87 | if(state == 2) { | |
88 | // TODO: error handling | |
89 | fprintf(stderr, "%s\n", "Error: Cannot parse http request"); | |
90 | return NULL; | |
91 | } | |
92 | r = read(conn->fd, buf->inbuf + buf->pos, buf->maxsize - buf->pos); | |
93 | if(r == -1) { | |
94 | // TODO: error handling | |
95 | fprintf(stderr, "%s\n", "Error: Cannot read from socket"); | |
96 | return NULL; | |
97 | } | |
98 | buf->cursize += r; | |
99 | } | |
100 | ||
101 | // process request | |
102 | r = handle_request(request); | |
103 | ||
104 | ||
105 | return NULL; | |
106 | } | |
107 | ||
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
108 | /* ----- event session handler ----- */ |
1 | 109 | |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
110 | SessionHandler* create_event_session_handler() { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
111 | EventSessionHandler *handler = malloc(sizeof(EventSessionHandler)); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
112 | handler->eventhandler = get_default_event_handler(); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
113 | handler->sh.enqueue_connection = evt_enq_conn; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
114 | return (SessionHandler*)handler; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
115 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
116 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
117 | void evt_enq_conn(SessionHandler *handler, Connection *conn) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
118 | HTTPRequest *request = http_request_new(); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
119 | request->connection = conn; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
120 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
121 | // set socket non blocking |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
122 | int flags; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
123 | if (-1 == (flags = fcntl(conn->fd, F_GETFL, 0))) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
124 | flags = 0; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
125 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
126 | if (fcntl(conn->fd, F_SETFL, flags | O_NONBLOCK) != 0) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
127 | perror("Error: start_event_session: fcntl"); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
128 | // TODO: error |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
129 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
130 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
131 | // TODO: remove code redundancy (basic_run_session) |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
132 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
133 | // read request |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
134 | netbuf *buf = malloc(sizeof(netbuf)); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
135 | buf->rdtimeout = 120; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
136 | buf->pos = 0; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
137 | buf->cursize = 0; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
138 | buf->maxsize = 2048; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
139 | buf->sd = &conn->fd; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
140 | buf->inbuf = malloc(2048); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
141 | buf->errmsg = NULL; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
142 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
143 | request->netbuf = buf; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
144 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
145 | HttpParser *parser = http_parser_new(request); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
146 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
147 | EventHttpIO *io = malloc(sizeof(EventHttpIO)); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
148 | if(io == NULL) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
149 | // TODO: error handling |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
150 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
151 | io->request = request; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
152 | io->parser = parser; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
153 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
154 | /* |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
155 | * to start the request handling, we begin with a poll on the socket, |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
156 | * |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
157 | * evt_enq_conn() --> event handler --> handle_request() |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
158 | */ |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
159 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
160 | event_handler_t *ev = ((EventSessionHandler*)handler)->eventhandler; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
161 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
162 | event_t *event = malloc(sizeof(event_t)); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
163 | event->fn = evt_request_input; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
164 | event->cookie = io; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
165 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
166 | if(ev_pollin(ev, conn->fd, event) != 0) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
167 | perror("poll"); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
168 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
169 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
170 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
171 | void evt_request_input(event_handler_t *handler, event_t *event) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
172 | EventHttpIO *io = event->cookie; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
173 | HttpParser *parser = io->parser; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
174 | HTTPRequest *request = io->request; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
175 | netbuf *buf = request->netbuf; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
176 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
177 | int state; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
178 | int r; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
179 | r = read( |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
180 | request->connection->fd, |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
181 | buf->inbuf + buf->pos, |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
182 | buf->maxsize - buf->pos); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
183 | if(r == -1) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
184 | // TODO: error handling |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
185 | fprintf(stderr, "%s\n", "Error: Cannot read from socket"); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
186 | return; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
187 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
188 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
189 | buf->cursize += r; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
190 | state = http_parser_process(parser); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
191 | if(state == 2) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
192 | // TODO: error handling |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
193 | fprintf(stderr, "%s\n", "Error: Cannot parse http request"); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
194 | return; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
195 | } else if(state == 1) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
196 | // we need more data -> begin poll, which repeats this function |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
197 | ev_pollin(handler, request->connection->fd, event); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
198 | // TODO: check ev_pollin return value for errors |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
199 | return; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
200 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
201 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
202 | // we are done with reading |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
203 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
204 | // set socket blocking |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
205 | int flags; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
206 | if (-1 == (flags = fcntl(request->connection->fd, F_GETFL, 0))) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
207 | flags = 0; |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
208 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
209 | if (fcntl(request->connection->fd, F_SETFL, flags & ~O_NONBLOCK) != 0) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
210 | perror("Error: evt_request_input: fcntl"); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
211 | // TODO: critical error |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
212 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
213 | |
36
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
35
diff
changeset
|
214 | // process request |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
215 | r = handle_request(request); |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
216 | } |