diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 822 |
1 files changed, 493 insertions, 329 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 5351b621..30cbbd06 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -110,8 +110,10 @@ mhd_panic_std (void *cls, | |||
110 | { | 110 | { |
111 | #ifdef HAVE_MESSAGES | 111 | #ifdef HAVE_MESSAGES |
112 | fprintf (stderr, | 112 | fprintf (stderr, |
113 | "Fatal error in GNU libmicrohttpd %s:%u: %s\n", | 113 | _("Fatal error in GNU libmicrohttpd %s:%u: %s\n"), |
114 | file, line, reason); | 114 | file, |
115 | line, | ||
116 | reason); | ||
115 | #endif | 117 | #endif |
116 | abort (); | 118 | abort (); |
117 | } | 119 | } |
@@ -193,9 +195,9 @@ struct MHD_IPCount | |||
193 | static void | 195 | static void |
194 | MHD_ip_count_lock (struct MHD_Daemon *daemon) | 196 | MHD_ip_count_lock (struct MHD_Daemon *daemon) |
195 | { | 197 | { |
196 | if (!MHD_mutex_lock_(&daemon->per_ip_connection_mutex)) | 198 | if (! MHD_mutex_lock_(&daemon->per_ip_connection_mutex)) |
197 | { | 199 | { |
198 | MHD_PANIC ("Failed to acquire IP connection limit mutex\n"); | 200 | MHD_PANIC (_("Failed to acquire IP connection limit mutex\n")); |
199 | } | 201 | } |
200 | } | 202 | } |
201 | 203 | ||
@@ -208,9 +210,9 @@ MHD_ip_count_lock (struct MHD_Daemon *daemon) | |||
208 | static void | 210 | static void |
209 | MHD_ip_count_unlock (struct MHD_Daemon *daemon) | 211 | MHD_ip_count_unlock (struct MHD_Daemon *daemon) |
210 | { | 212 | { |
211 | if (!MHD_mutex_unlock_(&daemon->per_ip_connection_mutex)) | 213 | if (! MHD_mutex_unlock_(&daemon->per_ip_connection_mutex)) |
212 | { | 214 | { |
213 | MHD_PANIC ("Failed to release IP connection limit mutex\n"); | 215 | MHD_PANIC (_("Failed to release IP connection limit mutex\n")); |
214 | } | 216 | } |
215 | } | 217 | } |
216 | 218 | ||
@@ -225,17 +227,21 @@ MHD_ip_count_unlock (struct MHD_Daemon *daemon) | |||
225 | * @return -1, 0 or 1 depending on result of compare | 227 | * @return -1, 0 or 1 depending on result of compare |
226 | */ | 228 | */ |
227 | static int | 229 | static int |
228 | MHD_ip_addr_compare (const void *a1, const void *a2) | 230 | MHD_ip_addr_compare (const void *a1, |
231 | const void *a2) | ||
229 | { | 232 | { |
230 | return memcmp (a1, a2, offsetof (struct MHD_IPCount, count)); | 233 | return memcmp (a1, |
234 | a2, | ||
235 | offsetof (struct MHD_IPCount, | ||
236 | count)); | ||
231 | } | 237 | } |
232 | 238 | ||
233 | 239 | ||
234 | /** | 240 | /** |
235 | * Parse address and initialize 'key' using the address. | 241 | * Parse address and initialize @a key using the address. |
236 | * | 242 | * |
237 | * @param addr address to parse | 243 | * @param addr address to parse |
238 | * @param addrlen number of bytes in addr | 244 | * @param addrlen number of bytes in @a addr |
239 | * @param key where to store the parsed address | 245 | * @param key where to store the parsed address |
240 | * @return #MHD_YES on success and #MHD_NO otherwise (e.g., invalid address type) | 246 | * @return #MHD_YES on success and #MHD_NO otherwise (e.g., invalid address type) |
241 | */ | 247 | */ |
@@ -244,14 +250,19 @@ MHD_ip_addr_to_key (const struct sockaddr *addr, | |||
244 | socklen_t addrlen, | 250 | socklen_t addrlen, |
245 | struct MHD_IPCount *key) | 251 | struct MHD_IPCount *key) |
246 | { | 252 | { |
247 | memset(key, 0, sizeof(*key)); | 253 | memset(key, |
254 | 0, | ||
255 | sizeof(*key)); | ||
248 | 256 | ||
249 | /* IPv4 addresses */ | 257 | /* IPv4 addresses */ |
250 | if (sizeof (struct sockaddr_in) == addrlen) | 258 | if (sizeof (struct sockaddr_in) == addrlen) |
251 | { | 259 | { |
252 | const struct sockaddr_in *addr4 = (const struct sockaddr_in*) addr; | 260 | const struct sockaddr_in *addr4 = (const struct sockaddr_in*) addr; |
261 | |||
253 | key->family = AF_INET; | 262 | key->family = AF_INET; |
254 | memcpy (&key->addr.ipv4, &addr4->sin_addr, sizeof(addr4->sin_addr)); | 263 | memcpy (&key->addr.ipv4, |
264 | &addr4->sin_addr, | ||
265 | sizeof(addr4->sin_addr)); | ||
255 | return MHD_YES; | 266 | return MHD_YES; |
256 | } | 267 | } |
257 | 268 | ||
@@ -260,8 +271,11 @@ MHD_ip_addr_to_key (const struct sockaddr *addr, | |||
260 | if (sizeof (struct sockaddr_in6) == addrlen) | 271 | if (sizeof (struct sockaddr_in6) == addrlen) |
261 | { | 272 | { |
262 | const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*) addr; | 273 | const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*) addr; |
274 | |||
263 | key->family = AF_INET6; | 275 | key->family = AF_INET6; |
264 | memcpy (&key->addr.ipv6, &addr6->sin6_addr, sizeof(addr6->sin6_addr)); | 276 | memcpy (&key->addr.ipv6, |
277 | &addr6->sin6_addr, | ||
278 | sizeof(addr6->sin6_addr)); | ||
265 | return MHD_YES; | 279 | return MHD_YES; |
266 | } | 280 | } |
267 | #endif | 281 | #endif |
@@ -272,11 +286,13 @@ MHD_ip_addr_to_key (const struct sockaddr *addr, | |||
272 | 286 | ||
273 | 287 | ||
274 | /** | 288 | /** |
275 | * Check if IP address is over its limit. | 289 | * Check if IP address is over its limit in terms of the number |
290 | * of allowed concurrent connections. If the IP is still allowed, | ||
291 | * increments the connection counter. | ||
276 | * | 292 | * |
277 | * @param daemon handle to daemon where connection counts are tracked | 293 | * @param daemon handle to daemon where connection counts are tracked |
278 | * @param addr address to add (or increment counter) | 294 | * @param addr address to add (or increment counter) |
279 | * @param addrlen number of bytes in addr | 295 | * @param addrlen number of bytes in @a addr |
280 | * @return Return #MHD_YES if IP below limit, #MHD_NO if IP has surpassed limit. | 296 | * @return Return #MHD_YES if IP below limit, #MHD_NO if IP has surpassed limit. |
281 | * Also returns #MHD_NO if fails to allocate memory. | 297 | * Also returns #MHD_NO if fails to allocate memory. |
282 | */ | 298 | */ |
@@ -299,7 +315,9 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon, | |||
299 | return MHD_NO; | 315 | return MHD_NO; |
300 | 316 | ||
301 | /* Initialize key */ | 317 | /* Initialize key */ |
302 | if (MHD_NO == MHD_ip_addr_to_key (addr, addrlen, key)) | 318 | if (MHD_NO == MHD_ip_addr_to_key (addr, |
319 | addrlen, | ||
320 | key)) | ||
303 | { | 321 | { |
304 | /* Allow unhandled address types through */ | 322 | /* Allow unhandled address types through */ |
305 | free (key); | 323 | free (key); |
@@ -314,7 +332,7 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon, | |||
314 | { | 332 | { |
315 | #ifdef HAVE_MESSAGES | 333 | #ifdef HAVE_MESSAGES |
316 | MHD_DLOG (daemon, | 334 | MHD_DLOG (daemon, |
317 | "Failed to add IP connection count node\n"); | 335 | _("Failed to add IP connection count node\n")); |
318 | #endif | 336 | #endif |
319 | MHD_ip_count_unlock (daemon); | 337 | MHD_ip_count_unlock (daemon); |
320 | free (key); | 338 | free (key); |
@@ -358,7 +376,9 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon, | |||
358 | if (0 == daemon->per_ip_connection_limit) | 376 | if (0 == daemon->per_ip_connection_limit) |
359 | return; | 377 | return; |
360 | /* Initialize search key */ | 378 | /* Initialize search key */ |
361 | if (MHD_NO == MHD_ip_addr_to_key (addr, addrlen, &search_key)) | 379 | if (MHD_NO == MHD_ip_addr_to_key (addr, |
380 | addrlen, | ||
381 | &search_key)) | ||
362 | return; | 382 | return; |
363 | 383 | ||
364 | MHD_ip_count_lock (daemon); | 384 | MHD_ip_count_lock (daemon); |
@@ -370,13 +390,13 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon, | |||
370 | { | 390 | { |
371 | /* Something's wrong if we couldn't find an IP address | 391 | /* Something's wrong if we couldn't find an IP address |
372 | * that was previously added */ | 392 | * that was previously added */ |
373 | MHD_PANIC ("Failed to find previously-added IP address\n"); | 393 | MHD_PANIC (_("Failed to find previously-added IP address\n")); |
374 | } | 394 | } |
375 | found_key = (struct MHD_IPCount *) *nodep; | 395 | found_key = (struct MHD_IPCount *) *nodep; |
376 | /* Validate existing count for IP address */ | 396 | /* Validate existing count for IP address */ |
377 | if (0 == found_key->count) | 397 | if (0 == found_key->count) |
378 | { | 398 | { |
379 | MHD_PANIC ("Previously-added IP address had 0 count\n"); | 399 | MHD_PANIC (_("Previously-added IP address had counter of zero\n")); |
380 | } | 400 | } |
381 | /* Remove the node entirely if count reduces to 0 */ | 401 | /* Remove the node entirely if count reduces to 0 */ |
382 | if (0 == --found_key->count) | 402 | if (0 == --found_key->count) |
@@ -505,7 +525,8 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) | |||
505 | { | 525 | { |
506 | cert.data = (unsigned char *) daemon->https_mem_trust; | 526 | cert.data = (unsigned char *) daemon->https_mem_trust; |
507 | cert.size = strlen (daemon->https_mem_trust); | 527 | cert.size = strlen (daemon->https_mem_trust); |
508 | if (gnutls_certificate_set_x509_trust_mem (daemon->x509_cred, &cert, | 528 | if (gnutls_certificate_set_x509_trust_mem (daemon->x509_cred, |
529 | &cert, | ||
509 | GNUTLS_X509_FMT_PEM) < 0) | 530 | GNUTLS_X509_FMT_PEM) < 0) |
510 | { | 531 | { |
511 | #ifdef HAVE_MESSAGES | 532 | #ifdef HAVE_MESSAGES |
@@ -533,22 +554,24 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) | |||
533 | if (NULL != daemon->https_key_password) { | 554 | if (NULL != daemon->https_key_password) { |
534 | #if GNUTLS_VERSION_NUMBER >= 0x030111 | 555 | #if GNUTLS_VERSION_NUMBER >= 0x030111 |
535 | ret = gnutls_certificate_set_x509_key_mem2 (daemon->x509_cred, | 556 | ret = gnutls_certificate_set_x509_key_mem2 (daemon->x509_cred, |
536 | &cert, &key, | 557 | &cert, |
558 | &key, | ||
537 | GNUTLS_X509_FMT_PEM, | 559 | GNUTLS_X509_FMT_PEM, |
538 | daemon->https_key_password, | 560 | daemon->https_key_password, |
539 | 0); | 561 | 0); |
540 | #else | 562 | #else |
541 | #ifdef HAVE_MESSAGES | 563 | #ifdef HAVE_MESSAGES |
542 | MHD_DLOG (daemon, | 564 | MHD_DLOG (daemon, |
543 | "Failed to setup x509 certificate/key: pre 3.X.X version " \ | 565 | _("Failed to setup x509 certificate/key: pre 3.X.X version " \ |
544 | "of GnuTLS does not support setting key password"); | 566 | "of GnuTLS does not support setting key password")); |
545 | #endif | 567 | #endif |
546 | return -1; | 568 | return -1; |
547 | #endif | 569 | #endif |
548 | } | 570 | } |
549 | else | 571 | else |
550 | ret = gnutls_certificate_set_x509_key_mem (daemon->x509_cred, | 572 | ret = gnutls_certificate_set_x509_key_mem (daemon->x509_cred, |
551 | &cert, &key, | 573 | &cert, |
574 | &key, | ||
552 | GNUTLS_X509_FMT_PEM); | 575 | GNUTLS_X509_FMT_PEM); |
553 | #ifdef HAVE_MESSAGES | 576 | #ifdef HAVE_MESSAGES |
554 | if (0 != ret) | 577 | if (0 != ret) |
@@ -589,7 +612,7 @@ MHD_TLS_init (struct MHD_Daemon *daemon) | |||
589 | default: | 612 | default: |
590 | #ifdef HAVE_MESSAGES | 613 | #ifdef HAVE_MESSAGES |
591 | MHD_DLOG (daemon, | 614 | MHD_DLOG (daemon, |
592 | "Error: invalid credentials type %d specified.\n", | 615 | _("Error: invalid credentials type %d specified.\n"), |
593 | daemon->cred_type); | 616 | daemon->cred_type); |
594 | #endif | 617 | #endif |
595 | return -1; | 618 | return -1; |
@@ -829,7 +852,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon, | |||
829 | #ifdef HAVE_MESSAGES | 852 | #ifdef HAVE_MESSAGES |
830 | if (NULL != max_fd) | 853 | if (NULL != max_fd) |
831 | MHD_DLOG (daemon, | 854 | MHD_DLOG (daemon, |
832 | "Maximum socket in select set: %d\n", | 855 | _("Maximum socket in select set: %d\n"), |
833 | *max_fd); | 856 | *max_fd); |
834 | #endif | 857 | #endif |
835 | #endif | 858 | #endif |
@@ -922,7 +945,7 @@ finish_upgrade_close (struct MHD_UpgradeResponseHandle *urh) | |||
922 | EPOLL_CTL_DEL, | 945 | EPOLL_CTL_DEL, |
923 | connection->socket_fd, | 946 | connection->socket_fd, |
924 | NULL)) | 947 | NULL)) |
925 | MHD_PANIC ("Failed to remove FD from epoll set\n"); | 948 | MHD_PANIC (_("Failed to remove FD from epoll set\n")); |
926 | } | 949 | } |
927 | if (MHD_INVALID_SOCKET != urh->mhd.socket) | 950 | if (MHD_INVALID_SOCKET != urh->mhd.socket) |
928 | { | 951 | { |
@@ -937,9 +960,9 @@ finish_upgrade_close (struct MHD_UpgradeResponseHandle *urh) | |||
937 | EPOLL_CTL_DEL, | 960 | EPOLL_CTL_DEL, |
938 | urh->mhd.socket, | 961 | urh->mhd.socket, |
939 | NULL)) ) | 962 | NULL)) ) |
940 | MHD_PANIC ("Failed to remove FD from epoll set\n"); | 963 | MHD_PANIC (_("Failed to remove FD from epoll set\n")); |
941 | if (0 != MHD_socket_close_ (urh->mhd.socket)) | 964 | if (0 != MHD_socket_close_ (urh->mhd.socket)) |
942 | MHD_PANIC ("close failed\n"); | 965 | MHD_PANIC (_("close failed\n")); |
943 | } | 966 | } |
944 | MHD_resume_connection (connection); | 967 | MHD_resume_connection (connection); |
945 | MHD_connection_close_ (connection, | 968 | MHD_connection_close_ (connection, |
@@ -1133,7 +1156,7 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1133 | { | 1156 | { |
1134 | #ifdef HAVE_MESSAGES | 1157 | #ifdef HAVE_MESSAGES |
1135 | MHD_DLOG (con->daemon, | 1158 | MHD_DLOG (con->daemon, |
1136 | "Error preparing select\n"); | 1159 | _("Error preparing select\n")); |
1137 | #endif | 1160 | #endif |
1138 | break; | 1161 | break; |
1139 | } | 1162 | } |
@@ -1153,7 +1176,7 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1153 | continue; | 1176 | continue; |
1154 | #ifdef HAVE_MESSAGES | 1177 | #ifdef HAVE_MESSAGES |
1155 | MHD_DLOG (con->daemon, | 1178 | MHD_DLOG (con->daemon, |
1156 | "Error during select (%d): `%s'\n", | 1179 | _("Error during select (%d): `%s'\n"), |
1157 | err, | 1180 | err, |
1158 | MHD_socket_strerr_ (err)); | 1181 | MHD_socket_strerr_ (err)); |
1159 | #endif | 1182 | #endif |
@@ -1178,7 +1201,9 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1178 | { | 1201 | { |
1179 | struct pollfd p[2]; | 1202 | struct pollfd p[2]; |
1180 | 1203 | ||
1181 | memset (p, 0, sizeof (struct pollfd) * 2); | 1204 | memset (p, |
1205 | 0, | ||
1206 | sizeof (struct pollfd) * 2); | ||
1182 | p[0].fd = urh->connection->socket_fd; | 1207 | p[0].fd = urh->connection->socket_fd; |
1183 | p[1].fd = urh->mhd.socket; | 1208 | p[1].fd = urh->mhd.socket; |
1184 | if (urh->in_buffer_off < urh->in_buffer_size) | 1209 | if (urh->in_buffer_off < urh->in_buffer_size) |
@@ -1201,7 +1226,7 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1201 | continue; | 1226 | continue; |
1202 | #ifdef HAVE_MESSAGES | 1227 | #ifdef HAVE_MESSAGES |
1203 | MHD_DLOG (con->daemon, | 1228 | MHD_DLOG (con->daemon, |
1204 | "Error during poll: `%s'\n", | 1229 | _("Error during poll: `%s'\n"), |
1205 | MHD_socket_strerr_ (err)); | 1230 | MHD_socket_strerr_ (err)); |
1206 | #endif | 1231 | #endif |
1207 | break; | 1232 | break; |
@@ -1362,7 +1387,7 @@ thread_main_handle_connection (void *data) | |||
1362 | { | 1387 | { |
1363 | #ifdef HAVE_MESSAGES | 1388 | #ifdef HAVE_MESSAGES |
1364 | MHD_DLOG (con->daemon, | 1389 | MHD_DLOG (con->daemon, |
1365 | "Can't add FD to fd_set\n"); | 1390 | _("Failed to add FD to fd_set\n")); |
1366 | #endif | 1391 | #endif |
1367 | goto exit; | 1392 | goto exit; |
1368 | } | 1393 | } |
@@ -1380,7 +1405,7 @@ thread_main_handle_connection (void *data) | |||
1380 | continue; | 1405 | continue; |
1381 | #ifdef HAVE_MESSAGES | 1406 | #ifdef HAVE_MESSAGES |
1382 | MHD_DLOG (con->daemon, | 1407 | MHD_DLOG (con->daemon, |
1383 | "Error during select (%d): `%s'\n", | 1408 | _("Error during select (%d): `%s'\n"), |
1384 | err, | 1409 | err, |
1385 | MHD_socket_strerr_ (err)); | 1410 | MHD_socket_strerr_ (err)); |
1386 | #endif | 1411 | #endif |
@@ -1389,7 +1414,8 @@ thread_main_handle_connection (void *data) | |||
1389 | #if WINDOWS | 1414 | #if WINDOWS |
1390 | /* drain signaling pipe before other processing */ | 1415 | /* drain signaling pipe before other processing */ |
1391 | if ( (MHD_INVALID_PIPE_ != spipe) && | 1416 | if ( (MHD_INVALID_PIPE_ != spipe) && |
1392 | (FD_ISSET (spipe, &rs)) ) | 1417 | (FD_ISSET (spipe, |
1418 | &rs)) ) | ||
1393 | MHD_pipe_drain_ (spipe); | 1419 | MHD_pipe_drain_ (spipe); |
1394 | #endif | 1420 | #endif |
1395 | if (MHD_NO == | 1421 | if (MHD_NO == |
@@ -1452,7 +1478,7 @@ thread_main_handle_connection (void *data) | |||
1452 | continue; | 1478 | continue; |
1453 | #ifdef HAVE_MESSAGES | 1479 | #ifdef HAVE_MESSAGES |
1454 | MHD_DLOG (con->daemon, | 1480 | MHD_DLOG (con->daemon, |
1455 | "Error during poll: `%s'\n", | 1481 | _("Error during poll: `%s'\n"), |
1456 | MHD_socket_last_strerr_ ()); | 1482 | MHD_socket_last_strerr_ ()); |
1457 | #endif | 1483 | #endif |
1458 | break; | 1484 | break; |
@@ -1482,7 +1508,7 @@ thread_main_handle_connection (void *data) | |||
1482 | #if DEBUG_CLOSE | 1508 | #if DEBUG_CLOSE |
1483 | #ifdef HAVE_MESSAGES | 1509 | #ifdef HAVE_MESSAGES |
1484 | MHD_DLOG (con->daemon, | 1510 | MHD_DLOG (con->daemon, |
1485 | "Processing thread terminating, closing connection\n"); | 1511 | _("Processing thread terminating. Closing connection\n")); |
1486 | #endif | 1512 | #endif |
1487 | #endif | 1513 | #endif |
1488 | if (MHD_CONNECTION_CLOSED != con->state) | 1514 | if (MHD_CONNECTION_CLOSED != con->state) |
@@ -1507,7 +1533,7 @@ exit: | |||
1507 | shutdown (con->socket_fd, | 1533 | shutdown (con->socket_fd, |
1508 | SHUT_WR); | 1534 | SHUT_WR); |
1509 | if (0 != MHD_socket_close_ (con->socket_fd)) | 1535 | if (0 != MHD_socket_close_ (con->socket_fd)) |
1510 | MHD_PANIC ("close failed\n"); | 1536 | MHD_PANIC (_("close failed\n")); |
1511 | con->socket_fd = MHD_INVALID_SOCKET; | 1537 | con->socket_fd = MHD_INVALID_SOCKET; |
1512 | } | 1538 | } |
1513 | return (MHD_THRD_RTRN_TYPE_) 0; | 1539 | return (MHD_THRD_RTRN_TYPE_) 0; |
@@ -1617,11 +1643,17 @@ send_param_adapter (struct MHD_Connection *connection, | |||
1617 | #ifndef HAVE_SENDFILE64 | 1643 | #ifndef HAVE_SENDFILE64 |
1618 | offset = (off_t) offsetu64; | 1644 | offset = (off_t) offsetu64; |
1619 | if ( (offsetu64 <= (uint64_t) OFF_T_MAX) && | 1645 | if ( (offsetu64 <= (uint64_t) OFF_T_MAX) && |
1620 | (0 < (ret = sendfile (connection->socket_fd, fd, &offset, left))) ) | 1646 | (0 < (ret = sendfile (connection->socket_fd, |
1647 | fd, | ||
1648 | &offset, | ||
1649 | left))) ) | ||
1621 | #else /* HAVE_SENDFILE64 */ | 1650 | #else /* HAVE_SENDFILE64 */ |
1622 | offset = (off64_t) offsetu64; | 1651 | offset = (off64_t) offsetu64; |
1623 | if ( (offsetu64 <= (uint64_t) OFF64_T_MAX) && | 1652 | if ( (offsetu64 <= (uint64_t) OFF64_T_MAX) && |
1624 | (0 < (ret = sendfile64 (connection->socket_fd, fd, &offset, left))) ) | 1653 | (0 < (ret = sendfile64 (connection->socket_fd, |
1654 | fd, | ||
1655 | &offset, | ||
1656 | left))) ) | ||
1625 | #endif /* HAVE_SENDFILE64 */ | 1657 | #endif /* HAVE_SENDFILE64 */ |
1626 | { | 1658 | { |
1627 | /* write successful */ | 1659 | /* write successful */ |
@@ -1635,9 +1667,11 @@ send_param_adapter (struct MHD_Connection *connection, | |||
1635 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | 1667 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; |
1636 | } | 1668 | } |
1637 | #endif | 1669 | #endif |
1638 | if (MHD_SCKT_ERR_IS_EINTR_ (err) || MHD_SCKT_ERR_IS_EAGAIN_ (err)) | 1670 | if (MHD_SCKT_ERR_IS_EINTR_ (err) || |
1671 | MHD_SCKT_ERR_IS_EAGAIN_ (err)) | ||
1639 | return 0; | 1672 | return 0; |
1640 | if (MHD_SCKT_ERR_IS_(err, MHD_SCKT_EBADF_)) | 1673 | if (MHD_SCKT_ERR_IS_(err, |
1674 | MHD_SCKT_EBADF_)) | ||
1641 | return -1; | 1675 | return -1; |
1642 | /* sendfile() failed with EINVAL if mmap()-like operations are not | 1676 | /* sendfile() failed with EINVAL if mmap()-like operations are not |
1643 | supported for FD or other 'unusual' errors occurred, so we should try | 1677 | supported for FD or other 'unusual' errors occurred, so we should try |
@@ -1646,10 +1680,14 @@ send_param_adapter (struct MHD_Connection *connection, | |||
1646 | http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ | 1680 | http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ |
1647 | } | 1681 | } |
1648 | #endif | 1682 | #endif |
1649 | ret = (ssize_t) send (connection->socket_fd, other, (MHD_SCKT_SEND_SIZE_)i, MSG_NOSIGNAL); | 1683 | ret = (ssize_t) send (connection->socket_fd, |
1684 | other, | ||
1685 | (MHD_SCKT_SEND_SIZE_) i, | ||
1686 | MSG_NOSIGNAL); | ||
1650 | err = MHD_socket_get_error_(); | 1687 | err = MHD_socket_get_error_(); |
1651 | #ifdef EPOLL_SUPPORT | 1688 | #ifdef EPOLL_SUPPORT |
1652 | if ( (0 > ret) && (MHD_SCKT_ERR_IS_EAGAIN_(err)) ) | 1689 | if ( (0 > ret) && |
1690 | (MHD_SCKT_ERR_IS_EAGAIN_(err)) ) | ||
1653 | { | 1691 | { |
1654 | /* EAGAIN --- no longer write-ready */ | 1692 | /* EAGAIN --- no longer write-ready */ |
1655 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | 1693 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; |
@@ -1658,7 +1696,8 @@ send_param_adapter (struct MHD_Connection *connection, | |||
1658 | /* Handle broken kernel / libc, returning -1 but not setting errno; | 1696 | /* Handle broken kernel / libc, returning -1 but not setting errno; |
1659 | kill connection as that should be safe; reported on mailinglist here: | 1697 | kill connection as that should be safe; reported on mailinglist here: |
1660 | http://lists.gnu.org/archive/html/libmicrohttpd/2014-10/msg00023.html */ | 1698 | http://lists.gnu.org/archive/html/libmicrohttpd/2014-10/msg00023.html */ |
1661 | if ( (0 > ret) && (0 == err) ) | 1699 | if ( (0 > ret) && |
1700 | (0 == err) ) | ||
1662 | MHD_socket_set_error_ (MHD_SCKT_ECONNRESET_); | 1701 | MHD_socket_set_error_ (MHD_SCKT_ECONNRESET_); |
1663 | return ret; | 1702 | return ret; |
1664 | } | 1703 | } |
@@ -1727,7 +1766,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1727 | if (worker->connections < worker->connection_limit) | 1766 | if (worker->connections < worker->connection_limit) |
1728 | return internal_add_connection (worker, | 1767 | return internal_add_connection (worker, |
1729 | client_socket, | 1768 | client_socket, |
1730 | addr, addrlen, | 1769 | addr, |
1770 | addrlen, | ||
1731 | external_add); | 1771 | external_add); |
1732 | } | 1772 | } |
1733 | /* all pools are at their connection limit, must refuse */ | 1773 | /* all pools are at their connection limit, must refuse */ |
@@ -1739,17 +1779,18 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1739 | return MHD_NO; | 1779 | return MHD_NO; |
1740 | } | 1780 | } |
1741 | 1781 | ||
1742 | if ( (! MHD_SCKT_FD_FITS_FDSET_(client_socket, NULL)) && | 1782 | if ( (! MHD_SCKT_FD_FITS_FDSET_(client_socket, |
1783 | NULL)) && | ||
1743 | (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) ) | 1784 | (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) ) |
1744 | { | 1785 | { |
1745 | #ifdef HAVE_MESSAGES | 1786 | #ifdef HAVE_MESSAGES |
1746 | MHD_DLOG (daemon, | 1787 | MHD_DLOG (daemon, |
1747 | "Socket descriptor larger than FD_SETSIZE: %d > %d\n", | 1788 | _("Socket descriptor larger than FD_SETSIZE: %d > %d\n"), |
1748 | (int)client_socket, | 1789 | (int) client_socket, |
1749 | (int)FD_SETSIZE); | 1790 | (int) FD_SETSIZE); |
1750 | #endif | 1791 | #endif |
1751 | if (0 != MHD_socket_close_ (client_socket)) | 1792 | if (0 != MHD_socket_close_ (client_socket)) |
1752 | MHD_PANIC ("close failed\n"); | 1793 | MHD_PANIC (_("close failed\n")); |
1753 | #if EINVAL | 1794 | #if EINVAL |
1754 | errno = EINVAL; | 1795 | errno = EINVAL; |
1755 | #endif | 1796 | #endif |
@@ -1760,20 +1801,22 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1760 | #ifdef HAVE_MESSAGES | 1801 | #ifdef HAVE_MESSAGES |
1761 | #if DEBUG_CONNECT | 1802 | #if DEBUG_CONNECT |
1762 | MHD_DLOG (daemon, | 1803 | MHD_DLOG (daemon, |
1763 | "Accepted connection on socket %d\n", | 1804 | _("Accepted connection on socket %d\n"), |
1764 | client_socket); | 1805 | client_socket); |
1765 | #endif | 1806 | #endif |
1766 | #endif | 1807 | #endif |
1767 | if ( (daemon->connections == daemon->connection_limit) || | 1808 | if ( (daemon->connections == daemon->connection_limit) || |
1768 | (MHD_NO == MHD_ip_limit_add (daemon, addr, addrlen)) ) | 1809 | (MHD_NO == MHD_ip_limit_add (daemon, |
1810 | addr, | ||
1811 | addrlen)) ) | ||
1769 | { | 1812 | { |
1770 | /* above connection limit - reject */ | 1813 | /* above connection limit - reject */ |
1771 | #ifdef HAVE_MESSAGES | 1814 | #ifdef HAVE_MESSAGES |
1772 | MHD_DLOG (daemon, | 1815 | MHD_DLOG (daemon, |
1773 | "Server reached connection limit (closing inbound connection)\n"); | 1816 | _("Server reached connection limit. Closing inbound connection.\n")); |
1774 | #endif | 1817 | #endif |
1775 | if (0 != MHD_socket_close_ (client_socket)) | 1818 | if (0 != MHD_socket_close_ (client_socket)) |
1776 | MHD_PANIC ("close failed\n"); | 1819 | MHD_PANIC (_("close failed\n")); |
1777 | #if ENFILE | 1820 | #if ENFILE |
1778 | errno = ENFILE; | 1821 | errno = ENFILE; |
1779 | #endif | 1822 | #endif |
@@ -1783,17 +1826,20 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1783 | /* apply connection acceptance policy if present */ | 1826 | /* apply connection acceptance policy if present */ |
1784 | if ( (NULL != daemon->apc) && | 1827 | if ( (NULL != daemon->apc) && |
1785 | (MHD_NO == daemon->apc (daemon->apc_cls, | 1828 | (MHD_NO == daemon->apc (daemon->apc_cls, |
1786 | addr, addrlen)) ) | 1829 | addr, |
1830 | addrlen)) ) | ||
1787 | { | 1831 | { |
1788 | #if DEBUG_CLOSE | 1832 | #if DEBUG_CLOSE |
1789 | #ifdef HAVE_MESSAGES | 1833 | #ifdef HAVE_MESSAGES |
1790 | MHD_DLOG (daemon, | 1834 | MHD_DLOG (daemon, |
1791 | "Connection rejected, closing connection\n"); | 1835 | _("Connection rejected by application. Closing connection.\n")); |
1792 | #endif | 1836 | #endif |
1793 | #endif | 1837 | #endif |
1794 | if (0 != MHD_socket_close_ (client_socket)) | 1838 | if (0 != MHD_socket_close_ (client_socket)) |
1795 | MHD_PANIC ("close failed\n"); | 1839 | MHD_PANIC (_("close failed\n")); |
1796 | MHD_ip_limit_del (daemon, addr, addrlen); | 1840 | MHD_ip_limit_del (daemon, |
1841 | addr, | ||
1842 | addrlen); | ||
1797 | #if EACCESS | 1843 | #if EACCESS |
1798 | errno = EACCESS; | 1844 | errno = EACCESS; |
1799 | #endif | 1845 | #endif |
@@ -1804,8 +1850,10 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1804 | #ifdef SOL_SOCKET | 1850 | #ifdef SOL_SOCKET |
1805 | #ifdef SO_NOSIGPIPE | 1851 | #ifdef SO_NOSIGPIPE |
1806 | setsockopt (client_socket, | 1852 | setsockopt (client_socket, |
1807 | SOL_SOCKET, SO_NOSIGPIPE, | 1853 | SOL_SOCKET, |
1808 | &on, sizeof (on)); | 1854 | SO_NOSIGPIPE, |
1855 | &on, | ||
1856 | sizeof (on)); | ||
1809 | #endif | 1857 | #endif |
1810 | #endif | 1858 | #endif |
1811 | #endif | 1859 | #endif |
@@ -1820,7 +1868,9 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1820 | #endif | 1868 | #endif |
1821 | if (0 != MHD_socket_close_ (client_socket)) | 1869 | if (0 != MHD_socket_close_ (client_socket)) |
1822 | MHD_PANIC ("close failed\n"); | 1870 | MHD_PANIC ("close failed\n"); |
1823 | MHD_ip_limit_del (daemon, addr, addrlen); | 1871 | MHD_ip_limit_del (daemon, |
1872 | addr, | ||
1873 | addrlen); | ||
1824 | errno = eno; | 1874 | errno = eno; |
1825 | return MHD_NO; | 1875 | return MHD_NO; |
1826 | } | 1876 | } |
@@ -1832,12 +1882,14 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1832 | { | 1882 | { |
1833 | #ifdef HAVE_MESSAGES | 1883 | #ifdef HAVE_MESSAGES |
1834 | MHD_DLOG (daemon, | 1884 | MHD_DLOG (daemon, |
1835 | "Error allocating memory: %s\n", | 1885 | _("Error allocating memory: %s\n"), |
1836 | MHD_strerror_ (errno)); | 1886 | MHD_strerror_ (errno)); |
1837 | #endif | 1887 | #endif |
1838 | if (0 != MHD_socket_close_ (client_socket)) | 1888 | if (0 != MHD_socket_close_ (client_socket)) |
1839 | MHD_PANIC ("close failed\n"); | 1889 | MHD_PANIC (_("close failed\n")); |
1840 | MHD_ip_limit_del (daemon, addr, addrlen); | 1890 | MHD_ip_limit_del (daemon, |
1891 | addr, | ||
1892 | addrlen); | ||
1841 | free (connection); | 1893 | free (connection); |
1842 | #if ENOMEM | 1894 | #if ENOMEM |
1843 | errno = ENOMEM; | 1895 | errno = ENOMEM; |
@@ -1851,18 +1903,22 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1851 | eno = errno; | 1903 | eno = errno; |
1852 | #ifdef HAVE_MESSAGES | 1904 | #ifdef HAVE_MESSAGES |
1853 | MHD_DLOG (daemon, | 1905 | MHD_DLOG (daemon, |
1854 | "Error allocating memory: %s\n", | 1906 | _("Error allocating memory: %s\n"), |
1855 | MHD_strerror_ (errno)); | 1907 | MHD_strerror_ (errno)); |
1856 | #endif | 1908 | #endif |
1857 | if (0 != MHD_socket_close_ (client_socket)) | 1909 | if (0 != MHD_socket_close_ (client_socket)) |
1858 | MHD_PANIC ("close failed\n"); | 1910 | MHD_PANIC (_("close failed\n")); |
1859 | MHD_ip_limit_del (daemon, addr, addrlen); | 1911 | MHD_ip_limit_del (daemon, |
1912 | addr, | ||
1913 | addrlen); | ||
1860 | MHD_pool_destroy (connection->pool); | 1914 | MHD_pool_destroy (connection->pool); |
1861 | free (connection); | 1915 | free (connection); |
1862 | errno = eno; | 1916 | errno = eno; |
1863 | return MHD_NO; | 1917 | return MHD_NO; |
1864 | } | 1918 | } |
1865 | memcpy (connection->addr, addr, addrlen); | 1919 | memcpy (connection->addr, |
1920 | addr, | ||
1921 | addrlen); | ||
1866 | connection->addr_len = addrlen; | 1922 | connection->addr_len = addrlen; |
1867 | connection->socket_fd = client_socket; | 1923 | connection->socket_fd = client_socket; |
1868 | connection->daemon = daemon; | 1924 | connection->daemon = daemon; |
@@ -1881,7 +1937,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1881 | { | 1937 | { |
1882 | #ifdef HAVE_MESSAGES | 1938 | #ifdef HAVE_MESSAGES |
1883 | MHD_DLOG (connection->daemon, | 1939 | MHD_DLOG (connection->daemon, |
1884 | "Failed to set nonblocking mode on connection socket: %s\n", | 1940 | _("Failed to set nonblocking mode on connection socket: %s\n"), |
1885 | MHD_socket_last_strerr_()); | 1941 | MHD_socket_last_strerr_()); |
1886 | #endif | 1942 | #endif |
1887 | } | 1943 | } |
@@ -1894,7 +1950,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1894 | connection->send_cls = &send_tls_adapter; | 1950 | connection->send_cls = &send_tls_adapter; |
1895 | connection->state = MHD_TLS_CONNECTION_INIT; | 1951 | connection->state = MHD_TLS_CONNECTION_INIT; |
1896 | MHD_set_https_callbacks (connection); | 1952 | MHD_set_https_callbacks (connection); |
1897 | gnutls_init (&connection->tls_session, GNUTLS_SERVER); | 1953 | gnutls_init (&connection->tls_session, |
1954 | GNUTLS_SERVER); | ||
1898 | gnutls_priority_set (connection->tls_session, | 1955 | gnutls_priority_set (connection->tls_session, |
1899 | daemon->priority_cache); | 1956 | daemon->priority_cache); |
1900 | switch (daemon->cred_type) | 1957 | switch (daemon->cred_type) |
@@ -1908,15 +1965,17 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1908 | default: | 1965 | default: |
1909 | #ifdef HAVE_MESSAGES | 1966 | #ifdef HAVE_MESSAGES |
1910 | MHD_DLOG (connection->daemon, | 1967 | MHD_DLOG (connection->daemon, |
1911 | "Failed to setup TLS credentials: unknown credential type %d\n", | 1968 | _("Failed to setup TLS credentials: unknown credential type %d\n"), |
1912 | daemon->cred_type); | 1969 | daemon->cred_type); |
1913 | #endif | 1970 | #endif |
1914 | if (0 != MHD_socket_close_ (client_socket)) | 1971 | if (0 != MHD_socket_close_ (client_socket)) |
1915 | MHD_PANIC ("close failed\n"); | 1972 | MHD_PANIC ("close failed\n"); |
1916 | MHD_ip_limit_del (daemon, addr, addrlen); | 1973 | MHD_ip_limit_del (daemon, |
1974 | addr, | ||
1975 | addrlen); | ||
1917 | free (connection->addr); | 1976 | free (connection->addr); |
1918 | free (connection); | 1977 | free (connection); |
1919 | MHD_PANIC ("Unknown credential type"); | 1978 | MHD_PANIC (_("Unknown credential type")); |
1920 | #if EINVAL | 1979 | #if EINVAL |
1921 | errno = EINVAL; | 1980 | errno = EINVAL; |
1922 | #endif | 1981 | #endif |
@@ -1938,7 +1997,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1938 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 1997 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
1939 | { | 1998 | { |
1940 | if (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) | 1999 | if (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) |
1941 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2000 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
1942 | } | 2001 | } |
1943 | else | 2002 | else |
1944 | XDLL_insert (daemon->normal_timeout_head, | 2003 | XDLL_insert (daemon->normal_timeout_head, |
@@ -1949,7 +2008,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1949 | connection); | 2008 | connection); |
1950 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2009 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
1951 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 2010 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
1952 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 2011 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
1953 | 2012 | ||
1954 | if (NULL != daemon->notify_connection) | 2013 | if (NULL != daemon->notify_connection) |
1955 | daemon->notify_connection (daemon->notify_connection_cls, | 2014 | daemon->notify_connection (daemon->notify_connection_cls, |
@@ -1960,11 +2019,11 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1960 | /* attempt to create handler thread */ | 2019 | /* attempt to create handler thread */ |
1961 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 2020 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
1962 | { | 2021 | { |
1963 | if (! MHD_create_named_thread_(&connection->pid, | 2022 | if (! MHD_create_named_thread_ (&connection->pid, |
1964 | "MHD-connection", | 2023 | "MHD-connection", |
1965 | daemon->thread_stack_size, | 2024 | daemon->thread_stack_size, |
1966 | &thread_main_handle_connection, | 2025 | &thread_main_handle_connection, |
1967 | connection)) | 2026 | connection)) |
1968 | { | 2027 | { |
1969 | eno = errno; | 2028 | eno = errno; |
1970 | #ifdef HAVE_MESSAGES | 2029 | #ifdef HAVE_MESSAGES |
@@ -1978,11 +2037,13 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1978 | else | 2037 | else |
1979 | if ( (MHD_YES == external_add) && | 2038 | if ( (MHD_YES == external_add) && |
1980 | (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && | 2039 | (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && |
1981 | (1 != MHD_pipe_write_ (daemon->wpipe[1], "n", 1)) ) | 2040 | (1 != MHD_pipe_write_ (daemon->wpipe[1], |
2041 | "n", | ||
2042 | 1)) ) | ||
1982 | { | 2043 | { |
1983 | #ifdef HAVE_MESSAGES | 2044 | #ifdef HAVE_MESSAGES |
1984 | MHD_DLOG (daemon, | 2045 | MHD_DLOG (daemon, |
1985 | "failed to signal new connection via pipe"); | 2046 | _("Failed to signal new connection via pipe.")); |
1986 | #endif | 2047 | #endif |
1987 | } | 2048 | } |
1988 | #ifdef EPOLL_SUPPORT | 2049 | #ifdef EPOLL_SUPPORT |
@@ -2002,7 +2063,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2002 | eno = errno; | 2063 | eno = errno; |
2003 | #ifdef HAVE_MESSAGES | 2064 | #ifdef HAVE_MESSAGES |
2004 | MHD_DLOG (daemon, | 2065 | MHD_DLOG (daemon, |
2005 | "Call to epoll_ctl failed: %s\n", | 2066 | _("Call to epoll_ctl failed: %s\n"), |
2006 | MHD_socket_last_strerr_ ()); | 2067 | MHD_socket_last_strerr_ ()); |
2007 | #endif | 2068 | #endif |
2008 | goto cleanup; | 2069 | goto cleanup; |
@@ -2028,12 +2089,12 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2028 | &connection->socket_context, | 2089 | &connection->socket_context, |
2029 | MHD_CONNECTION_NOTIFY_CLOSED); | 2090 | MHD_CONNECTION_NOTIFY_CLOSED); |
2030 | if (0 != MHD_socket_close_ (client_socket)) | 2091 | if (0 != MHD_socket_close_ (client_socket)) |
2031 | MHD_PANIC ("close failed\n"); | 2092 | MHD_PANIC (_("close failed\n")); |
2032 | MHD_ip_limit_del (daemon, addr, addrlen); | 2093 | MHD_ip_limit_del (daemon, addr, addrlen); |
2033 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 2094 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
2034 | { | 2095 | { |
2035 | if (!MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) | 2096 | if (!MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) |
2036 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2097 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
2037 | } | 2098 | } |
2038 | else | 2099 | else |
2039 | XDLL_remove (daemon->normal_timeout_head, | 2100 | XDLL_remove (daemon->normal_timeout_head, |
@@ -2044,7 +2105,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2044 | connection); | 2105 | connection); |
2045 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2106 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2046 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 2107 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
2047 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 2108 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
2048 | MHD_pool_destroy (connection->pool); | 2109 | MHD_pool_destroy (connection->pool); |
2049 | free (connection->addr); | 2110 | free (connection->addr); |
2050 | free (connection); | 2111 | free (connection); |
@@ -2087,11 +2148,11 @@ MHD_suspend_connection (struct MHD_Connection *connection) | |||
2087 | 2148 | ||
2088 | daemon = connection->daemon; | 2149 | daemon = connection->daemon; |
2089 | if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME)) | 2150 | if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME)) |
2090 | MHD_PANIC ("Cannot suspend connections without enabling MHD_USE_SUSPEND_RESUME!\n"); | 2151 | MHD_PANIC (_("Cannot suspend connections without enabling MHD_USE_SUSPEND_RESUME!\n")); |
2091 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 2152 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
2092 | { | 2153 | { |
2093 | if (!MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) | 2154 | if (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) |
2094 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2155 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
2095 | } | 2156 | } |
2096 | else | 2157 | else |
2097 | { | 2158 | { |
@@ -2126,7 +2187,7 @@ MHD_suspend_connection (struct MHD_Connection *connection) | |||
2126 | EPOLL_CTL_DEL, | 2187 | EPOLL_CTL_DEL, |
2127 | connection->socket_fd, | 2188 | connection->socket_fd, |
2128 | NULL)) | 2189 | NULL)) |
2129 | MHD_PANIC ("Failed to remove FD from epoll set\n"); | 2190 | MHD_PANIC (_("Failed to remove FD from epoll set\n")); |
2130 | connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; | 2191 | connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; |
2131 | } | 2192 | } |
2132 | connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED; | 2193 | connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED; |
@@ -2134,8 +2195,8 @@ MHD_suspend_connection (struct MHD_Connection *connection) | |||
2134 | #endif | 2195 | #endif |
2135 | connection->suspended = MHD_YES; | 2196 | connection->suspended = MHD_YES; |
2136 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2197 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2137 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 2198 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
2138 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 2199 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
2139 | } | 2200 | } |
2140 | 2201 | ||
2141 | 2202 | ||
@@ -2154,10 +2215,10 @@ MHD_resume_connection (struct MHD_Connection *connection) | |||
2154 | 2215 | ||
2155 | daemon = connection->daemon; | 2216 | daemon = connection->daemon; |
2156 | if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME)) | 2217 | if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME)) |
2157 | MHD_PANIC ("Cannot resume connections without enabling MHD_USE_SUSPEND_RESUME!\n"); | 2218 | MHD_PANIC (_("Cannot resume connections without enabling MHD_USE_SUSPEND_RESUME!\n")); |
2158 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2219 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2159 | (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | 2220 | (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) |
2160 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2221 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
2161 | connection->resuming = MHD_YES; | 2222 | connection->resuming = MHD_YES; |
2162 | daemon->resuming = MHD_YES; | 2223 | daemon->resuming = MHD_YES; |
2163 | if ( (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && | 2224 | if ( (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && |
@@ -2165,12 +2226,12 @@ MHD_resume_connection (struct MHD_Connection *connection) | |||
2165 | { | 2226 | { |
2166 | #ifdef HAVE_MESSAGES | 2227 | #ifdef HAVE_MESSAGES |
2167 | MHD_DLOG (daemon, | 2228 | MHD_DLOG (daemon, |
2168 | "failed to signal resume via pipe"); | 2229 | _("Failed to signal resume via pipe.")); |
2169 | #endif | 2230 | #endif |
2170 | } | 2231 | } |
2171 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2232 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2172 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 2233 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
2173 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 2234 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
2174 | } | 2235 | } |
2175 | 2236 | ||
2176 | 2237 | ||
@@ -2190,8 +2251,8 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2190 | 2251 | ||
2191 | ret = MHD_NO; | 2252 | ret = MHD_NO; |
2192 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2253 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2193 | (!MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | 2254 | (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) |
2194 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2255 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
2195 | if (MHD_NO != daemon->resuming) | 2256 | if (MHD_NO != daemon->resuming) |
2196 | next = daemon->suspended_connections_head; | 2257 | next = daemon->suspended_connections_head; |
2197 | 2258 | ||
@@ -2246,8 +2307,8 @@ resume_suspended_connections (struct MHD_Daemon *daemon) | |||
2246 | pos->resuming = MHD_NO; | 2307 | pos->resuming = MHD_NO; |
2247 | } | 2308 | } |
2248 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2309 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2249 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 2310 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
2250 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 2311 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
2251 | return ret; | 2312 | return ret; |
2252 | } | 2313 | } |
2253 | 2314 | ||
@@ -2295,7 +2356,7 @@ MHD_add_connection (struct MHD_Daemon *daemon, | |||
2295 | { | 2356 | { |
2296 | #ifdef HAVE_MESSAGES | 2357 | #ifdef HAVE_MESSAGES |
2297 | MHD_DLOG (daemon, | 2358 | MHD_DLOG (daemon, |
2298 | "Failed to set nonblocking mode on new client socket: %s\n", | 2359 | _("Failed to set nonblocking mode on new client socket: %s\n"), |
2299 | MHD_socket_last_strerr_()); | 2360 | MHD_socket_last_strerr_()); |
2300 | #endif | 2361 | #endif |
2301 | } | 2362 | } |
@@ -2303,13 +2364,14 @@ MHD_add_connection (struct MHD_Daemon *daemon, | |||
2303 | { | 2364 | { |
2304 | #ifdef HAVE_MESSAGES | 2365 | #ifdef HAVE_MESSAGES |
2305 | MHD_DLOG (daemon, | 2366 | MHD_DLOG (daemon, |
2306 | "Failed to set noninheritable mode on new client socket.\n"); | 2367 | _("Failed to set noninheritable mode on new client socket.\n")); |
2307 | #endif | 2368 | #endif |
2308 | } | 2369 | } |
2309 | } | 2370 | } |
2310 | return internal_add_connection (daemon, | 2371 | return internal_add_connection (daemon, |
2311 | client_socket, | 2372 | client_socket, |
2312 | addr, addrlen, | 2373 | addr, |
2374 | addrlen, | ||
2313 | MHD_YES); | 2375 | MHD_YES); |
2314 | } | 2376 | } |
2315 | 2377 | ||
@@ -2340,19 +2402,29 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
2340 | MHD_socket fd; | 2402 | MHD_socket fd; |
2341 | 2403 | ||
2342 | addrlen = sizeof (addrstorage); | 2404 | addrlen = sizeof (addrstorage); |
2343 | memset (addr, 0, sizeof (addrstorage)); | 2405 | memset (addr, |
2406 | 0, | ||
2407 | sizeof (addrstorage)); | ||
2344 | if (MHD_INVALID_SOCKET == (fd = daemon->socket_fd)) | 2408 | if (MHD_INVALID_SOCKET == (fd = daemon->socket_fd)) |
2345 | return MHD_NO; | 2409 | return MHD_NO; |
2346 | #ifdef USE_ACCEPT4 | 2410 | #ifdef USE_ACCEPT4 |
2347 | s = accept4 (fd, addr, &addrlen, MAYBE_SOCK_CLOEXEC | MAYBE_SOCK_NONBLOCK); | 2411 | s = accept4 (fd, |
2412 | addr, | ||
2413 | &addrlen, | ||
2414 | MAYBE_SOCK_CLOEXEC | MAYBE_SOCK_NONBLOCK); | ||
2348 | #else /* ! USE_ACCEPT4 */ | 2415 | #else /* ! USE_ACCEPT4 */ |
2349 | s = accept (fd, addr, &addrlen); | 2416 | s = accept (fd, |
2417 | addr, | ||
2418 | &addrlen); | ||
2350 | #endif /* ! USE_ACCEPT4 */ | 2419 | #endif /* ! USE_ACCEPT4 */ |
2351 | if ((MHD_INVALID_SOCKET == s) || (addrlen <= 0)) | 2420 | if ( (MHD_INVALID_SOCKET == s) || |
2421 | (addrlen <= 0) ) | ||
2352 | { | 2422 | { |
2353 | const int err = MHD_socket_get_error_ (); | 2423 | const int err = MHD_socket_get_error_ (); |
2424 | |||
2354 | /* This could be a common occurance with multiple worker threads */ | 2425 | /* This could be a common occurance with multiple worker threads */ |
2355 | if ( (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) && | 2426 | if ( (MHD_SCKT_ERR_IS_ (err, |
2427 | MHD_SCKT_EINVAL_)) && | ||
2356 | (MHD_INVALID_SOCKET == daemon->socket_fd) ) | 2428 | (MHD_INVALID_SOCKET == daemon->socket_fd) ) |
2357 | return MHD_NO; /* can happen during shutdown */ | 2429 | return MHD_NO; /* can happen during shutdown */ |
2358 | if (MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err)) | 2430 | if (MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err)) |
@@ -2360,13 +2432,13 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
2360 | #ifdef HAVE_MESSAGES | 2432 | #ifdef HAVE_MESSAGES |
2361 | if (! MHD_SCKT_ERR_IS_EAGAIN_ (err) ) | 2433 | if (! MHD_SCKT_ERR_IS_EAGAIN_ (err) ) |
2362 | MHD_DLOG (daemon, | 2434 | MHD_DLOG (daemon, |
2363 | "Error accepting connection: %s\n", | 2435 | _("Error accepting connection: %s\n"), |
2364 | MHD_socket_strerr_(err)); | 2436 | MHD_socket_strerr_(err)); |
2365 | #endif | 2437 | #endif |
2366 | if (MHD_INVALID_SOCKET != s) | 2438 | if (MHD_INVALID_SOCKET != s) |
2367 | { | 2439 | { |
2368 | if (0 != MHD_socket_close_ (s)) | 2440 | if (0 != MHD_socket_close_ (s)) |
2369 | MHD_PANIC ("close failed\n"); | 2441 | MHD_PANIC (_("close failed\n")); |
2370 | /* just in case */ | 2442 | /* just in case */ |
2371 | } | 2443 | } |
2372 | if ( MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) | 2444 | if ( MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) |
@@ -2379,7 +2451,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
2379 | would ever be cleared. Instead trying to produce | 2451 | would ever be cleared. Instead trying to produce |
2380 | bit fat ugly warning. */ | 2452 | bit fat ugly warning. */ |
2381 | MHD_DLOG (daemon, | 2453 | MHD_DLOG (daemon, |
2382 | "Hit process or system resource limit at FIRST connection. This is really bad as there is no sane way to proceed. Will try busy waiting for system resources to become magically available.\n"); | 2454 | _("Hit process or system resource limit at FIRST connection. This is really bad as there is no sane way to proceed. Will try busy waiting for system resources to become magically available.\n")); |
2383 | #endif | 2455 | #endif |
2384 | } | 2456 | } |
2385 | else | 2457 | else |
@@ -2387,7 +2459,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
2387 | daemon->at_limit = MHD_YES; | 2459 | daemon->at_limit = MHD_YES; |
2388 | #ifdef HAVE_MESSAGES | 2460 | #ifdef HAVE_MESSAGES |
2389 | MHD_DLOG (daemon, | 2461 | MHD_DLOG (daemon, |
2390 | "Hit process or system resource limit at %u connections, temporarily suspending accept(). Consider setting a lower MHD_OPTION_CONNECTION_LIMIT.\n", | 2462 | _("Hit process or system resource limit at %u connections, temporarily suspending accept(). Consider setting a lower MHD_OPTION_CONNECTION_LIMIT.\n"), |
2391 | (unsigned int) daemon->connections); | 2463 | (unsigned int) daemon->connections); |
2392 | #endif | 2464 | #endif |
2393 | } | 2465 | } |
@@ -2399,7 +2471,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
2399 | { | 2471 | { |
2400 | #ifdef HAVE_MESSAGES | 2472 | #ifdef HAVE_MESSAGES |
2401 | MHD_DLOG (daemon, | 2473 | MHD_DLOG (daemon, |
2402 | "Failed to set nonblocking mode on incoming connection socket: %s\n", | 2474 | _("Failed to set nonblocking mode on incoming connection socket: %s\n"), |
2403 | MHD_socket_last_strerr_()); | 2475 | MHD_socket_last_strerr_()); |
2404 | #endif | 2476 | #endif |
2405 | } | 2477 | } |
@@ -2409,14 +2481,14 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
2409 | { | 2481 | { |
2410 | #ifdef HAVE_MESSAGES | 2482 | #ifdef HAVE_MESSAGES |
2411 | MHD_DLOG (daemon, | 2483 | MHD_DLOG (daemon, |
2412 | "Failed to set noninheritable mode on incoming connection socket.\n"); | 2484 | _("Failed to set noninheritable mode on incoming connection socket.\n")); |
2413 | #endif | 2485 | #endif |
2414 | } | 2486 | } |
2415 | #endif /* !USE_ACCEPT4 || !SOCK_CLOEXEC */ | 2487 | #endif /* !USE_ACCEPT4 || !SOCK_CLOEXEC */ |
2416 | #ifdef HAVE_MESSAGES | 2488 | #ifdef HAVE_MESSAGES |
2417 | #if DEBUG_CONNECT | 2489 | #if DEBUG_CONNECT |
2418 | MHD_DLOG (daemon, | 2490 | MHD_DLOG (daemon, |
2419 | "Accepted connection on socket %d\n", | 2491 | _("Accepted connection on socket %d\n"), |
2420 | s); | 2492 | s); |
2421 | #endif | 2493 | #endif |
2422 | #endif | 2494 | #endif |
@@ -2443,7 +2515,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2443 | 2515 | ||
2444 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2516 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2445 | (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | 2517 | (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) |
2446 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2518 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
2447 | while (NULL != (pos = daemon->cleanup_head)) | 2519 | while (NULL != (pos = daemon->cleanup_head)) |
2448 | { | 2520 | { |
2449 | DLL_remove (daemon->cleanup_head, | 2521 | DLL_remove (daemon->cleanup_head, |
@@ -2454,7 +2526,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2454 | { | 2526 | { |
2455 | if (! MHD_join_thread_ (pos->pid)) | 2527 | if (! MHD_join_thread_ (pos->pid)) |
2456 | { | 2528 | { |
2457 | MHD_PANIC ("Failed to join a thread\n"); | 2529 | MHD_PANIC (_("Failed to join a thread\n")); |
2458 | } | 2530 | } |
2459 | } | 2531 | } |
2460 | MHD_pool_destroy (pos->pool); | 2532 | MHD_pool_destroy (pos->pool); |
@@ -2471,7 +2543,9 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2471 | pos, | 2543 | pos, |
2472 | &pos->socket_context, | 2544 | &pos->socket_context, |
2473 | MHD_CONNECTION_NOTIFY_CLOSED); | 2545 | MHD_CONNECTION_NOTIFY_CLOSED); |
2474 | MHD_ip_limit_del (daemon, pos->addr, pos->addr_len); | 2546 | MHD_ip_limit_del (daemon, |
2547 | pos->addr, | ||
2548 | pos->addr_len); | ||
2475 | #ifdef EPOLL_SUPPORT | 2549 | #ifdef EPOLL_SUPPORT |
2476 | if (0 != (daemon->options & MHD_USE_EPOLL)) | 2550 | if (0 != (daemon->options & MHD_USE_EPOLL)) |
2477 | { | 2551 | { |
@@ -2495,7 +2569,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2495 | EPOLL_CTL_DEL, | 2569 | EPOLL_CTL_DEL, |
2496 | pos->socket_fd, | 2570 | pos->socket_fd, |
2497 | NULL)) | 2571 | NULL)) |
2498 | MHD_PANIC ("Failed to remove FD from epoll set\n"); | 2572 | MHD_PANIC (_("Failed to remove FD from epoll set\n")); |
2499 | pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; | 2573 | pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; |
2500 | } | 2574 | } |
2501 | } | 2575 | } |
@@ -2508,7 +2582,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2508 | if (MHD_INVALID_SOCKET != pos->socket_fd) | 2582 | if (MHD_INVALID_SOCKET != pos->socket_fd) |
2509 | { | 2583 | { |
2510 | if (0 != MHD_socket_close_ (pos->socket_fd)) | 2584 | if (0 != MHD_socket_close_ (pos->socket_fd)) |
2511 | MHD_PANIC ("close failed\n"); | 2585 | MHD_PANIC (_("close failed\n")); |
2512 | } | 2586 | } |
2513 | if (NULL != pos->addr) | 2587 | if (NULL != pos->addr) |
2514 | free (pos->addr); | 2588 | free (pos->addr); |
@@ -2516,7 +2590,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
2516 | } | 2590 | } |
2517 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2591 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
2518 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 2592 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
2519 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 2593 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
2520 | } | 2594 | } |
2521 | 2595 | ||
2522 | 2596 | ||
@@ -2547,7 +2621,7 @@ MHD_get_timeout (struct MHD_Daemon *daemon, | |||
2547 | { | 2621 | { |
2548 | #ifdef HAVE_MESSAGES | 2622 | #ifdef HAVE_MESSAGES |
2549 | MHD_DLOG (daemon, | 2623 | MHD_DLOG (daemon, |
2550 | "Illegal call to MHD_get_timeout\n"); | 2624 | _("Illegal call to MHD_get_timeout\n")); |
2551 | #endif | 2625 | #endif |
2552 | return MHD_NO; | 2626 | return MHD_NO; |
2553 | } | 2627 | } |
@@ -2651,7 +2725,8 @@ MHD_run_from_select (struct MHD_Daemon *daemon, | |||
2651 | /* Do it before any other processing so new signals | 2725 | /* Do it before any other processing so new signals |
2652 | will trigger select again and will be processed */ | 2726 | will trigger select again and will be processed */ |
2653 | if ((MHD_INVALID_PIPE_ != daemon->wpipe[0]) && | 2727 | if ((MHD_INVALID_PIPE_ != daemon->wpipe[0]) && |
2654 | (FD_ISSET (daemon->wpipe[0], read_fd_set))) | 2728 | (FD_ISSET (daemon->wpipe[0], |
2729 | read_fd_set))) | ||
2655 | MHD_pipe_drain_ (daemon->wpipe[0]); | 2730 | MHD_pipe_drain_ (daemon->wpipe[0]); |
2656 | 2731 | ||
2657 | /* Resuming external connections when using an extern mainloop */ | 2732 | /* Resuming external connections when using an extern mainloop */ |
@@ -2663,9 +2738,11 @@ MHD_run_from_select (struct MHD_Daemon *daemon, | |||
2663 | { | 2738 | { |
2664 | /* we're in epoll mode, the epoll FD stands for | 2739 | /* we're in epoll mode, the epoll FD stands for |
2665 | the entire event set! */ | 2740 | the entire event set! */ |
2666 | if (! MHD_SCKT_FD_FITS_FDSET_(daemon->epoll_fd, NULL)) | 2741 | if (! MHD_SCKT_FD_FITS_FDSET_(daemon->epoll_fd, |
2742 | NULL)) | ||
2667 | return MHD_NO; /* poll fd too big, fail hard */ | 2743 | return MHD_NO; /* poll fd too big, fail hard */ |
2668 | if (FD_ISSET (daemon->epoll_fd, read_fd_set)) | 2744 | if (FD_ISSET (daemon->epoll_fd, |
2745 | read_fd_set)) | ||
2669 | return MHD_run (daemon); | 2746 | return MHD_run (daemon); |
2670 | return MHD_YES; | 2747 | return MHD_YES; |
2671 | } | 2748 | } |
@@ -2673,7 +2750,8 @@ MHD_run_from_select (struct MHD_Daemon *daemon, | |||
2673 | 2750 | ||
2674 | /* select connection thread handling type */ | 2751 | /* select connection thread handling type */ |
2675 | if ( (MHD_INVALID_SOCKET != (ds = daemon->socket_fd)) && | 2752 | if ( (MHD_INVALID_SOCKET != (ds = daemon->socket_fd)) && |
2676 | (FD_ISSET (ds, read_fd_set)) ) | 2753 | (FD_ISSET (ds, |
2754 | read_fd_set)) ) | ||
2677 | (void) MHD_accept_connection (daemon); | 2755 | (void) MHD_accept_connection (daemon); |
2678 | 2756 | ||
2679 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 2757 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
@@ -2687,8 +2765,10 @@ MHD_run_from_select (struct MHD_Daemon *daemon, | |||
2687 | if (MHD_INVALID_SOCKET == ds) | 2765 | if (MHD_INVALID_SOCKET == ds) |
2688 | continue; | 2766 | continue; |
2689 | call_handlers (pos, | 2767 | call_handlers (pos, |
2690 | FD_ISSET (ds, read_fd_set), | 2768 | FD_ISSET (ds, |
2691 | FD_ISSET (ds, write_fd_set), | 2769 | read_fd_set), |
2770 | FD_ISSET (ds, | ||
2771 | write_fd_set), | ||
2692 | MHD_NO); | 2772 | MHD_NO); |
2693 | } | 2773 | } |
2694 | } | 2774 | } |
@@ -2759,7 +2839,7 @@ MHD_select (struct MHD_Daemon *daemon, | |||
2759 | { | 2839 | { |
2760 | #ifdef HAVE_MESSAGES | 2840 | #ifdef HAVE_MESSAGES |
2761 | MHD_DLOG (daemon, | 2841 | MHD_DLOG (daemon, |
2762 | "Could not obtain daemon fdsets"); | 2842 | _("Could not obtain daemon fdsets")); |
2763 | #endif | 2843 | #endif |
2764 | err_state = MHD_YES; | 2844 | err_state = MHD_YES; |
2765 | } | 2845 | } |
@@ -2775,7 +2855,7 @@ MHD_select (struct MHD_Daemon *daemon, | |||
2775 | { | 2855 | { |
2776 | #ifdef HAVE_MESSAGES | 2856 | #ifdef HAVE_MESSAGES |
2777 | MHD_DLOG (daemon, | 2857 | MHD_DLOG (daemon, |
2778 | "Could not add listen socket to fdset"); | 2858 | _("Could not add listen socket to fdset")); |
2779 | #endif | 2859 | #endif |
2780 | return MHD_NO; | 2860 | return MHD_NO; |
2781 | } | 2861 | } |
@@ -2792,7 +2872,8 @@ MHD_select (struct MHD_Daemon *daemon, | |||
2792 | from fdset and retry to add pipe FD. */ | 2872 | from fdset and retry to add pipe FD. */ |
2793 | if (MHD_INVALID_SOCKET != daemon->socket_fd) | 2873 | if (MHD_INVALID_SOCKET != daemon->socket_fd) |
2794 | { | 2874 | { |
2795 | FD_CLR (daemon->socket_fd, &rs); | 2875 | FD_CLR (daemon->socket_fd, |
2876 | &rs); | ||
2796 | if (! MHD_add_to_fd_set_ (daemon->wpipe[0], | 2877 | if (! MHD_add_to_fd_set_ (daemon->wpipe[0], |
2797 | &rs, | 2878 | &rs, |
2798 | &maxsock, | 2879 | &maxsock, |
@@ -2801,7 +2882,7 @@ MHD_select (struct MHD_Daemon *daemon, | |||
2801 | #endif /* MHD_WINSOCK_SOCKETS */ | 2882 | #endif /* MHD_WINSOCK_SOCKETS */ |
2802 | #ifdef HAVE_MESSAGES | 2883 | #ifdef HAVE_MESSAGES |
2803 | MHD_DLOG (daemon, | 2884 | MHD_DLOG (daemon, |
2804 | "Could not add control pipe FD to fdset"); | 2885 | _("Could not add control pipe FD to fdset")); |
2805 | #endif | 2886 | #endif |
2806 | err_state = MHD_YES; | 2887 | err_state = MHD_YES; |
2807 | #if defined(MHD_WINSOCK_SOCKETS) | 2888 | #if defined(MHD_WINSOCK_SOCKETS) |
@@ -2858,12 +2939,15 @@ MHD_select (struct MHD_Daemon *daemon, | |||
2858 | return (MHD_NO == err_state) ? MHD_YES : MHD_NO; | 2939 | return (MHD_NO == err_state) ? MHD_YES : MHD_NO; |
2859 | #ifdef HAVE_MESSAGES | 2940 | #ifdef HAVE_MESSAGES |
2860 | MHD_DLOG (daemon, | 2941 | MHD_DLOG (daemon, |
2861 | "select failed: %s\n", | 2942 | _("select failed: %s\n"), |
2862 | MHD_socket_strerr_ (err)); | 2943 | MHD_socket_strerr_ (err)); |
2863 | #endif | 2944 | #endif |
2864 | return MHD_NO; | 2945 | return MHD_NO; |
2865 | } | 2946 | } |
2866 | if (MHD_YES == MHD_run_from_select (daemon, &rs, &ws, &es)) | 2947 | if (MHD_YES == MHD_run_from_select (daemon, |
2948 | &rs, | ||
2949 | &ws, | ||
2950 | &es)) | ||
2867 | return (MHD_NO == err_state) ? MHD_YES : MHD_NO; | 2951 | return (MHD_NO == err_state) ? MHD_YES : MHD_NO; |
2868 | return MHD_NO; | 2952 | return MHD_NO; |
2869 | } | 2953 | } |
@@ -2915,13 +2999,15 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
2915 | if (NULL == p) | 2999 | if (NULL == p) |
2916 | { | 3000 | { |
2917 | #ifdef HAVE_MESSAGES | 3001 | #ifdef HAVE_MESSAGES |
2918 | MHD_DLOG(daemon, | 3002 | MHD_DLOG (daemon, |
2919 | "Error allocating memory: %s\n", | 3003 | _("Error allocating memory: %s\n"), |
2920 | MHD_strerror_(errno)); | 3004 | MHD_strerror_(errno)); |
2921 | #endif | 3005 | #endif |
2922 | return MHD_NO; | 3006 | return MHD_NO; |
2923 | } | 3007 | } |
2924 | memset (p, 0, sizeof (struct pollfd) * (2 + num_connections)); | 3008 | memset (p, |
3009 | 0, | ||
3010 | sizeof (struct pollfd) * (2 + num_connections)); | ||
2925 | poll_server = 0; | 3011 | poll_server = 0; |
2926 | poll_listen = -1; | 3012 | poll_listen = -1; |
2927 | if ( (MHD_INVALID_SOCKET != daemon->socket_fd) && | 3013 | if ( (MHD_INVALID_SOCKET != daemon->socket_fd) && |
@@ -2947,7 +3033,8 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
2947 | if (may_block == MHD_NO) | 3033 | if (may_block == MHD_NO) |
2948 | timeout = 0; | 3034 | timeout = 0; |
2949 | else if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || | 3035 | else if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || |
2950 | (MHD_YES != MHD_get_timeout (daemon, <imeout)) ) | 3036 | (MHD_YES != MHD_get_timeout (daemon, |
3037 | <imeout)) ) | ||
2951 | timeout = -1; | 3038 | timeout = -1; |
2952 | else | 3039 | else |
2953 | timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout; | 3040 | timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout; |
@@ -3010,7 +3097,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
3010 | } | 3097 | } |
3011 | #ifdef HAVE_MESSAGES | 3098 | #ifdef HAVE_MESSAGES |
3012 | MHD_DLOG (daemon, | 3099 | MHD_DLOG (daemon, |
3013 | "poll failed: %s\n", | 3100 | _("poll failed: %s\n"), |
3014 | MHD_socket_strerr_ (err)); | 3101 | MHD_socket_strerr_ (err)); |
3015 | #endif | 3102 | #endif |
3016 | free(p); | 3103 | free(p); |
@@ -3101,7 +3188,9 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon, | |||
3101 | unsigned int poll_count; | 3188 | unsigned int poll_count; |
3102 | int poll_listen; | 3189 | int poll_listen; |
3103 | 3190 | ||
3104 | memset (&p, 0, sizeof (p)); | 3191 | memset (&p, |
3192 | 0, | ||
3193 | sizeof (p)); | ||
3105 | poll_count = 0; | 3194 | poll_count = 0; |
3106 | poll_listen = -1; | 3195 | poll_listen = -1; |
3107 | if (MHD_INVALID_SOCKET != daemon->socket_fd) | 3196 | if (MHD_INVALID_SOCKET != daemon->socket_fd) |
@@ -3125,14 +3214,17 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon, | |||
3125 | timeout = -1; | 3214 | timeout = -1; |
3126 | if (0 == poll_count) | 3215 | if (0 == poll_count) |
3127 | return MHD_YES; | 3216 | return MHD_YES; |
3128 | if (MHD_sys_poll_(p, poll_count, timeout) < 0) | 3217 | if (MHD_sys_poll_(p, |
3218 | poll_count, | ||
3219 | timeout) < 0) | ||
3129 | { | 3220 | { |
3130 | const int err = MHD_socket_get_error_ (); | 3221 | const int err = MHD_socket_get_error_ (); |
3222 | |||
3131 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) | 3223 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) |
3132 | return MHD_YES; | 3224 | return MHD_YES; |
3133 | #ifdef HAVE_MESSAGES | 3225 | #ifdef HAVE_MESSAGES |
3134 | MHD_DLOG (daemon, | 3226 | MHD_DLOG (daemon, |
3135 | "poll failed: %s\n", | 3227 | _("poll failed: %s\n"), |
3136 | MHD_socket_strerr_ (err)); | 3228 | MHD_socket_strerr_ (err)); |
3137 | #endif | 3229 | #endif |
3138 | return MHD_NO; | 3230 | return MHD_NO; |
@@ -3163,9 +3255,10 @@ MHD_poll (struct MHD_Daemon *daemon, | |||
3163 | if (MHD_YES == daemon->shutdown) | 3255 | if (MHD_YES == daemon->shutdown) |
3164 | return MHD_NO; | 3256 | return MHD_NO; |
3165 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 3257 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
3166 | return MHD_poll_all (daemon, may_block); | 3258 | return MHD_poll_all (daemon, |
3167 | else | 3259 | may_block); |
3168 | return MHD_poll_listen_socket (daemon, may_block); | 3260 | return MHD_poll_listen_socket (daemon, |
3261 | may_block); | ||
3169 | #else | 3262 | #else |
3170 | return MHD_NO; | 3263 | return MHD_NO; |
3171 | #endif | 3264 | #endif |
@@ -3216,7 +3309,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) | |||
3216 | return MHD_YES; | 3309 | return MHD_YES; |
3217 | #ifdef HAVE_MESSAGES | 3310 | #ifdef HAVE_MESSAGES |
3218 | MHD_DLOG (daemon, | 3311 | MHD_DLOG (daemon, |
3219 | "Call to epoll_wait failed: %s\n", | 3312 | _("Call to epoll_wait failed: %s\n"), |
3220 | MHD_socket_strerr_ (err)); | 3313 | MHD_socket_strerr_ (err)); |
3221 | #endif | 3314 | #endif |
3222 | return MHD_NO; | 3315 | return MHD_NO; |
@@ -3311,7 +3404,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3311 | { | 3404 | { |
3312 | #ifdef HAVE_MESSAGES | 3405 | #ifdef HAVE_MESSAGES |
3313 | MHD_DLOG (daemon, | 3406 | MHD_DLOG (daemon, |
3314 | "Call to epoll_ctl failed: %s\n", | 3407 | _("Call to epoll_ctl failed: %s\n"), |
3315 | MHD_socket_last_strerr_ ()); | 3408 | MHD_socket_last_strerr_ ()); |
3316 | #endif | 3409 | #endif |
3317 | return MHD_NO; | 3410 | return MHD_NO; |
@@ -3331,7 +3424,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3331 | { | 3424 | { |
3332 | #ifdef HAVE_MESSAGES | 3425 | #ifdef HAVE_MESSAGES |
3333 | MHD_DLOG (daemon, | 3426 | MHD_DLOG (daemon, |
3334 | "Call to epoll_ctl failed: %s\n", | 3427 | _("Call to epoll_ctl failed: %s\n"), |
3335 | MHD_socket_last_strerr_ ()); | 3428 | MHD_socket_last_strerr_ ()); |
3336 | #endif | 3429 | #endif |
3337 | return MHD_NO; | 3430 | return MHD_NO; |
@@ -3349,7 +3442,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3349 | EPOLL_CTL_DEL, | 3442 | EPOLL_CTL_DEL, |
3350 | daemon->socket_fd, | 3443 | daemon->socket_fd, |
3351 | NULL)) | 3444 | NULL)) |
3352 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); | 3445 | MHD_PANIC (_("Failed to remove listen FD from epoll set\n")); |
3353 | daemon->listen_socket_in_epoll = MHD_NO; | 3446 | daemon->listen_socket_in_epoll = MHD_NO; |
3354 | } | 3447 | } |
3355 | if (MHD_YES == may_block) | 3448 | if (MHD_YES == may_block) |
@@ -3387,7 +3480,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3387 | return MHD_YES; | 3480 | return MHD_YES; |
3388 | #ifdef HAVE_MESSAGES | 3481 | #ifdef HAVE_MESSAGES |
3389 | MHD_DLOG (daemon, | 3482 | MHD_DLOG (daemon, |
3390 | "Call to epoll_wait failed: %s\n", | 3483 | _("Call to epoll_wait failed: %s\n"), |
3391 | MHD_socket_strerr_ (err)); | 3484 | MHD_socket_strerr_ (err)); |
3392 | #endif | 3485 | #endif |
3393 | return MHD_NO; | 3486 | return MHD_NO; |
@@ -3566,7 +3659,7 @@ MHD_run (struct MHD_Daemon *daemon) | |||
3566 | * Thread that runs the select loop until the daemon | 3659 | * Thread that runs the select loop until the daemon |
3567 | * is explicitly shut down. | 3660 | * is explicitly shut down. |
3568 | * | 3661 | * |
3569 | * @param cls 'struct MHD_Deamon' to run select loop in a thread for | 3662 | * @param cls `struct MHD_Deamon` to run select loop in a thread for |
3570 | * @return always 0 (on shutdown) | 3663 | * @return always 0 (on shutdown) |
3571 | */ | 3664 | */ |
3572 | static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ | 3665 | static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ |
@@ -3631,13 +3724,22 @@ MHD_start_daemon (unsigned int flags, | |||
3631 | uint16_t port, | 3724 | uint16_t port, |
3632 | MHD_AcceptPolicyCallback apc, | 3725 | MHD_AcceptPolicyCallback apc, |
3633 | void *apc_cls, | 3726 | void *apc_cls, |
3634 | MHD_AccessHandlerCallback dh, void *dh_cls, ...) | 3727 | MHD_AccessHandlerCallback dh, |
3728 | void *dh_cls, | ||
3729 | ...) | ||
3635 | { | 3730 | { |
3636 | struct MHD_Daemon *daemon; | 3731 | struct MHD_Daemon *daemon; |
3637 | va_list ap; | 3732 | va_list ap; |
3638 | 3733 | ||
3639 | va_start (ap, dh_cls); | 3734 | va_start (ap, |
3640 | daemon = MHD_start_daemon_va (flags, port, apc, apc_cls, dh, dh_cls, ap); | 3735 | dh_cls); |
3736 | daemon = MHD_start_daemon_va (flags, | ||
3737 | port, | ||
3738 | apc, | ||
3739 | apc_cls, | ||
3740 | dh, | ||
3741 | dh_cls, | ||
3742 | ap); | ||
3641 | va_end (ap); | 3743 | va_end (ap); |
3642 | return daemon; | 3744 | return daemon; |
3643 | } | 3745 | } |
@@ -3694,15 +3796,17 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
3694 | EPOLL_CTL_DEL, | 3796 | EPOLL_CTL_DEL, |
3695 | ret, | 3797 | ret, |
3696 | NULL)) | 3798 | NULL)) |
3697 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); | 3799 | MHD_PANIC (_("Failed to remove listen FD from epoll set\n")); |
3698 | daemon->worker_pool[i].listen_socket_in_epoll = MHD_NO; | 3800 | daemon->worker_pool[i].listen_socket_in_epoll = MHD_NO; |
3699 | } | 3801 | } |
3700 | else | 3802 | else |
3701 | #endif | 3803 | #endif |
3702 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) | 3804 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) |
3703 | { | 3805 | { |
3704 | if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe[1], "q", 1)) | 3806 | if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe[1], |
3705 | MHD_PANIC ("failed to signal quiesce via pipe"); | 3807 | "q", |
3808 | 1)) | ||
3809 | MHD_PANIC (_("Failed to signal quiesce via pipe")); | ||
3706 | } | 3810 | } |
3707 | } | 3811 | } |
3708 | daemon->socket_fd = MHD_INVALID_SOCKET; | 3812 | daemon->socket_fd = MHD_INVALID_SOCKET; |
@@ -3722,8 +3826,10 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
3722 | #endif | 3826 | #endif |
3723 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) | 3827 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) |
3724 | { | 3828 | { |
3725 | if (1 != MHD_pipe_write_ (daemon->wpipe[1], "q", 1)) | 3829 | if (1 != MHD_pipe_write_ (daemon->wpipe[1], |
3726 | MHD_PANIC ("failed to signal quiesce via pipe"); | 3830 | "q", |
3831 | 1)) | ||
3832 | MHD_PANIC (_("failed to signal quiesce via pipe")); | ||
3727 | } | 3833 | } |
3728 | 3834 | ||
3729 | return ret; | 3835 | return ret; |
@@ -3774,7 +3880,9 @@ parse_options (struct MHD_Daemon *daemon, | |||
3774 | int ret; | 3880 | int ret; |
3775 | 3881 | ||
3776 | va_start (ap, servaddr); | 3882 | va_start (ap, servaddr); |
3777 | ret = parse_options_va (daemon, servaddr, ap); | 3883 | ret = parse_options_va (daemon, |
3884 | servaddr, | ||
3885 | ap); | ||
3778 | va_end (ap); | 3886 | va_end (ap); |
3779 | return ret; | 3887 | return ret; |
3780 | } | 3888 | } |
@@ -3806,45 +3914,55 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
3806 | switch (opt) | 3914 | switch (opt) |
3807 | { | 3915 | { |
3808 | case MHD_OPTION_CONNECTION_MEMORY_LIMIT: | 3916 | case MHD_OPTION_CONNECTION_MEMORY_LIMIT: |
3809 | daemon->pool_size = va_arg (ap, size_t); | 3917 | daemon->pool_size = va_arg (ap, |
3918 | size_t); | ||
3810 | break; | 3919 | break; |
3811 | case MHD_OPTION_CONNECTION_MEMORY_INCREMENT: | 3920 | case MHD_OPTION_CONNECTION_MEMORY_INCREMENT: |
3812 | daemon->pool_increment= va_arg (ap, size_t); | 3921 | daemon->pool_increment= va_arg (ap, |
3922 | size_t); | ||
3813 | break; | 3923 | break; |
3814 | case MHD_OPTION_CONNECTION_LIMIT: | 3924 | case MHD_OPTION_CONNECTION_LIMIT: |
3815 | daemon->connection_limit = va_arg (ap, unsigned int); | 3925 | daemon->connection_limit = va_arg (ap, |
3926 | unsigned int); | ||
3816 | break; | 3927 | break; |
3817 | case MHD_OPTION_CONNECTION_TIMEOUT: | 3928 | case MHD_OPTION_CONNECTION_TIMEOUT: |
3818 | daemon->connection_timeout = va_arg (ap, unsigned int); | 3929 | daemon->connection_timeout = va_arg (ap, |
3930 | unsigned int); | ||
3819 | break; | 3931 | break; |
3820 | case MHD_OPTION_NOTIFY_COMPLETED: | 3932 | case MHD_OPTION_NOTIFY_COMPLETED: |
3821 | daemon->notify_completed = | 3933 | daemon->notify_completed = va_arg (ap, |
3822 | va_arg (ap, MHD_RequestCompletedCallback); | 3934 | MHD_RequestCompletedCallback); |
3823 | daemon->notify_completed_cls = va_arg (ap, void *); | 3935 | daemon->notify_completed_cls = va_arg (ap, |
3936 | void *); | ||
3824 | break; | 3937 | break; |
3825 | case MHD_OPTION_NOTIFY_CONNECTION: | 3938 | case MHD_OPTION_NOTIFY_CONNECTION: |
3826 | daemon->notify_connection = | 3939 | daemon->notify_connection = va_arg (ap, |
3827 | va_arg (ap, MHD_NotifyConnectionCallback); | 3940 | MHD_NotifyConnectionCallback); |
3828 | daemon->notify_connection_cls = va_arg (ap, void *); | 3941 | daemon->notify_connection_cls = va_arg (ap, |
3942 | void *); | ||
3829 | break; | 3943 | break; |
3830 | case MHD_OPTION_PER_IP_CONNECTION_LIMIT: | 3944 | case MHD_OPTION_PER_IP_CONNECTION_LIMIT: |
3831 | daemon->per_ip_connection_limit = va_arg (ap, unsigned int); | 3945 | daemon->per_ip_connection_limit = va_arg (ap, |
3946 | unsigned int); | ||
3832 | break; | 3947 | break; |
3833 | case MHD_OPTION_SOCK_ADDR: | 3948 | case MHD_OPTION_SOCK_ADDR: |
3834 | *servaddr = va_arg (ap, const struct sockaddr *); | 3949 | *servaddr = va_arg (ap, |
3950 | const struct sockaddr *); | ||
3835 | break; | 3951 | break; |
3836 | case MHD_OPTION_URI_LOG_CALLBACK: | 3952 | case MHD_OPTION_URI_LOG_CALLBACK: |
3837 | daemon->uri_log_callback = | 3953 | daemon->uri_log_callback = va_arg (ap, |
3838 | va_arg (ap, LogCallback); | 3954 | LogCallback); |
3839 | daemon->uri_log_callback_cls = va_arg (ap, void *); | 3955 | daemon->uri_log_callback_cls = va_arg (ap, |
3956 | void *); | ||
3840 | break; | 3957 | break; |
3841 | case MHD_OPTION_THREAD_POOL_SIZE: | 3958 | case MHD_OPTION_THREAD_POOL_SIZE: |
3842 | daemon->worker_pool_size = va_arg (ap, unsigned int); | 3959 | daemon->worker_pool_size = va_arg (ap, |
3960 | unsigned int); | ||
3843 | if (daemon->worker_pool_size >= (SIZE_MAX / sizeof (struct MHD_Daemon))) | 3961 | if (daemon->worker_pool_size >= (SIZE_MAX / sizeof (struct MHD_Daemon))) |
3844 | { | 3962 | { |
3845 | #ifdef HAVE_MESSAGES | 3963 | #ifdef HAVE_MESSAGES |
3846 | MHD_DLOG (daemon, | 3964 | MHD_DLOG (daemon, |
3847 | "Specified thread pool size (%u) too big\n", | 3965 | _("Specified thread pool size (%u) too big\n"), |
3848 | daemon->worker_pool_size); | 3966 | daemon->worker_pool_size); |
3849 | #endif | 3967 | #endif |
3850 | return MHD_NO; | 3968 | return MHD_NO; |
@@ -3853,69 +3971,76 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
3853 | #if HTTPS_SUPPORT | 3971 | #if HTTPS_SUPPORT |
3854 | case MHD_OPTION_HTTPS_MEM_KEY: | 3972 | case MHD_OPTION_HTTPS_MEM_KEY: |
3855 | if (0 != (daemon->options & MHD_USE_SSL)) | 3973 | if (0 != (daemon->options & MHD_USE_SSL)) |
3856 | daemon->https_mem_key = va_arg (ap, const char *); | 3974 | daemon->https_mem_key = va_arg (ap, |
3975 | const char *); | ||
3857 | #ifdef HAVE_MESSAGES | 3976 | #ifdef HAVE_MESSAGES |
3858 | else | 3977 | else |
3859 | MHD_DLOG (daemon, | 3978 | MHD_DLOG (daemon, |
3860 | "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", | 3979 | _("MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n"), |
3861 | opt); | 3980 | opt); |
3862 | #endif | 3981 | #endif |
3863 | break; | 3982 | break; |
3864 | case MHD_OPTION_HTTPS_KEY_PASSWORD: | 3983 | case MHD_OPTION_HTTPS_KEY_PASSWORD: |
3865 | if (0 != (daemon->options & MHD_USE_SSL)) | 3984 | if (0 != (daemon->options & MHD_USE_SSL)) |
3866 | daemon->https_key_password = va_arg (ap, const char *); | 3985 | daemon->https_key_password = va_arg (ap, |
3986 | const char *); | ||
3867 | #ifdef HAVE_MESSAGES | 3987 | #ifdef HAVE_MESSAGES |
3868 | else | 3988 | else |
3869 | MHD_DLOG (daemon, | 3989 | MHD_DLOG (daemon, |
3870 | "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", | 3990 | _("MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n"), |
3871 | opt); | 3991 | opt); |
3872 | #endif | 3992 | #endif |
3873 | break; | 3993 | break; |
3874 | case MHD_OPTION_HTTPS_MEM_CERT: | 3994 | case MHD_OPTION_HTTPS_MEM_CERT: |
3875 | if (0 != (daemon->options & MHD_USE_SSL)) | 3995 | if (0 != (daemon->options & MHD_USE_SSL)) |
3876 | daemon->https_mem_cert = va_arg (ap, const char *); | 3996 | daemon->https_mem_cert = va_arg (ap, |
3997 | const char *); | ||
3877 | #ifdef HAVE_MESSAGES | 3998 | #ifdef HAVE_MESSAGES |
3878 | else | 3999 | else |
3879 | MHD_DLOG (daemon, | 4000 | MHD_DLOG (daemon, |
3880 | "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", | 4001 | _("MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n"), |
3881 | opt); | 4002 | opt); |
3882 | #endif | 4003 | #endif |
3883 | break; | 4004 | break; |
3884 | case MHD_OPTION_HTTPS_MEM_TRUST: | 4005 | case MHD_OPTION_HTTPS_MEM_TRUST: |
3885 | if (0 != (daemon->options & MHD_USE_SSL)) | 4006 | if (0 != (daemon->options & MHD_USE_SSL)) |
3886 | daemon->https_mem_trust = va_arg (ap, const char *); | 4007 | daemon->https_mem_trust = va_arg (ap, |
4008 | const char *); | ||
3887 | #ifdef HAVE_MESSAGES | 4009 | #ifdef HAVE_MESSAGES |
3888 | else | 4010 | else |
3889 | MHD_DLOG (daemon, | 4011 | MHD_DLOG (daemon, |
3890 | "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", | 4012 | _("MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n"), |
3891 | opt); | 4013 | opt); |
3892 | #endif | 4014 | #endif |
3893 | break; | 4015 | break; |
3894 | case MHD_OPTION_HTTPS_CRED_TYPE: | 4016 | case MHD_OPTION_HTTPS_CRED_TYPE: |
3895 | daemon->cred_type = (gnutls_credentials_type_t) va_arg (ap, int); | 4017 | daemon->cred_type = (gnutls_credentials_type_t) va_arg (ap, |
4018 | int); | ||
3896 | break; | 4019 | break; |
3897 | case MHD_OPTION_HTTPS_MEM_DHPARAMS: | 4020 | case MHD_OPTION_HTTPS_MEM_DHPARAMS: |
3898 | if (0 != (daemon->options & MHD_USE_SSL)) | 4021 | if (0 != (daemon->options & MHD_USE_SSL)) |
3899 | { | 4022 | { |
3900 | const char *arg = va_arg (ap, const char *); | 4023 | const char *arg = va_arg (ap, |
4024 | const char *); | ||
3901 | gnutls_datum_t dhpar; | 4025 | gnutls_datum_t dhpar; |
3902 | 4026 | ||
3903 | if (gnutls_dh_params_init (&daemon->https_mem_dhparams) < 0) | 4027 | if (gnutls_dh_params_init (&daemon->https_mem_dhparams) < 0) |
3904 | { | 4028 | { |
3905 | #ifdef HAVE_MESSAGES | 4029 | #ifdef HAVE_MESSAGES |
3906 | MHD_DLOG (daemon, | 4030 | MHD_DLOG (daemon, |
3907 | "Error initializing DH parameters\n"); | 4031 | _("Error initializing DH parameters\n")); |
3908 | #endif | 4032 | #endif |
3909 | return MHD_NO; | 4033 | return MHD_NO; |
3910 | } | 4034 | } |
3911 | dhpar.data = (unsigned char *) arg; | 4035 | dhpar.data = (unsigned char *) arg; |
3912 | dhpar.size = strlen (arg); | 4036 | dhpar.size = strlen (arg); |
3913 | if (gnutls_dh_params_import_pkcs3 (daemon->https_mem_dhparams, &dhpar, | 4037 | if (gnutls_dh_params_import_pkcs3 (daemon->https_mem_dhparams, |
4038 | &dhpar, | ||
3914 | GNUTLS_X509_FMT_PEM) < 0) | 4039 | GNUTLS_X509_FMT_PEM) < 0) |
3915 | { | 4040 | { |
3916 | #ifdef HAVE_MESSAGES | 4041 | #ifdef HAVE_MESSAGES |
3917 | MHD_DLOG (daemon, | 4042 | MHD_DLOG (daemon, |
3918 | "Bad Diffie-Hellman parameters format\n"); | 4043 | _("Bad Diffie-Hellman parameters format\n")); |
3919 | #endif | 4044 | #endif |
3920 | gnutls_dh_params_deinit (daemon->https_mem_dhparams); | 4045 | gnutls_dh_params_deinit (daemon->https_mem_dhparams); |
3921 | return MHD_NO; | 4046 | return MHD_NO; |
@@ -3926,7 +4051,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
3926 | { | 4051 | { |
3927 | #ifdef HAVE_MESSAGES | 4052 | #ifdef HAVE_MESSAGES |
3928 | MHD_DLOG (daemon, | 4053 | MHD_DLOG (daemon, |
3929 | "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", | 4054 | _("MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n"), |
3930 | opt); | 4055 | opt); |
3931 | #endif | 4056 | #endif |
3932 | return MHD_NO; | 4057 | return MHD_NO; |
@@ -3943,7 +4068,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
3943 | { | 4068 | { |
3944 | #ifdef HAVE_MESSAGES | 4069 | #ifdef HAVE_MESSAGES |
3945 | MHD_DLOG (daemon, | 4070 | MHD_DLOG (daemon, |
3946 | "Setting priorities to `%s' failed: %s\n", | 4071 | _("Setting priorities to `%s' failed: %s\n"), |
3947 | pstr, | 4072 | pstr, |
3948 | gnutls_strerror (ret)); | 4073 | gnutls_strerror (ret)); |
3949 | #endif | 4074 | #endif |
@@ -3956,50 +4081,62 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
3956 | #if GNUTLS_VERSION_MAJOR < 3 | 4081 | #if GNUTLS_VERSION_MAJOR < 3 |
3957 | #ifdef HAVE_MESSAGES | 4082 | #ifdef HAVE_MESSAGES |
3958 | MHD_DLOG (daemon, | 4083 | MHD_DLOG (daemon, |
3959 | "MHD_OPTION_HTTPS_CERT_CALLBACK requires building MHD with GnuTLS >= 3.0\n"); | 4084 | _("MHD_OPTION_HTTPS_CERT_CALLBACK requires building MHD with GnuTLS >= 3.0\n")); |
3960 | #endif | 4085 | #endif |
3961 | return MHD_NO; | 4086 | return MHD_NO; |
3962 | #else | 4087 | #else |
3963 | if (0 != (daemon->options & MHD_USE_SSL)) | 4088 | if (0 != (daemon->options & MHD_USE_SSL)) |
3964 | daemon->cert_callback = va_arg (ap, gnutls_certificate_retrieve_function2 *); | 4089 | daemon->cert_callback = va_arg (ap, |
4090 | gnutls_certificate_retrieve_function2 *); | ||
3965 | break; | 4091 | break; |
3966 | #endif | 4092 | #endif |
3967 | #endif | 4093 | #endif |
3968 | #ifdef DAUTH_SUPPORT | 4094 | #ifdef DAUTH_SUPPORT |
3969 | case MHD_OPTION_DIGEST_AUTH_RANDOM: | 4095 | case MHD_OPTION_DIGEST_AUTH_RANDOM: |
3970 | daemon->digest_auth_rand_size = va_arg (ap, size_t); | 4096 | daemon->digest_auth_rand_size = va_arg (ap, |
3971 | daemon->digest_auth_random = va_arg (ap, const char *); | 4097 | size_t); |
4098 | daemon->digest_auth_random = va_arg (ap, | ||
4099 | const char *); | ||
3972 | break; | 4100 | break; |
3973 | case MHD_OPTION_NONCE_NC_SIZE: | 4101 | case MHD_OPTION_NONCE_NC_SIZE: |
3974 | daemon->nonce_nc_size = va_arg (ap, unsigned int); | 4102 | daemon->nonce_nc_size = va_arg (ap, |
4103 | unsigned int); | ||
3975 | break; | 4104 | break; |
3976 | #endif | 4105 | #endif |
3977 | case MHD_OPTION_LISTEN_SOCKET: | 4106 | case MHD_OPTION_LISTEN_SOCKET: |
3978 | daemon->socket_fd = va_arg (ap, MHD_socket); | 4107 | daemon->socket_fd = va_arg (ap, |
4108 | MHD_socket); | ||
3979 | break; | 4109 | break; |
3980 | case MHD_OPTION_EXTERNAL_LOGGER: | 4110 | case MHD_OPTION_EXTERNAL_LOGGER: |
3981 | #ifdef HAVE_MESSAGES | 4111 | #ifdef HAVE_MESSAGES |
3982 | daemon->custom_error_log = | 4112 | daemon->custom_error_log = va_arg (ap, |
3983 | va_arg (ap, VfprintfFunctionPointerType); | 4113 | VfprintfFunctionPointerType); |
3984 | daemon->custom_error_log_cls = va_arg (ap, void *); | 4114 | daemon->custom_error_log_cls = va_arg (ap, |
4115 | void *); | ||
3985 | #else | 4116 | #else |
3986 | va_arg (ap, VfprintfFunctionPointerType); | 4117 | va_arg (ap, |
3987 | va_arg (ap, void *); | 4118 | VfprintfFunctionPointerType); |
4119 | va_arg (ap, | ||
4120 | void *); | ||
3988 | #endif | 4121 | #endif |
3989 | break; | 4122 | break; |
3990 | case MHD_OPTION_THREAD_STACK_SIZE: | 4123 | case MHD_OPTION_THREAD_STACK_SIZE: |
3991 | daemon->thread_stack_size = va_arg (ap, size_t); | 4124 | daemon->thread_stack_size = va_arg (ap, |
4125 | size_t); | ||
3992 | break; | 4126 | break; |
3993 | #ifdef TCP_FASTOPEN | 4127 | #ifdef TCP_FASTOPEN |
3994 | case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE: | 4128 | case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE: |
3995 | daemon->fastopen_queue_size = va_arg (ap, unsigned int); | 4129 | daemon->fastopen_queue_size = va_arg (ap, |
4130 | unsigned int); | ||
3996 | break; | 4131 | break; |
3997 | #endif | 4132 | #endif |
3998 | case MHD_OPTION_LISTENING_ADDRESS_REUSE: | 4133 | case MHD_OPTION_LISTENING_ADDRESS_REUSE: |
3999 | daemon->listening_address_reuse = va_arg (ap, unsigned int) ? 1 : -1; | 4134 | daemon->listening_address_reuse = va_arg (ap, |
4135 | unsigned int) ? 1 : -1; | ||
4000 | break; | 4136 | break; |
4001 | case MHD_OPTION_LISTEN_BACKLOG_SIZE: | 4137 | case MHD_OPTION_LISTEN_BACKLOG_SIZE: |
4002 | daemon->listen_backlog_size = va_arg (ap, unsigned int); | 4138 | daemon->listen_backlog_size = va_arg (ap, |
4139 | unsigned int); | ||
4003 | break; | 4140 | break; |
4004 | case MHD_OPTION_ARRAY: | 4141 | case MHD_OPTION_ARRAY: |
4005 | oa = va_arg (ap, struct MHD_OptionItem*); | 4142 | oa = va_arg (ap, struct MHD_OptionItem*); |
@@ -4101,23 +4238,25 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
4101 | } | 4238 | } |
4102 | break; | 4239 | break; |
4103 | case MHD_OPTION_UNESCAPE_CALLBACK: | 4240 | case MHD_OPTION_UNESCAPE_CALLBACK: |
4104 | daemon->unescape_callback = | 4241 | daemon->unescape_callback = va_arg (ap, |
4105 | va_arg (ap, UnescapeCallback); | 4242 | UnescapeCallback); |
4106 | daemon->unescape_callback_cls = va_arg (ap, void *); | 4243 | daemon->unescape_callback_cls = va_arg (ap, |
4244 | void *); | ||
4107 | break; | 4245 | break; |
4108 | default: | 4246 | default: |
4109 | #ifdef HAVE_MESSAGES | 4247 | #ifdef HAVE_MESSAGES |
4110 | if (((opt >= MHD_OPTION_HTTPS_MEM_KEY) && | 4248 | if ( ( (opt >= MHD_OPTION_HTTPS_MEM_KEY) && |
4111 | (opt <= MHD_OPTION_HTTPS_PRIORITIES)) || (opt == MHD_OPTION_HTTPS_MEM_TRUST)) | 4249 | (opt <= MHD_OPTION_HTTPS_PRIORITIES) ) || |
4250 | (opt == MHD_OPTION_HTTPS_MEM_TRUST)) | ||
4112 | { | 4251 | { |
4113 | MHD_DLOG (daemon, | 4252 | MHD_DLOG (daemon, |
4114 | "MHD HTTPS option %d passed to MHD compiled without HTTPS support\n", | 4253 | _("MHD HTTPS option %d passed to MHD compiled without HTTPS support\n"), |
4115 | opt); | 4254 | opt); |
4116 | } | 4255 | } |
4117 | else | 4256 | else |
4118 | { | 4257 | { |
4119 | MHD_DLOG (daemon, | 4258 | MHD_DLOG (daemon, |
4120 | "Invalid option %d! (Did you terminate the list with MHD_OPTION_END?)\n", | 4259 | _("Invalid option %d! (Did you terminate the list with MHD_OPTION_END?)\n"), |
4121 | opt); | 4260 | opt); |
4122 | } | 4261 | } |
4123 | #endif | 4262 | #endif |
@@ -4143,7 +4282,7 @@ setup_epoll_fd (struct MHD_Daemon *daemon) | |||
4143 | { | 4282 | { |
4144 | #ifdef HAVE_MESSAGES | 4283 | #ifdef HAVE_MESSAGES |
4145 | MHD_DLOG (daemon, | 4284 | MHD_DLOG (daemon, |
4146 | "Call to epoll_create1 failed: %s\n", | 4285 | _("Call to epoll_create1 failed: %s\n"), |
4147 | MHD_socket_last_strerr_ ()); | 4286 | MHD_socket_last_strerr_ ()); |
4148 | #endif | 4287 | #endif |
4149 | return MHD_INVALID_SOCKET; | 4288 | return MHD_INVALID_SOCKET; |
@@ -4153,7 +4292,7 @@ setup_epoll_fd (struct MHD_Daemon *daemon) | |||
4153 | { | 4292 | { |
4154 | #ifdef HAVE_MESSAGES | 4293 | #ifdef HAVE_MESSAGES |
4155 | MHD_DLOG (daemon, | 4294 | MHD_DLOG (daemon, |
4156 | "Failed to set noninheritable mode on epoll FD.\n"); | 4295 | _("Failed to set noninheritable mode on epoll FD.\n")); |
4157 | #endif | 4296 | #endif |
4158 | } | 4297 | } |
4159 | #endif /* ! USE_EPOLL_CREATE1 */ | 4298 | #endif /* ! USE_EPOLL_CREATE1 */ |
@@ -4195,7 +4334,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) | |||
4195 | { | 4334 | { |
4196 | #ifdef HAVE_MESSAGES | 4335 | #ifdef HAVE_MESSAGES |
4197 | MHD_DLOG (daemon, | 4336 | MHD_DLOG (daemon, |
4198 | "Call to epoll_ctl failed: %s\n", | 4337 | _("Call to epoll_ctl failed: %s\n"), |
4199 | MHD_socket_last_strerr_ ()); | 4338 | MHD_socket_last_strerr_ ()); |
4200 | #endif | 4339 | #endif |
4201 | return MHD_NO; | 4340 | return MHD_NO; |
@@ -4213,7 +4352,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) | |||
4213 | { | 4352 | { |
4214 | #ifdef HAVE_MESSAGES | 4353 | #ifdef HAVE_MESSAGES |
4215 | MHD_DLOG (daemon, | 4354 | MHD_DLOG (daemon, |
4216 | "Call to epoll_ctl failed: %s\n", | 4355 | _("Call to epoll_ctl failed: %s\n"), |
4217 | MHD_socket_last_strerr_ ()); | 4356 | MHD_socket_last_strerr_ ()); |
4218 | #endif | 4357 | #endif |
4219 | return MHD_NO; | 4358 | return MHD_NO; |
@@ -4247,7 +4386,8 @@ MHD_start_daemon_va (unsigned int flags, | |||
4247 | uint16_t port, | 4386 | uint16_t port, |
4248 | MHD_AcceptPolicyCallback apc, | 4387 | MHD_AcceptPolicyCallback apc, |
4249 | void *apc_cls, | 4388 | void *apc_cls, |
4250 | MHD_AccessHandlerCallback dh, void *dh_cls, | 4389 | MHD_AccessHandlerCallback dh, |
4390 | void *dh_cls, | ||
4251 | va_list ap) | 4391 | va_list ap) |
4252 | { | 4392 | { |
4253 | const MHD_SCKT_OPT_BOOL_ on = 1; | 4393 | const MHD_SCKT_OPT_BOOL_ on = 1; |
@@ -4282,7 +4422,9 @@ MHD_start_daemon_va (unsigned int flags, | |||
4282 | return NULL; | 4422 | return NULL; |
4283 | if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon)))) | 4423 | if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon)))) |
4284 | return NULL; | 4424 | return NULL; |
4285 | memset (daemon, 0, sizeof (struct MHD_Daemon)); | 4425 | memset (daemon, |
4426 | 0, | ||
4427 | sizeof (struct MHD_Daemon)); | ||
4286 | #ifdef EPOLL_SUPPORT | 4428 | #ifdef EPOLL_SUPPORT |
4287 | daemon->epoll_fd = -1; | 4429 | daemon->epoll_fd = -1; |
4288 | #if HTTPS_SUPPORT | 4430 | #if HTTPS_SUPPORT |
@@ -4332,11 +4474,11 @@ MHD_start_daemon_va (unsigned int flags, | |||
4332 | use_pipe = 0; /* useless if we are using 'external' select */ | 4474 | use_pipe = 0; /* useless if we are using 'external' select */ |
4333 | if (use_pipe) | 4475 | if (use_pipe) |
4334 | { | 4476 | { |
4335 | if (!MHD_pipe_ (daemon->wpipe)) | 4477 | if (! MHD_pipe_ (daemon->wpipe)) |
4336 | { | 4478 | { |
4337 | #ifdef HAVE_MESSAGES | 4479 | #ifdef HAVE_MESSAGES |
4338 | MHD_DLOG (daemon, | 4480 | MHD_DLOG (daemon, |
4339 | "Failed to create control pipe: %s\n", | 4481 | _("Failed to create control pipe: %s\n"), |
4340 | MHD_pipe_last_strerror_ ()); | 4482 | MHD_pipe_last_strerror_ ()); |
4341 | #endif | 4483 | #endif |
4342 | free (daemon); | 4484 | free (daemon); |
@@ -4346,13 +4488,13 @@ MHD_start_daemon_va (unsigned int flags, | |||
4346 | { | 4488 | { |
4347 | #ifdef HAVE_MESSAGES | 4489 | #ifdef HAVE_MESSAGES |
4348 | MHD_DLOG (daemon, | 4490 | MHD_DLOG (daemon, |
4349 | "Failed to make read side of inter-thread control channel non-blocking: %s\n", | 4491 | _("Failed to make read side of inter-thread control channel non-blocking: %s\n"), |
4350 | MHD_pipe_last_strerror_ ()); | 4492 | MHD_pipe_last_strerror_ ()); |
4351 | #endif | 4493 | #endif |
4352 | if (0 != MHD_pipe_close_ (daemon->wpipe[0])) | 4494 | if (0 != MHD_pipe_close_ (daemon->wpipe[0])) |
4353 | MHD_PANIC ("close failed\n"); | 4495 | MHD_PANIC (_("close failed\n")); |
4354 | if (0 != MHD_pipe_close_ (daemon->wpipe[1])) | 4496 | if (0 != MHD_pipe_close_ (daemon->wpipe[1])) |
4355 | MHD_PANIC ("close failed\n"); | 4497 | MHD_PANIC (_("close failed\n")); |
4356 | free (daemon); | 4498 | free (daemon); |
4357 | return NULL; | 4499 | return NULL; |
4358 | } | 4500 | } |
@@ -4360,23 +4502,24 @@ MHD_start_daemon_va (unsigned int flags, | |||
4360 | { | 4502 | { |
4361 | #ifdef HAVE_MESSAGES | 4503 | #ifdef HAVE_MESSAGES |
4362 | MHD_DLOG (daemon, | 4504 | MHD_DLOG (daemon, |
4363 | "Failed to make write side of inter-thread control channel non-blocking: %s\n", | 4505 | _("Failed to make write side of inter-thread control channel non-blocking: %s\n"), |
4364 | MHD_pipe_last_strerror_ ()); | 4506 | MHD_pipe_last_strerror_ ()); |
4365 | #endif | 4507 | #endif |
4366 | } | 4508 | } |
4367 | } | 4509 | } |
4368 | if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) && | 4510 | if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) && |
4369 | (1 == use_pipe) && | 4511 | (1 == use_pipe) && |
4370 | (! MHD_SCKT_FD_FITS_FDSET_(daemon->wpipe[0], NULL)) ) | 4512 | (! MHD_SCKT_FD_FITS_FDSET_(daemon->wpipe[0], |
4513 | NULL)) ) | ||
4371 | { | 4514 | { |
4372 | #ifdef HAVE_MESSAGES | 4515 | #ifdef HAVE_MESSAGES |
4373 | MHD_DLOG (daemon, | 4516 | MHD_DLOG (daemon, |
4374 | "file descriptor for control pipe exceeds maximum value\n"); | 4517 | _("file descriptor for control pipe exceeds maximum value\n")); |
4375 | #endif | 4518 | #endif |
4376 | if (0 != MHD_pipe_close_ (daemon->wpipe[0])) | 4519 | if (0 != MHD_pipe_close_ (daemon->wpipe[0])) |
4377 | MHD_PANIC ("close failed\n"); | 4520 | MHD_PANIC (_("close failed\n")); |
4378 | if (0 != MHD_pipe_close_ (daemon->wpipe[1])) | 4521 | if (0 != MHD_pipe_close_ (daemon->wpipe[1])) |
4379 | MHD_PANIC ("close failed\n"); | 4522 | MHD_PANIC (_("close failed\n")); |
4380 | free (daemon); | 4523 | free (daemon); |
4381 | return NULL; | 4524 | return NULL; |
4382 | } | 4525 | } |
@@ -4393,7 +4536,9 @@ MHD_start_daemon_va (unsigned int flags, | |||
4393 | #endif | 4536 | #endif |
4394 | 4537 | ||
4395 | 4538 | ||
4396 | if (MHD_YES != parse_options_va (daemon, &servaddr, ap)) | 4539 | if (MHD_YES != parse_options_va (daemon, |
4540 | &servaddr, | ||
4541 | ap)) | ||
4397 | { | 4542 | { |
4398 | #if HTTPS_SUPPORT | 4543 | #if HTTPS_SUPPORT |
4399 | if ( (0 != (flags & MHD_USE_SSL)) && | 4544 | if ( (0 != (flags & MHD_USE_SSL)) && |
@@ -4411,7 +4556,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4411 | { | 4556 | { |
4412 | #ifdef HAVE_MESSAGES | 4557 | #ifdef HAVE_MESSAGES |
4413 | MHD_DLOG (daemon, | 4558 | MHD_DLOG (daemon, |
4414 | "Specified value for NC_SIZE too large\n"); | 4559 | _("Specified value for NC_SIZE too large\n")); |
4415 | #endif | 4560 | #endif |
4416 | #if HTTPS_SUPPORT | 4561 | #if HTTPS_SUPPORT |
4417 | if (0 != (flags & MHD_USE_SSL)) | 4562 | if (0 != (flags & MHD_USE_SSL)) |
@@ -4425,7 +4570,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4425 | { | 4570 | { |
4426 | #ifdef HAVE_MESSAGES | 4571 | #ifdef HAVE_MESSAGES |
4427 | MHD_DLOG (daemon, | 4572 | MHD_DLOG (daemon, |
4428 | "Failed to allocate memory for nonce-nc map: %s\n", | 4573 | _("Failed to allocate memory for nonce-nc map: %s\n"), |
4429 | MHD_strerror_ (errno)); | 4574 | MHD_strerror_ (errno)); |
4430 | #endif | 4575 | #endif |
4431 | #if HTTPS_SUPPORT | 4576 | #if HTTPS_SUPPORT |
@@ -4437,11 +4582,11 @@ MHD_start_daemon_va (unsigned int flags, | |||
4437 | } | 4582 | } |
4438 | } | 4583 | } |
4439 | 4584 | ||
4440 | if (!MHD_mutex_init_ (&daemon->nnc_lock)) | 4585 | if (! MHD_mutex_init_ (&daemon->nnc_lock)) |
4441 | { | 4586 | { |
4442 | #ifdef HAVE_MESSAGES | 4587 | #ifdef HAVE_MESSAGES |
4443 | MHD_DLOG (daemon, | 4588 | MHD_DLOG (daemon, |
4444 | "MHD failed to initialize nonce-nc mutex\n"); | 4589 | _("MHD failed to initialize nonce-nc mutex\n")); |
4445 | #endif | 4590 | #endif |
4446 | #if HTTPS_SUPPORT | 4591 | #if HTTPS_SUPPORT |
4447 | if (0 != (flags & MHD_USE_SSL)) | 4592 | if (0 != (flags & MHD_USE_SSL)) |
@@ -4459,7 +4604,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4459 | { | 4604 | { |
4460 | #ifdef HAVE_MESSAGES | 4605 | #ifdef HAVE_MESSAGES |
4461 | MHD_DLOG (daemon, | 4606 | MHD_DLOG (daemon, |
4462 | "MHD thread pooling only works with MHD_USE_SELECT_INTERNALLY\n"); | 4607 | _("MHD thread pooling only works with MHD_USE_SELECT_INTERNALLY\n")); |
4463 | #endif | 4608 | #endif |
4464 | goto free_and_fail; | 4609 | goto free_and_fail; |
4465 | } | 4610 | } |
@@ -4469,7 +4614,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4469 | { | 4614 | { |
4470 | #ifdef HAVE_MESSAGES | 4615 | #ifdef HAVE_MESSAGES |
4471 | MHD_DLOG (daemon, | 4616 | MHD_DLOG (daemon, |
4472 | "Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_SUSPEND_RESUME is not supported.\n"); | 4617 | _("Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_SUSPEND_RESUME is not supported.\n")); |
4473 | #endif | 4618 | #endif |
4474 | goto free_and_fail; | 4619 | goto free_and_fail; |
4475 | } | 4620 | } |
@@ -4479,7 +4624,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4479 | { | 4624 | { |
4480 | #ifdef HAVE_MESSAGES | 4625 | #ifdef HAVE_MESSAGES |
4481 | MHD_DLOG (daemon, | 4626 | MHD_DLOG (daemon, |
4482 | "Threaded operations are not supported on Symbian.\n"); | 4627 | _("Threaded operations are not supported on Symbian.\n")); |
4483 | #endif | 4628 | #endif |
4484 | goto free_and_fail; | 4629 | goto free_and_fail; |
4485 | } | 4630 | } |
@@ -4493,7 +4638,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4493 | { | 4638 | { |
4494 | #ifdef HAVE_MESSAGES | 4639 | #ifdef HAVE_MESSAGES |
4495 | MHD_DLOG (daemon, | 4640 | MHD_DLOG (daemon, |
4496 | "Failed to create socket for listening: %s\n", | 4641 | _("Failed to create socket for listening: %s\n"), |
4497 | MHD_socket_last_strerr_ ()); | 4642 | MHD_socket_last_strerr_ ()); |
4498 | #endif | 4643 | #endif |
4499 | goto free_and_fail; | 4644 | goto free_and_fail; |
@@ -4511,7 +4656,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4511 | { | 4656 | { |
4512 | #ifdef HAVE_MESSAGES | 4657 | #ifdef HAVE_MESSAGES |
4513 | MHD_DLOG (daemon, | 4658 | MHD_DLOG (daemon, |
4514 | "setsockopt failed: %s\n", | 4659 | _("setsockopt failed: %s\n"), |
4515 | MHD_socket_last_strerr_ ()); | 4660 | MHD_socket_last_strerr_ ()); |
4516 | #endif | 4661 | #endif |
4517 | } | 4662 | } |
@@ -4550,11 +4695,12 @@ MHD_start_daemon_va (unsigned int flags, | |||
4550 | if (0 > setsockopt (socket_fd, | 4695 | if (0 > setsockopt (socket_fd, |
4551 | SOL_SOCKET, | 4696 | SOL_SOCKET, |
4552 | SO_REUSEPORT, | 4697 | SO_REUSEPORT, |
4553 | (void*)&on, sizeof (on))) | 4698 | (void *) &on, |
4699 | sizeof (on))) | ||
4554 | { | 4700 | { |
4555 | #ifdef HAVE_MESSAGES | 4701 | #ifdef HAVE_MESSAGES |
4556 | MHD_DLOG (daemon, | 4702 | MHD_DLOG (daemon, |
4557 | "setsockopt failed: %s\n", | 4703 | _("setsockopt failed: %s\n"), |
4558 | MHD_socket_last_strerr_ ()); | 4704 | MHD_socket_last_strerr_ ()); |
4559 | #endif | 4705 | #endif |
4560 | goto free_and_fail; | 4706 | goto free_and_fail; |
@@ -4564,7 +4710,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4564 | on this platform we cannot; fail hard */ | 4710 | on this platform we cannot; fail hard */ |
4565 | #ifdef HAVE_MESSAGES | 4711 | #ifdef HAVE_MESSAGES |
4566 | MHD_DLOG (daemon, | 4712 | MHD_DLOG (daemon, |
4567 | "Cannot allow listening address reuse: SO_REUSEPORT not defined\n"); | 4713 | _("Cannot allow listening address reuse: SO_REUSEPORT not defined\n")); |
4568 | #endif | 4714 | #endif |
4569 | goto free_and_fail; | 4715 | goto free_and_fail; |
4570 | #endif | 4716 | #endif |
@@ -4581,11 +4727,12 @@ MHD_start_daemon_va (unsigned int flags, | |||
4581 | if (0 > setsockopt (socket_fd, | 4727 | if (0 > setsockopt (socket_fd, |
4582 | SOL_SOCKET, | 4728 | SOL_SOCKET, |
4583 | SO_EXCLUSIVEADDRUSE, | 4729 | SO_EXCLUSIVEADDRUSE, |
4584 | (void*)&on, sizeof (on))) | 4730 | (void *) &on, |
4731 | sizeof (on))) | ||
4585 | { | 4732 | { |
4586 | #ifdef HAVE_MESSAGES | 4733 | #ifdef HAVE_MESSAGES |
4587 | MHD_DLOG (daemon, | 4734 | MHD_DLOG (daemon, |
4588 | "setsockopt failed: %s\n", | 4735 | _("setsockopt failed: %s\n"), |
4589 | MHD_socket_last_strerr_ ()); | 4736 | MHD_socket_last_strerr_ ()); |
4590 | #endif | 4737 | #endif |
4591 | goto free_and_fail; | 4738 | goto free_and_fail; |
@@ -4593,7 +4740,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4593 | #else /* SO_EXCLUSIVEADDRUSE not defined on W32? */ | 4740 | #else /* SO_EXCLUSIVEADDRUSE not defined on W32? */ |
4594 | #ifdef HAVE_MESSAGES | 4741 | #ifdef HAVE_MESSAGES |
4595 | MHD_DLOG (daemon, | 4742 | MHD_DLOG (daemon, |
4596 | "Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n"); | 4743 | _("Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n")); |
4597 | #endif | 4744 | #endif |
4598 | goto free_and_fail; | 4745 | goto free_and_fail; |
4599 | #endif | 4746 | #endif |
@@ -4612,7 +4759,9 @@ MHD_start_daemon_va (unsigned int flags, | |||
4612 | #if HAVE_INET6 | 4759 | #if HAVE_INET6 |
4613 | if (0 != (flags & MHD_USE_IPv6)) | 4760 | if (0 != (flags & MHD_USE_IPv6)) |
4614 | { | 4761 | { |
4615 | memset (&servaddr6, 0, sizeof (struct sockaddr_in6)); | 4762 | memset (&servaddr6, |
4763 | 0, | ||
4764 | sizeof (struct sockaddr_in6)); | ||
4616 | servaddr6.sin6_family = AF_INET6; | 4765 | servaddr6.sin6_family = AF_INET6; |
4617 | servaddr6.sin6_port = htons (port); | 4766 | servaddr6.sin6_port = htons (port); |
4618 | #if HAVE_SOCKADDR_IN_SIN_LEN | 4767 | #if HAVE_SOCKADDR_IN_SIN_LEN |
@@ -4623,7 +4772,9 @@ MHD_start_daemon_va (unsigned int flags, | |||
4623 | else | 4772 | else |
4624 | #endif | 4773 | #endif |
4625 | { | 4774 | { |
4626 | memset (&servaddr4, 0, sizeof (struct sockaddr_in)); | 4775 | memset (&servaddr4, |
4776 | 0, | ||
4777 | sizeof (struct sockaddr_in)); | ||
4627 | servaddr4.sin_family = AF_INET; | 4778 | servaddr4.sin_family = AF_INET; |
4628 | servaddr4.sin_port = htons (port); | 4779 | servaddr4.sin_port = htons (port); |
4629 | #if HAVE_SOCKADDR_IN_SIN_LEN | 4780 | #if HAVE_SOCKADDR_IN_SIN_LEN |
@@ -4646,11 +4797,12 @@ MHD_start_daemon_va (unsigned int flags, | |||
4646 | (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)); | 4797 | (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)); |
4647 | if (0 > setsockopt (socket_fd, | 4798 | if (0 > setsockopt (socket_fd, |
4648 | IPPROTO_IPV6, IPV6_V6ONLY, | 4799 | IPPROTO_IPV6, IPV6_V6ONLY, |
4649 | (const void*)&v6_only, sizeof (v6_only))) | 4800 | (const void *) &v6_only, |
4801 | sizeof (v6_only))) | ||
4650 | { | 4802 | { |
4651 | #ifdef HAVE_MESSAGES | 4803 | #ifdef HAVE_MESSAGES |
4652 | MHD_DLOG (daemon, | 4804 | MHD_DLOG (daemon, |
4653 | "setsockopt failed: %s\n", | 4805 | _("setsockopt failed: %s\n"), |
4654 | MHD_socket_last_strerr_ ()); | 4806 | MHD_socket_last_strerr_ ()); |
4655 | #endif | 4807 | #endif |
4656 | } | 4808 | } |
@@ -4661,12 +4813,12 @@ MHD_start_daemon_va (unsigned int flags, | |||
4661 | { | 4813 | { |
4662 | #ifdef HAVE_MESSAGES | 4814 | #ifdef HAVE_MESSAGES |
4663 | MHD_DLOG (daemon, | 4815 | MHD_DLOG (daemon, |
4664 | "Failed to bind to port %u: %s\n", | 4816 | _("Failed to bind to port %u: %s\n"), |
4665 | (unsigned int) port, | 4817 | (unsigned int) port, |
4666 | MHD_socket_last_strerr_ ()); | 4818 | MHD_socket_last_strerr_ ()); |
4667 | #endif | 4819 | #endif |
4668 | if (0 != MHD_socket_close_ (socket_fd)) | 4820 | if (0 != MHD_socket_close_ (socket_fd)) |
4669 | MHD_PANIC ("close failed\n"); | 4821 | MHD_PANIC (_("close failed\n")); |
4670 | goto free_and_fail; | 4822 | goto free_and_fail; |
4671 | } | 4823 | } |
4672 | #ifdef TCP_FASTOPEN | 4824 | #ifdef TCP_FASTOPEN |
@@ -4675,27 +4827,29 @@ MHD_start_daemon_va (unsigned int flags, | |||
4675 | if (0 == daemon->fastopen_queue_size) | 4827 | if (0 == daemon->fastopen_queue_size) |
4676 | daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT; | 4828 | daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT; |
4677 | if (0 != setsockopt (socket_fd, | 4829 | if (0 != setsockopt (socket_fd, |
4678 | IPPROTO_TCP, TCP_FASTOPEN, | 4830 | IPPROTO_TCP, |
4831 | TCP_FASTOPEN, | ||
4679 | &daemon->fastopen_queue_size, | 4832 | &daemon->fastopen_queue_size, |
4680 | sizeof (daemon->fastopen_queue_size))) | 4833 | sizeof (daemon->fastopen_queue_size))) |
4681 | { | 4834 | { |
4682 | #ifdef HAVE_MESSAGES | 4835 | #ifdef HAVE_MESSAGES |
4683 | MHD_DLOG (daemon, | 4836 | MHD_DLOG (daemon, |
4684 | "setsockopt failed: %s\n", | 4837 | _("setsockopt failed: %s\n"), |
4685 | MHD_socket_last_strerr_ ()); | 4838 | MHD_socket_last_strerr_ ()); |
4686 | #endif | 4839 | #endif |
4687 | } | 4840 | } |
4688 | } | 4841 | } |
4689 | #endif | 4842 | #endif |
4690 | if (listen (socket_fd, daemon->listen_backlog_size) < 0) | 4843 | if (listen (socket_fd, |
4844 | daemon->listen_backlog_size) < 0) | ||
4691 | { | 4845 | { |
4692 | #ifdef HAVE_MESSAGES | 4846 | #ifdef HAVE_MESSAGES |
4693 | MHD_DLOG (daemon, | 4847 | MHD_DLOG (daemon, |
4694 | "Failed to listen for connections: %s\n", | 4848 | _("Failed to listen for connections: %s\n"), |
4695 | MHD_socket_last_strerr_ ()); | 4849 | MHD_socket_last_strerr_ ()); |
4696 | #endif | 4850 | #endif |
4697 | if (0 != MHD_socket_close_ (socket_fd)) | 4851 | if (0 != MHD_socket_close_ (socket_fd)) |
4698 | MHD_PANIC ("close failed\n"); | 4852 | MHD_PANIC (_("close failed\n")); |
4699 | goto free_and_fail; | 4853 | goto free_and_fail; |
4700 | } | 4854 | } |
4701 | } | 4855 | } |
@@ -4708,7 +4862,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4708 | { | 4862 | { |
4709 | #ifdef HAVE_MESSAGES | 4863 | #ifdef HAVE_MESSAGES |
4710 | MHD_DLOG (daemon, | 4864 | MHD_DLOG (daemon, |
4711 | "Failed to set nonblocking mode on listening socket: %s\n", | 4865 | _("Failed to set nonblocking mode on listening socket: %s\n"), |
4712 | MHD_socket_last_strerr_()); | 4866 | MHD_socket_last_strerr_()); |
4713 | #endif | 4867 | #endif |
4714 | if (0 != (flags & MHD_USE_EPOLL) || | 4868 | if (0 != (flags & MHD_USE_EPOLL) || |
@@ -4718,21 +4872,22 @@ MHD_start_daemon_va (unsigned int flags, | |||
4718 | * to handle a new connection, but only one will win the race. | 4872 | * to handle a new connection, but only one will win the race. |
4719 | * The others must immediately return. */ | 4873 | * The others must immediately return. */ |
4720 | if (0 != MHD_socket_close_ (socket_fd)) | 4874 | if (0 != MHD_socket_close_ (socket_fd)) |
4721 | MHD_PANIC ("close failed\n"); | 4875 | MHD_PANIC (_("close failed\n")); |
4722 | goto free_and_fail; | 4876 | goto free_and_fail; |
4723 | } | 4877 | } |
4724 | } | 4878 | } |
4725 | if ( (!MHD_SCKT_FD_FITS_FDSET_(socket_fd, NULL)) && | 4879 | if ( (!MHD_SCKT_FD_FITS_FDSET_(socket_fd, |
4880 | NULL)) && | ||
4726 | (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) ) | 4881 | (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) ) |
4727 | { | 4882 | { |
4728 | #ifdef HAVE_MESSAGES | 4883 | #ifdef HAVE_MESSAGES |
4729 | MHD_DLOG (daemon, | 4884 | MHD_DLOG (daemon, |
4730 | "Socket descriptor larger than FD_SETSIZE: %d > %d\n", | 4885 | _("Socket descriptor larger than FD_SETSIZE: %d > %d\n"), |
4731 | socket_fd, | 4886 | socket_fd, |
4732 | FD_SETSIZE); | 4887 | FD_SETSIZE); |
4733 | #endif | 4888 | #endif |
4734 | if (0 != MHD_socket_close_ (socket_fd)) | 4889 | if (0 != MHD_socket_close_ (socket_fd)) |
4735 | MHD_PANIC ("close failed\n"); | 4890 | MHD_PANIC (_("close failed\n")); |
4736 | goto free_and_fail; | 4891 | goto free_and_fail; |
4737 | } | 4892 | } |
4738 | 4893 | ||
@@ -4745,7 +4900,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4745 | { | 4900 | { |
4746 | #ifdef HAVE_MESSAGES | 4901 | #ifdef HAVE_MESSAGES |
4747 | MHD_DLOG (daemon, | 4902 | MHD_DLOG (daemon, |
4748 | "Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_EPOLL is not supported.\n"); | 4903 | _("Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_EPOLL is not supported.\n")); |
4749 | #endif | 4904 | #endif |
4750 | goto free_and_fail; | 4905 | goto free_and_fail; |
4751 | } | 4906 | } |
@@ -4757,7 +4912,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4757 | { | 4912 | { |
4758 | #ifdef HAVE_MESSAGES | 4913 | #ifdef HAVE_MESSAGES |
4759 | MHD_DLOG (daemon, | 4914 | MHD_DLOG (daemon, |
4760 | "epoll is not supported on this platform by this build.\n"); | 4915 | _("epoll is not supported on this platform by this build.\n")); |
4761 | #endif | 4916 | #endif |
4762 | goto free_and_fail; | 4917 | goto free_and_fail; |
4763 | } | 4918 | } |
@@ -4767,37 +4922,38 @@ MHD_start_daemon_va (unsigned int flags, | |||
4767 | { | 4922 | { |
4768 | #ifdef HAVE_MESSAGES | 4923 | #ifdef HAVE_MESSAGES |
4769 | MHD_DLOG (daemon, | 4924 | MHD_DLOG (daemon, |
4770 | "MHD failed to initialize IP connection limit mutex\n"); | 4925 | _("MHD failed to initialize IP connection limit mutex\n")); |
4771 | #endif | 4926 | #endif |
4772 | if ( (MHD_INVALID_SOCKET != socket_fd) && | 4927 | if ( (MHD_INVALID_SOCKET != socket_fd) && |
4773 | (0 != MHD_socket_close_ (socket_fd)) ) | 4928 | (0 != MHD_socket_close_ (socket_fd)) ) |
4774 | MHD_PANIC ("close failed\n"); | 4929 | MHD_PANIC (_("close failed\n")); |
4775 | goto free_and_fail; | 4930 | goto free_and_fail; |
4776 | } | 4931 | } |
4777 | if (! MHD_mutex_init_ (&daemon->cleanup_connection_mutex)) | 4932 | if (! MHD_mutex_init_ (&daemon->cleanup_connection_mutex)) |
4778 | { | 4933 | { |
4779 | #ifdef HAVE_MESSAGES | 4934 | #ifdef HAVE_MESSAGES |
4780 | MHD_DLOG (daemon, | 4935 | MHD_DLOG (daemon, |
4781 | "MHD failed to initialize IP connection limit mutex\n"); | 4936 | _("MHD failed to initialize IP connection limit mutex\n")); |
4782 | #endif | 4937 | #endif |
4783 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); | 4938 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); |
4784 | if ( (MHD_INVALID_SOCKET != socket_fd) && | 4939 | if ( (MHD_INVALID_SOCKET != socket_fd) && |
4785 | (0 != MHD_socket_close_ (socket_fd)) ) | 4940 | (0 != MHD_socket_close_ (socket_fd)) ) |
4786 | MHD_PANIC ("close failed\n"); | 4941 | MHD_PANIC (_("close failed\n")); |
4787 | goto free_and_fail; | 4942 | goto free_and_fail; |
4788 | } | 4943 | } |
4789 | 4944 | ||
4790 | #if HTTPS_SUPPORT | 4945 | #if HTTPS_SUPPORT |
4791 | /* initialize HTTPS daemon certificate aspects & send / recv functions */ | 4946 | /* initialize HTTPS daemon certificate aspects & send / recv functions */ |
4792 | if ((0 != (flags & MHD_USE_SSL)) && (0 != MHD_TLS_init (daemon))) | 4947 | if ( (0 != (flags & MHD_USE_SSL)) && |
4948 | (0 != MHD_TLS_init (daemon)) ) | ||
4793 | { | 4949 | { |
4794 | #ifdef HAVE_MESSAGES | 4950 | #ifdef HAVE_MESSAGES |
4795 | MHD_DLOG (daemon, | 4951 | MHD_DLOG (daemon, |
4796 | "Failed to initialize TLS support\n"); | 4952 | _("Failed to initialize TLS support\n")); |
4797 | #endif | 4953 | #endif |
4798 | if ( (MHD_INVALID_SOCKET != socket_fd) && | 4954 | if ( (MHD_INVALID_SOCKET != socket_fd) && |
4799 | (0 != MHD_socket_close_ (socket_fd)) ) | 4955 | (0 != MHD_socket_close_ (socket_fd)) ) |
4800 | MHD_PANIC ("close failed\n"); | 4956 | MHD_PANIC (_("close failed\n")); |
4801 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); | 4957 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); |
4802 | (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); | 4958 | (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); |
4803 | goto free_and_fail; | 4959 | goto free_and_fail; |
@@ -4816,14 +4972,14 @@ MHD_start_daemon_va (unsigned int flags, | |||
4816 | { | 4972 | { |
4817 | #ifdef HAVE_MESSAGES | 4973 | #ifdef HAVE_MESSAGES |
4818 | MHD_DLOG (daemon, | 4974 | MHD_DLOG (daemon, |
4819 | "Failed to create listen thread: %s\n", | 4975 | _("Failed to create listen thread: %s\n"), |
4820 | MHD_strerror_ (errno)); | 4976 | MHD_strerror_ (errno)); |
4821 | #endif | 4977 | #endif |
4822 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); | 4978 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); |
4823 | (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); | 4979 | (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); |
4824 | if ( (MHD_INVALID_SOCKET != socket_fd) && | 4980 | if ( (MHD_INVALID_SOCKET != socket_fd) && |
4825 | (0 != MHD_socket_close_ (socket_fd)) ) | 4981 | (0 != MHD_socket_close_ (socket_fd)) ) |
4826 | MHD_PANIC ("close failed\n"); | 4982 | MHD_PANIC (_("close failed\n")); |
4827 | goto free_and_fail; | 4983 | goto free_and_fail; |
4828 | } | 4984 | } |
4829 | if ( (daemon->worker_pool_size > 0) && | 4985 | if ( (daemon->worker_pool_size > 0) && |
@@ -4862,44 +5018,45 @@ MHD_start_daemon_va (unsigned int flags, | |||
4862 | /* Always use individual control pipes */ | 5018 | /* Always use individual control pipes */ |
4863 | if (1) | 5019 | if (1) |
4864 | { | 5020 | { |
4865 | if (!MHD_pipe_ (d->wpipe)) | 5021 | if (! MHD_pipe_ (d->wpipe)) |
4866 | { | 5022 | { |
4867 | #ifdef HAVE_MESSAGES | 5023 | #ifdef HAVE_MESSAGES |
4868 | MHD_DLOG (daemon, | 5024 | MHD_DLOG (daemon, |
4869 | "Failed to create worker control pipe: %s\n", | 5025 | _("Failed to create worker control pipe: %s\n"), |
4870 | MHD_pipe_last_strerror_() ); | 5026 | MHD_pipe_last_strerror_() ); |
4871 | #endif | 5027 | #endif |
4872 | goto thread_failed; | 5028 | goto thread_failed; |
4873 | } | 5029 | } |
4874 | if (!MHD_itc_nonblocking_(d->wpipe[0])) | 5030 | if (! MHD_itc_nonblocking_(d->wpipe[0])) |
4875 | { | 5031 | { |
4876 | #ifdef HAVE_MESSAGES | 5032 | #ifdef HAVE_MESSAGES |
4877 | MHD_DLOG (daemon, | 5033 | MHD_DLOG (daemon, |
4878 | "Failed to make read side of worker inter-thread control channel non-blocking: %s\n", | 5034 | _("Failed to make read side of worker inter-thread control channel non-blocking: %s\n"), |
4879 | MHD_pipe_last_strerror_ ()); | 5035 | MHD_pipe_last_strerror_ ()); |
4880 | #endif | 5036 | #endif |
4881 | goto thread_failed; | 5037 | goto thread_failed; |
4882 | } | 5038 | } |
4883 | if (!MHD_itc_nonblocking_(d->wpipe[1])) | 5039 | if (! MHD_itc_nonblocking_(d->wpipe[1])) |
4884 | { | 5040 | { |
4885 | #ifdef HAVE_MESSAGES | 5041 | #ifdef HAVE_MESSAGES |
4886 | MHD_DLOG (daemon, | 5042 | MHD_DLOG (daemon, |
4887 | "Failed to make write side of worker inter-thread control channel non-blocking: %s\n", | 5043 | _("Failed to make write side of worker inter-thread control channel non-blocking: %s\n"), |
4888 | MHD_pipe_last_strerror_ ()); | 5044 | MHD_pipe_last_strerror_ ()); |
4889 | #endif | 5045 | #endif |
4890 | } | 5046 | } |
4891 | } | 5047 | } |
4892 | if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) && | 5048 | if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) && |
4893 | (!MHD_SCKT_FD_FITS_FDSET_(d->wpipe[0], NULL)) ) | 5049 | (! MHD_SCKT_FD_FITS_FDSET_(d->wpipe[0], |
5050 | NULL)) ) | ||
4894 | { | 5051 | { |
4895 | #ifdef HAVE_MESSAGES | 5052 | #ifdef HAVE_MESSAGES |
4896 | MHD_DLOG (daemon, | 5053 | MHD_DLOG (daemon, |
4897 | "File descriptor for worker control pipe exceeds maximum value\n"); | 5054 | _("File descriptor for worker control pipe exceeds maximum value\n")); |
4898 | #endif | 5055 | #endif |
4899 | if (0 != MHD_pipe_close_ (d->wpipe[0])) | 5056 | if (0 != MHD_pipe_close_ (d->wpipe[0])) |
4900 | MHD_PANIC ("close failed\n"); | 5057 | MHD_PANIC (_("close failed\n")); |
4901 | if (0 != MHD_pipe_close_ (d->wpipe[1])) | 5058 | if (0 != MHD_pipe_close_ (d->wpipe[1])) |
4902 | MHD_PANIC ("close failed\n"); | 5059 | MHD_PANIC (_("close failed\n")); |
4903 | goto thread_failed; | 5060 | goto thread_failed; |
4904 | } | 5061 | } |
4905 | 5062 | ||
@@ -4915,11 +5072,11 @@ MHD_start_daemon_va (unsigned int flags, | |||
4915 | goto thread_failed; | 5072 | goto thread_failed; |
4916 | #endif | 5073 | #endif |
4917 | /* Must init cleanup connection mutex for each worker */ | 5074 | /* Must init cleanup connection mutex for each worker */ |
4918 | if (!MHD_mutex_init_ (&d->cleanup_connection_mutex)) | 5075 | if (! MHD_mutex_init_ (&d->cleanup_connection_mutex)) |
4919 | { | 5076 | { |
4920 | #ifdef HAVE_MESSAGES | 5077 | #ifdef HAVE_MESSAGES |
4921 | MHD_DLOG (daemon, | 5078 | MHD_DLOG (daemon, |
4922 | "MHD failed to initialize cleanup connection mutex for thread worker %d\n", i); | 5079 | _("MHD failed to initialize cleanup connection mutex\n")); |
4923 | #endif | 5080 | #endif |
4924 | goto thread_failed; | 5081 | goto thread_failed; |
4925 | } | 5082 | } |
@@ -4933,7 +5090,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
4933 | { | 5090 | { |
4934 | #ifdef HAVE_MESSAGES | 5091 | #ifdef HAVE_MESSAGES |
4935 | MHD_DLOG (daemon, | 5092 | MHD_DLOG (daemon, |
4936 | "Failed to create pool thread: %s\n", | 5093 | _("Failed to create pool thread: %s\n"), |
4937 | MHD_strerror_ (errno)); | 5094 | MHD_strerror_ (errno)); |
4938 | #endif | 5095 | #endif |
4939 | /* Free memory for this worker; cleanup below handles | 5096 | /* Free memory for this worker; cleanup below handles |
@@ -4960,7 +5117,7 @@ thread_failed: | |||
4960 | { | 5117 | { |
4961 | if ( (MHD_INVALID_SOCKET != socket_fd) && | 5118 | if ( (MHD_INVALID_SOCKET != socket_fd) && |
4962 | (0 != MHD_socket_close_ (socket_fd)) ) | 5119 | (0 != MHD_socket_close_ (socket_fd)) ) |
4963 | MHD_PANIC ("close failed\n"); | 5120 | MHD_PANIC (_("close failed\n")); |
4964 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); | 5121 | (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); |
4965 | (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); | 5122 | (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); |
4966 | if (NULL != daemon->worker_pool) | 5123 | if (NULL != daemon->worker_pool) |
@@ -4987,7 +5144,7 @@ thread_failed: | |||
4987 | EPOLL_CTL_DEL, | 5144 | EPOLL_CTL_DEL, |
4988 | daemon->epoll_upgrade_fd, | 5145 | daemon->epoll_upgrade_fd, |
4989 | NULL)) | 5146 | NULL)) |
4990 | MHD_PANIC ("Failed to remove FD from epoll set\n"); | 5147 | MHD_PANIC (_("Failed to remove FD from epoll set\n")); |
4991 | daemon->upgrade_fd_in_epoll = MHD_NO; | 5148 | daemon->upgrade_fd_in_epoll = MHD_NO; |
4992 | } | 5149 | } |
4993 | #endif | 5150 | #endif |
@@ -5008,10 +5165,10 @@ thread_failed: | |||
5008 | #endif | 5165 | #endif |
5009 | if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) && | 5166 | if ( (MHD_INVALID_PIPE_ != daemon->wpipe[0]) && |
5010 | (0 != MHD_pipe_close_ (daemon->wpipe[0])) ) | 5167 | (0 != MHD_pipe_close_ (daemon->wpipe[0])) ) |
5011 | MHD_PANIC ("close failed\n"); | 5168 | MHD_PANIC (_("close failed\n")); |
5012 | if ( (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && | 5169 | if ( (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && |
5013 | (0 != MHD_pipe_close_ (daemon->wpipe[1])) ) | 5170 | (0 != MHD_pipe_close_ (daemon->wpipe[1])) ) |
5014 | MHD_PANIC ("close failed\n"); | 5171 | MHD_PANIC (_("close failed\n")); |
5015 | free (daemon); | 5172 | free (daemon); |
5016 | return NULL; | 5173 | return NULL; |
5017 | } | 5174 | } |
@@ -5065,10 +5222,10 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
5065 | /* first, make sure all threads are aware of shutdown; need to | 5222 | /* first, make sure all threads are aware of shutdown; need to |
5066 | traverse DLLs in peace... */ | 5223 | traverse DLLs in peace... */ |
5067 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 5224 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
5068 | (!MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | 5225 | (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) |
5069 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 5226 | MHD_PANIC (_("Failed to acquire cleanup mutex\n")); |
5070 | if (NULL != daemon->suspended_connections_head) | 5227 | if (NULL != daemon->suspended_connections_head) |
5071 | MHD_PANIC ("MHD_stop_daemon() called while we have suspended connections.\n"); | 5228 | MHD_PANIC (_("MHD_stop_daemon() called while we have suspended connections.\n")); |
5072 | for (pos = daemon->connections_head; NULL != pos; pos = pos->next) | 5229 | for (pos = daemon->connections_head; NULL != pos; pos = pos->next) |
5073 | { | 5230 | { |
5074 | shutdown (pos->socket_fd, SHUT_RDWR); | 5231 | shutdown (pos->socket_fd, SHUT_RDWR); |
@@ -5076,12 +5233,12 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
5076 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 5233 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
5077 | (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && | 5234 | (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && |
5078 | (1 != MHD_pipe_write_ (daemon->wpipe[1], "e", 1)) ) | 5235 | (1 != MHD_pipe_write_ (daemon->wpipe[1], "e", 1)) ) |
5079 | MHD_PANIC ("Failed to signal shutdown via pipe"); | 5236 | MHD_PANIC (_("Failed to signal shutdown via pipe")); |
5080 | #endif | 5237 | #endif |
5081 | } | 5238 | } |
5082 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 5239 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
5083 | (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | 5240 | (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) |
5084 | MHD_PANIC ("Failed to release cleanup mutex\n"); | 5241 | MHD_PANIC (_("Failed to release cleanup mutex\n")); |
5085 | 5242 | ||
5086 | /* now, collect per-connection threads */ | 5243 | /* now, collect per-connection threads */ |
5087 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 5244 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
@@ -5091,8 +5248,8 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
5091 | { | 5248 | { |
5092 | if (MHD_YES != pos->thread_joined) | 5249 | if (MHD_YES != pos->thread_joined) |
5093 | { | 5250 | { |
5094 | if (!MHD_join_thread_ (pos->pid)) | 5251 | if (! MHD_join_thread_ (pos->pid)) |
5095 | MHD_PANIC ("Failed to join a thread\n"); | 5252 | MHD_PANIC (_("Failed to join a thread\n")); |
5096 | pos->thread_joined = MHD_YES; | 5253 | pos->thread_joined = MHD_YES; |
5097 | /* The thread may have concurrently modified the DLL, | 5254 | /* The thread may have concurrently modified the DLL, |
5098 | need to restart from the beginning */ | 5255 | need to restart from the beginning */ |
@@ -5107,7 +5264,7 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
5107 | { | 5264 | { |
5108 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 5265 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
5109 | (MHD_YES != pos->thread_joined) ) | 5266 | (MHD_YES != pos->thread_joined) ) |
5110 | MHD_PANIC ("Failed to join a thread\n"); | 5267 | MHD_PANIC (_("Failed to join a thread\n")); |
5111 | close_connection (pos); | 5268 | close_connection (pos); |
5112 | } | 5269 | } |
5113 | MHD_cleanup_connections (daemon); | 5270 | MHD_cleanup_connections (daemon); |
@@ -5128,7 +5285,7 @@ epoll_shutdown (struct MHD_Daemon *daemon) | |||
5128 | if (MHD_INVALID_PIPE_ == daemon->wpipe[1]) | 5285 | if (MHD_INVALID_PIPE_ == daemon->wpipe[1]) |
5129 | { | 5286 | { |
5130 | /* wpipe was required in this mode, how could this happen? */ | 5287 | /* wpipe was required in this mode, how could this happen? */ |
5131 | MHD_PANIC ("Internal error\n"); | 5288 | MHD_PANIC (_("Internal error\n")); |
5132 | } | 5289 | } |
5133 | event.events = EPOLLOUT; | 5290 | event.events = EPOLLOUT; |
5134 | event.data.ptr = NULL; | 5291 | event.data.ptr = NULL; |
@@ -5136,7 +5293,7 @@ epoll_shutdown (struct MHD_Daemon *daemon) | |||
5136 | EPOLL_CTL_ADD, | 5293 | EPOLL_CTL_ADD, |
5137 | daemon->wpipe[1], | 5294 | daemon->wpipe[1], |
5138 | &event)) | 5295 | &event)) |
5139 | MHD_PANIC ("Failed to add wpipe to epoll set to signal termination\n"); | 5296 | MHD_PANIC (_("Failed to add wpipe to epoll set to signal termination\n")); |
5140 | } | 5297 | } |
5141 | #endif | 5298 | #endif |
5142 | 5299 | ||
@@ -5180,7 +5337,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5180 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) | 5337 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) |
5181 | { | 5338 | { |
5182 | if (1 != MHD_pipe_write_ (daemon->wpipe[1], "e", 1)) | 5339 | if (1 != MHD_pipe_write_ (daemon->wpipe[1], "e", 1)) |
5183 | MHD_PANIC ("failed to signal shutdown via pipe"); | 5340 | MHD_PANIC (_("Failed to signal shutdown via pipe")); |
5184 | } | 5341 | } |
5185 | #ifdef HAVE_LISTEN_SHUTDOWN | 5342 | #ifdef HAVE_LISTEN_SHUTDOWN |
5186 | else | 5343 | else |
@@ -5188,7 +5345,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5188 | /* fd might be MHD_INVALID_SOCKET here due to 'MHD_quiesce_daemon' */ | 5345 | /* fd might be MHD_INVALID_SOCKET here due to 'MHD_quiesce_daemon' */ |
5189 | if ( (MHD_INVALID_SOCKET != fd) && | 5346 | if ( (MHD_INVALID_SOCKET != fd) && |
5190 | (0 == (daemon->options & MHD_USE_PIPE_FOR_SHUTDOWN)) ) | 5347 | (0 == (daemon->options & MHD_USE_PIPE_FOR_SHUTDOWN)) ) |
5191 | (void) shutdown (fd, SHUT_RDWR); | 5348 | (void) shutdown (fd, |
5349 | SHUT_RDWR); | ||
5192 | } | 5350 | } |
5193 | #endif | 5351 | #endif |
5194 | #ifdef EPOLL_SUPPORT | 5352 | #ifdef EPOLL_SUPPORT |
@@ -5201,7 +5359,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5201 | #if DEBUG_CLOSE | 5359 | #if DEBUG_CLOSE |
5202 | #ifdef HAVE_MESSAGES | 5360 | #ifdef HAVE_MESSAGES |
5203 | MHD_DLOG (daemon, | 5361 | MHD_DLOG (daemon, |
5204 | "MHD listen socket shutdown\n"); | 5362 | _("MHD listen socket shutdown\n")); |
5205 | #endif | 5363 | #endif |
5206 | #endif | 5364 | #endif |
5207 | 5365 | ||
@@ -5214,21 +5372,23 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5214 | { | 5372 | { |
5215 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) | 5373 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) |
5216 | { | 5374 | { |
5217 | if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe[1], "e", 1)) | 5375 | if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe[1], |
5218 | MHD_PANIC ("failed to signal shutdown via pipe"); | 5376 | "e", |
5377 | 1)) | ||
5378 | MHD_PANIC (_("Failed to signal shutdown via pipe.")); | ||
5219 | } | 5379 | } |
5220 | if (!MHD_join_thread_ (daemon->worker_pool[i].pid)) | 5380 | if (!MHD_join_thread_ (daemon->worker_pool[i].pid)) |
5221 | MHD_PANIC ("Failed to join a thread\n"); | 5381 | MHD_PANIC (_("Failed to join a thread\n")); |
5222 | close_all_connections (&daemon->worker_pool[i]); | 5382 | close_all_connections (&daemon->worker_pool[i]); |
5223 | (void) MHD_mutex_destroy_ (&daemon->worker_pool[i].cleanup_connection_mutex); | 5383 | (void) MHD_mutex_destroy_ (&daemon->worker_pool[i].cleanup_connection_mutex); |
5224 | #ifdef EPOLL_SUPPORT | 5384 | #ifdef EPOLL_SUPPORT |
5225 | if ( (-1 != daemon->worker_pool[i].epoll_fd) && | 5385 | if ( (-1 != daemon->worker_pool[i].epoll_fd) && |
5226 | (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_fd)) ) | 5386 | (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_fd)) ) |
5227 | MHD_PANIC ("close failed\n"); | 5387 | MHD_PANIC (_("close failed\n")); |
5228 | #if HTTPS_SUPPORT | 5388 | #if HTTPS_SUPPORT |
5229 | if ( (-1 != daemon->worker_pool[i].epoll_upgrade_fd) && | 5389 | if ( (-1 != daemon->worker_pool[i].epoll_upgrade_fd) && |
5230 | (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_upgrade_fd)) ) | 5390 | (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_upgrade_fd)) ) |
5231 | MHD_PANIC ("close failed\n"); | 5391 | MHD_PANIC (_("close failed\n")); |
5232 | #endif | 5392 | #endif |
5233 | #endif | 5393 | #endif |
5234 | /* Individual pipes are always used */ | 5394 | /* Individual pipes are always used */ |
@@ -5237,9 +5397,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5237 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) | 5397 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) |
5238 | { | 5398 | { |
5239 | if (0 != MHD_pipe_close_ (daemon->worker_pool[i].wpipe[0])) | 5399 | if (0 != MHD_pipe_close_ (daemon->worker_pool[i].wpipe[0])) |
5240 | MHD_PANIC ("close failed\n"); | 5400 | MHD_PANIC (_("close failed\n")); |
5241 | if (0 != MHD_pipe_close_ (daemon->worker_pool[i].wpipe[1])) | 5401 | if (0 != MHD_pipe_close_ (daemon->worker_pool[i].wpipe[1])) |
5242 | MHD_PANIC ("close failed\n"); | 5402 | MHD_PANIC (_("close failed\n")); |
5243 | } | 5403 | } |
5244 | } | 5404 | } |
5245 | } | 5405 | } |
@@ -5254,14 +5414,14 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5254 | { | 5414 | { |
5255 | if (!MHD_join_thread_ (daemon->pid)) | 5415 | if (!MHD_join_thread_ (daemon->pid)) |
5256 | { | 5416 | { |
5257 | MHD_PANIC ("Failed to join a thread\n"); | 5417 | MHD_PANIC (_("Failed to join a thread\n")); |
5258 | } | 5418 | } |
5259 | } | 5419 | } |
5260 | } | 5420 | } |
5261 | close_all_connections (daemon); | 5421 | close_all_connections (daemon); |
5262 | if ( (MHD_INVALID_SOCKET != fd) && | 5422 | if ( (MHD_INVALID_SOCKET != fd) && |
5263 | (0 != MHD_socket_close_ (fd)) ) | 5423 | (0 != MHD_socket_close_ (fd)) ) |
5264 | MHD_PANIC ("close failed\n"); | 5424 | MHD_PANIC (_("close failed\n")); |
5265 | 5425 | ||
5266 | /* TLS clean up */ | 5426 | /* TLS clean up */ |
5267 | #if HTTPS_SUPPORT | 5427 | #if HTTPS_SUPPORT |
@@ -5281,12 +5441,12 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5281 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && | 5441 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && |
5282 | (-1 != daemon->epoll_fd) && | 5442 | (-1 != daemon->epoll_fd) && |
5283 | (0 != MHD_socket_close_ (daemon->epoll_fd)) ) | 5443 | (0 != MHD_socket_close_ (daemon->epoll_fd)) ) |
5284 | MHD_PANIC ("close failed\n"); | 5444 | MHD_PANIC (_("close failed\n")); |
5285 | #if HTTPS_SUPPORT | 5445 | #if HTTPS_SUPPORT |
5286 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && | 5446 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && |
5287 | (-1 != daemon->epoll_upgrade_fd) && | 5447 | (-1 != daemon->epoll_upgrade_fd) && |
5288 | (0 != MHD_socket_close_ (daemon->epoll_upgrade_fd)) ) | 5448 | (0 != MHD_socket_close_ (daemon->epoll_upgrade_fd)) ) |
5289 | MHD_PANIC ("close failed\n"); | 5449 | MHD_PANIC (_("close failed\n")); |
5290 | #endif | 5450 | #endif |
5291 | #endif | 5451 | #endif |
5292 | 5452 | ||
@@ -5300,9 +5460,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
5300 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) | 5460 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) |
5301 | { | 5461 | { |
5302 | if (0 != MHD_pipe_close_ (daemon->wpipe[0])) | 5462 | if (0 != MHD_pipe_close_ (daemon->wpipe[0])) |
5303 | MHD_PANIC ("close failed\n"); | 5463 | MHD_PANIC (_("close failed\n")); |
5304 | if (0 != MHD_pipe_close_ (daemon->wpipe[1])) | 5464 | if (0 != MHD_pipe_close_ (daemon->wpipe[1])) |
5305 | MHD_PANIC ("close failed\n"); | 5465 | MHD_PANIC (_("close failed\n")); |
5306 | } | 5466 | } |
5307 | free (daemon); | 5467 | free (daemon); |
5308 | } | 5468 | } |
@@ -5397,7 +5557,9 @@ MHD_get_version (void) | |||
5397 | static char ver[12] = "\0\0\0\0\0\0\0\0\0\0\0"; | 5557 | static char ver[12] = "\0\0\0\0\0\0\0\0\0\0\0"; |
5398 | if (0 == ver[0]) | 5558 | if (0 == ver[0]) |
5399 | { | 5559 | { |
5400 | int res = MHD_snprintf_(ver, sizeof(ver), "%x.%x.%x", | 5560 | int res = MHD_snprintf_(ver, |
5561 | sizeof(ver), | ||
5562 | "%x.%x.%x", | ||
5401 | (((int)MHD_VERSION >> 24) & 0xFF), | 5563 | (((int)MHD_VERSION >> 24) & 0xFF), |
5402 | (((int)MHD_VERSION >> 16) & 0xFF), | 5564 | (((int)MHD_VERSION >> 16) & 0xFF), |
5403 | (((int)MHD_VERSION >> 8) & 0xFF)); | 5565 | (((int)MHD_VERSION >> 8) & 0xFF)); |
@@ -5596,24 +5758,26 @@ MHD_init(void) | |||
5596 | 5758 | ||
5597 | #ifdef _WIN32 | 5759 | #ifdef _WIN32 |
5598 | if (0 != WSAStartup(MAKEWORD(2, 2), &wsd)) | 5760 | if (0 != WSAStartup(MAKEWORD(2, 2), &wsd)) |
5599 | MHD_PANIC ("Failed to initialize winsock\n"); | 5761 | MHD_PANIC (_("Failed to initialize winsock\n")); |
5600 | mhd_winsock_inited_ = 1; | 5762 | mhd_winsock_inited_ = 1; |
5601 | if (2 != LOBYTE(wsd.wVersion) && 2 != HIBYTE(wsd.wVersion)) | 5763 | if (2 != LOBYTE(wsd.wVersion) && 2 != HIBYTE(wsd.wVersion)) |
5602 | MHD_PANIC ("Winsock version 2.2 is not available\n"); | 5764 | MHD_PANIC (_("Winsock version 2.2 is not available\n")); |
5603 | #endif | 5765 | #endif |
5604 | #if HTTPS_SUPPORT | 5766 | #if HTTPS_SUPPORT |
5605 | #if GCRYPT_VERSION_NUMBER < 0x010600 | 5767 | #if GCRYPT_VERSION_NUMBER < 0x010600 |
5606 | #if defined(MHD_USE_POSIX_THREADS) | 5768 | #if defined(MHD_USE_POSIX_THREADS) |
5607 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread)) | 5769 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, |
5608 | MHD_PANIC ("Failed to initialise multithreading in libgcrypt\n"); | 5770 | &gcry_threads_pthread)) |
5771 | MHD_PANIC (_("Failed to initialise multithreading in libgcrypt\n")); | ||
5609 | #elif defined(MHD_W32_MUTEX_) | 5772 | #elif defined(MHD_W32_MUTEX_) |
5610 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_w32)) | 5773 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, |
5611 | MHD_PANIC ("Failed to initialise multithreading in libgcrypt\n"); | 5774 | &gcry_threads_w32)) |
5775 | MHD_PANIC (_("Failed to initialise multithreading in libgcrypt\n")); | ||
5612 | #endif /* defined(MHD_W32_MUTEX_) */ | 5776 | #endif /* defined(MHD_W32_MUTEX_) */ |
5613 | gcry_check_version (NULL); | 5777 | gcry_check_version (NULL); |
5614 | #else | 5778 | #else |
5615 | if (NULL == gcry_check_version ("1.6.0")) | 5779 | if (NULL == gcry_check_version ("1.6.0")) |
5616 | MHD_PANIC ("libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 or newer\n"); | 5780 | MHD_PANIC (_("libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 or newer\n")); |
5617 | #endif | 5781 | #endif |
5618 | gnutls_global_init (); | 5782 | gnutls_global_init (); |
5619 | #endif | 5783 | #endif |