diff options
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/Makefile.am | 2 | ||||
-rw-r--r-- | src/daemon/connection.c | 27 | ||||
-rw-r--r-- | src/daemon/connection.h | 8 | ||||
-rw-r--r-- | src/daemon/connection_https.c | 12 | ||||
-rw-r--r-- | src/daemon/daemon.c | 19 | ||||
-rw-r--r-- | src/daemon/internal.h | 4 |
6 files changed, 45 insertions, 27 deletions
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index f3aea3db..1ce0accc 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am | |||
@@ -9,7 +9,7 @@ AM_CPPFLAGS = \ | |||
9 | 9 | ||
10 | if HAVE_GNU_LD | 10 | if HAVE_GNU_LD |
11 | # If you want to debug with gdb, comment out this line: | 11 | # If you want to debug with gdb, comment out this line: |
12 | # retaincommand=-Wl,--retain-symbols-file -Wl,$(srcdir)/SYMBOLS | 12 | retaincommand=-Wl,--retain-symbols-file -Wl,$(srcdir)/SYMBOLS |
13 | endif | 13 | endif |
14 | 14 | ||
15 | EXTRA_DIST = SYMBOLS | 15 | EXTRA_DIST = SYMBOLS |
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index 9a346bc7..3209974d 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -275,12 +275,14 @@ need_100_continue (struct MHD_Connection *connection) | |||
275 | } | 275 | } |
276 | 276 | ||
277 | /** | 277 | /** |
278 | * A serious error occured, close the | 278 | * Close the given connection and give the |
279 | * connection (and notify the application). | 279 | * specified termination code to the user. |
280 | */ | 280 | */ |
281 | static void | 281 | void |
282 | connection_close_error (struct MHD_Connection *connection) | 282 | MHD_connection_close (struct MHD_Connection *connection, |
283 | enum MHD_RequestTerminationCode termination_code) | ||
283 | { | 284 | { |
285 | |||
284 | SHUTDOWN (connection->socket_fd, SHUT_RDWR); | 286 | SHUTDOWN (connection->socket_fd, SHUT_RDWR); |
285 | CLOSE (connection->socket_fd); | 287 | CLOSE (connection->socket_fd); |
286 | connection->socket_fd = -1; | 288 | connection->socket_fd = -1; |
@@ -290,7 +292,18 @@ connection_close_error (struct MHD_Connection *connection) | |||
290 | daemon->notify_completed_cls, | 292 | daemon->notify_completed_cls, |
291 | connection, | 293 | connection, |
292 | &connection->client_context, | 294 | &connection->client_context, |
293 | MHD_REQUEST_TERMINATED_WITH_ERROR); | 295 | termination_code); |
296 | } | ||
297 | |||
298 | /** | ||
299 | * A serious error occured, close the | ||
300 | * connection (and notify the application). | ||
301 | */ | ||
302 | static void | ||
303 | connection_close_error (struct MHD_Connection *connection) | ||
304 | { | ||
305 | MHD_connection_close(connection, | ||
306 | MHD_REQUEST_TERMINATED_WITH_ERROR); | ||
294 | } | 307 | } |
295 | 308 | ||
296 | /** | 309 | /** |
@@ -1024,6 +1037,10 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) | |||
1024 | httpVersion[0] = '\0'; | 1037 | httpVersion[0] = '\0'; |
1025 | httpVersion++; | 1038 | httpVersion++; |
1026 | } | 1039 | } |
1040 | if (connection->daemon->uri_log_callback != NULL) | ||
1041 | connection->client_context | ||
1042 | = connection->daemon->uri_log_callback(connection->daemon->uri_log_callback_cls, | ||
1043 | uri); | ||
1027 | args = strstr (uri, "?"); | 1044 | args = strstr (uri, "?"); |
1028 | if (args != NULL) | 1045 | if (args != NULL) |
1029 | { | 1046 | { |
diff --git a/src/daemon/connection.h b/src/daemon/connection.h index b53f4e74..6cbef165 100644 --- a/src/daemon/connection.h +++ b/src/daemon/connection.h | |||
@@ -43,8 +43,16 @@ MHD_connection_get_fdset (struct MHD_Connection *connection, | |||
43 | void MHD_set_http_calbacks (struct MHD_Connection *connection); | 43 | void MHD_set_http_calbacks (struct MHD_Connection *connection); |
44 | 44 | ||
45 | int MHD_connection_handle_read (struct MHD_Connection *connection); | 45 | int MHD_connection_handle_read (struct MHD_Connection *connection); |
46 | |||
46 | int MHD_connection_handle_write (struct MHD_Connection *connection); | 47 | int MHD_connection_handle_write (struct MHD_Connection *connection); |
48 | |||
47 | int MHD_connection_handle_idle (struct MHD_Connection *connection); | 49 | int MHD_connection_handle_idle (struct MHD_Connection *connection); |
48 | 50 | ||
51 | /** | ||
52 | * Close the given connection and give the | ||
53 | * specified termination code to the user. | ||
54 | */ | ||
55 | void MHD_connection_close (struct MHD_Connection *connection, | ||
56 | enum MHD_RequestTerminationCode termination_code); | ||
49 | 57 | ||
50 | #endif | 58 | #endif |
diff --git a/src/daemon/connection_https.c b/src/daemon/connection_https.c index 3ced8602..4bb98595 100644 --- a/src/daemon/connection_https.c +++ b/src/daemon/connection_https.c | |||
@@ -100,16 +100,8 @@ MHD_tls_connection_close (struct MHD_Connection *connection, | |||
100 | { | 100 | { |
101 | MHD__gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR); | 101 | MHD__gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR); |
102 | connection->tls_session->internals.read_eof = 1; | 102 | connection->tls_session->internals.read_eof = 1; |
103 | SHUTDOWN (connection->socket_fd, SHUT_RDWR); | 103 | MHD_connection_close(connection, |
104 | CLOSE (connection->socket_fd); | 104 | termination_code); |
105 | connection->socket_fd = -1; | ||
106 | connection->state = MHD_CONNECTION_CLOSED; | ||
107 | if (connection->daemon->notify_completed != NULL) | ||
108 | connection->daemon->notify_completed (connection-> | ||
109 | daemon->notify_completed_cls, | ||
110 | connection, | ||
111 | &connection->client_context, | ||
112 | termination_code); | ||
113 | } | 105 | } |
114 | 106 | ||
115 | /** | 107 | /** |
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 1f85c4b2..40254c00 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -274,9 +274,8 @@ MHD_handle_connection (void *data) | |||
274 | "Processing thread terminating, closing connection\n"); | 274 | "Processing thread terminating, closing connection\n"); |
275 | #endif | 275 | #endif |
276 | #endif | 276 | #endif |
277 | SHUTDOWN (con->socket_fd, SHUT_RDWR); | 277 | MHD_connection_close(con, |
278 | CLOSE (con->socket_fd); | 278 | MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); |
279 | con->socket_fd = -1; | ||
280 | } | 279 | } |
281 | return NULL; | 280 | return NULL; |
282 | } | 281 | } |
@@ -871,6 +870,10 @@ MHD_start_daemon_va (unsigned int options, | |||
871 | case MHD_OPTION_SOCK_ADDR: | 870 | case MHD_OPTION_SOCK_ADDR: |
872 | servaddr = va_arg (ap, struct sockaddr *); | 871 | servaddr = va_arg (ap, struct sockaddr *); |
873 | break; | 872 | break; |
873 | case MHD_OPTION_URI_LOG_CALLBACK: | ||
874 | retVal->uri_log_callback = va_arg(ap, void* (*)(void * cls, const char* uri)); | ||
875 | retVal->uri_log_callback_cls = va_arg(ap, void*); | ||
876 | break; | ||
874 | #if HTTPS_SUPPORT | 877 | #if HTTPS_SUPPORT |
875 | case MHD_OPTION_PROTOCOL_VERSION: | 878 | case MHD_OPTION_PROTOCOL_VERSION: |
876 | _set_priority (&retVal->priority_cache->protocol, | 879 | _set_priority (&retVal->priority_cache->protocol, |
@@ -1065,14 +1068,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
1065 | MHD_DLOG (daemon, "MHD shutdown, closing active connections\n"); | 1068 | MHD_DLOG (daemon, "MHD shutdown, closing active connections\n"); |
1066 | #endif | 1069 | #endif |
1067 | #endif | 1070 | #endif |
1068 | if (daemon->notify_completed != NULL) | 1071 | MHD_connection_close(daemon->connections, |
1069 | daemon->notify_completed (daemon->notify_completed_cls, | 1072 | MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); |
1070 | daemon->connections, | ||
1071 | &daemon->connections->client_context, | ||
1072 | MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); | ||
1073 | SHUTDOWN (daemon->connections->socket_fd, SHUT_RDWR); | ||
1074 | CLOSE (daemon->connections->socket_fd); | ||
1075 | daemon->connections->socket_fd = -1; | ||
1076 | } | 1073 | } |
1077 | MHD_cleanup_connections (daemon); | 1074 | MHD_cleanup_connections (daemon); |
1078 | } | 1075 | } |
diff --git a/src/daemon/internal.h b/src/daemon/internal.h index e0514b9a..4d89ac57 100644 --- a/src/daemon/internal.h +++ b/src/daemon/internal.h | |||
@@ -599,6 +599,10 @@ struct MHD_Daemon | |||
599 | 599 | ||
600 | void *notify_completed_cls; | 600 | void *notify_completed_cls; |
601 | 601 | ||
602 | void * (*uri_log_callback)(void * cls, const char * uri); | ||
603 | |||
604 | void * uri_log_callback_cls; | ||
605 | |||
602 | /** | 606 | /** |
603 | * PID of the select thread (if we have internal select) | 607 | * PID of the select thread (if we have internal select) |
604 | */ | 608 | */ |