diff options
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r-- | src/daemon/daemon.c | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 4b743aad..ac0a7398 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -26,33 +26,14 @@ | |||
26 | * @version 0.1.0 | 26 | * @version 0.1.0 |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "microhttpd.h" | ||
30 | #include "internal.h" | 29 | #include "internal.h" |
31 | #include "response.h" | 30 | #include "response.h" |
32 | #include "session.h" | 31 | #include "session.h" |
33 | #include "config.h" | ||
34 | 32 | ||
35 | #define MHD_MAX_CONNECTIONS FD_SETSIZE -4 | 33 | #define MHD_MAX_CONNECTIONS FD_SETSIZE -4 |
36 | 34 | ||
37 | 35 | ||
38 | /** | 36 | /** |
39 | * fprintf-like helper function for logging debug | ||
40 | * messages. | ||
41 | */ | ||
42 | static void DLOG(const struct MHD_Daemon * daemon, | ||
43 | const char * format, | ||
44 | ...) { | ||
45 | va_list va; | ||
46 | |||
47 | if ( (daemon->options & MHD_USE_DEBUG) == 0) | ||
48 | return; | ||
49 | va_start(va, format); | ||
50 | vfprintf(stderr, format, va); | ||
51 | va_end(va); | ||
52 | } | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Register an access handler for all URIs beginning with uri_prefix. | 37 | * Register an access handler for all URIs beginning with uri_prefix. |
57 | * | 38 | * |
58 | * @param uri_prefix | 39 | * @param uri_prefix |
@@ -234,9 +215,9 @@ MHD_accept_connection(struct MHD_Daemon * daemon) { | |||
234 | &addr, | 215 | &addr, |
235 | &addrlen))) || | 216 | &addrlen))) || |
236 | (addrlen <= 0) ) { | 217 | (addrlen <= 0) ) { |
237 | DLOG(daemon, | 218 | MHD_DLOG(daemon, |
238 | "Error accepting connection: %s\n", | 219 | "Error accepting connection: %s\n", |
239 | strerror(errno)); | 220 | strerror(errno)); |
240 | return MHD_NO; | 221 | return MHD_NO; |
241 | } | 222 | } |
242 | if (MHD_NO == daemon->apc(daemon->apc_cls, | 223 | if (MHD_NO == daemon->apc(daemon->apc_cls, |
@@ -261,9 +242,9 @@ MHD_accept_connection(struct MHD_Daemon * daemon) { | |||
261 | NULL, | 242 | NULL, |
262 | &MHD_handle_connection, | 243 | &MHD_handle_connection, |
263 | session)) ) { | 244 | session)) ) { |
264 | DLOG(daemon, | 245 | MHD_DLOG(daemon, |
265 | "Failed to create a thread: %s\n", | 246 | "Failed to create a thread: %s\n", |
266 | strerror(errno)); | 247 | strerror(errno)); |
267 | free(session->addr); | 248 | free(session->addr); |
268 | close(s); | 249 | close(s); |
269 | free(session); | 250 | free(session); |
@@ -354,9 +335,9 @@ MHD_select(struct MHD_Daemon * daemon) { | |||
354 | if (num_ready < 0) { | 335 | if (num_ready < 0) { |
355 | if (errno == EINTR) | 336 | if (errno == EINTR) |
356 | return MHD_YES; | 337 | return MHD_YES; |
357 | DLOG(daemon, | 338 | MHD_DLOG(daemon, |
358 | "Select failed: %s\n", | 339 | "Select failed: %s\n", |
359 | strerror(errno)); | 340 | strerror(errno)); |
360 | return MHD_NO; | 341 | return MHD_NO; |
361 | } | 342 | } |
362 | if (FD_ISSET(daemon->socket_fd, | 343 | if (FD_ISSET(daemon->socket_fd, |