aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-03-02 20:42:56 +0100
committerChristian Grothoff <christian@grothoff.org>2018-03-02 21:45:25 +0100
commit71a67ca95997fb2c3a90108a776f61fe1b95e68c (patch)
tree133397bb2199b93eedb95da8caab01873ca07f89 /src
parent7f1dbb2aef40573861d9d19add648d1a327386f2 (diff)
downloadlibmicrohttpd-71a67ca95997fb2c3a90108a776f61fe1b95e68c.tar.gz
libmicrohttpd-71a67ca95997fb2c3a90108a776f61fe1b95e68c.zip
remove dead IN_CLEANUP state, revert previous patch that called completed callback from wrong thread
Diffstat (limited to 'src')
-rw-r--r--src/lib/connection_add.c31
-rw-r--r--src/lib/connection_call_handlers.c6
-rw-r--r--src/lib/internal.h101
-rw-r--r--src/lib/request_info.c7
-rw-r--r--src/lib/request_resume.c2
-rw-r--r--src/microhttpd/connection.c9
-rw-r--r--src/microhttpd/daemon.c21
-rw-r--r--src/microhttpd/internal.h5
8 files changed, 74 insertions, 108 deletions
diff --git a/src/lib/connection_add.c b/src/lib/connection_add.c
index 39a61f61..570a6a09 100644
--- a/src/lib/connection_add.c
+++ b/src/lib/connection_add.c
@@ -110,7 +110,7 @@ thread_main_handle_connection (void *data)
110 const bool use_poll = false; 110 const bool use_poll = false;
111#endif /* ! HAVE_POLL */ 111#endif /* ! HAVE_POLL */
112 bool was_suspended = false; 112 bool was_suspended = false;
113 113
114 MHD_thread_init_(&con->pid); 114 MHD_thread_init_(&con->pid);
115 115
116 while ( (! daemon->shutdown) && 116 while ( (! daemon->shutdown) &&
@@ -398,7 +398,7 @@ thread_main_handle_connection (void *data)
398 { 398 {
399 /* Normal HTTP processing is finished, 399 /* Normal HTTP processing is finished,
400 * notify application. */ 400 * notify application. */
401 if (NULL != con->request.response->termination_cb) 401 if (NULL != con->request.response->termination_cb)
402 con->request.response->termination_cb 402 con->request.response->termination_cb
403 (con->request.response->termination_cb_cls, 403 (con->request.response->termination_cb_cls,
404 MHD_REQUEST_TERMINATED_COMPLETED_OK, 404 MHD_REQUEST_TERMINATED_COMPLETED_OK,
@@ -419,22 +419,19 @@ thread_main_handle_connection (void *data)
419 } 419 }
420#endif /* UPGRADE_SUPPORT */ 420#endif /* UPGRADE_SUPPORT */
421 } 421 }
422 if (MHD_REQUEST_IN_CLEANUP != con->request.state)
423 {
424#if DEBUG_CLOSE 422#if DEBUG_CLOSE
425#ifdef HAVE_MESSAGES 423#ifdef HAVE_MESSAGES
426 MHD_DLOG (con->daemon, 424 MHD_DLOG (con->daemon,
427 MHD_SC_THREAD_TERMINATING, 425 MHD_SC_THREAD_TERMINATING,
428 _("Processing thread terminating. Closing connection\n")); 426 _("Processing thread terminating. Closing connection\n"));
429#endif 427#endif
430#endif 428#endif
431 if (MHD_REQUEST_CLOSED != con->request.state) 429 if (MHD_REQUEST_CLOSED != con->request.state)
432 MHD_connection_close_ (con, 430 MHD_connection_close_ (con,
433 (daemon->shutdown) ? 431 (daemon->shutdown) ?
434 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN: 432 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN:
435 MHD_REQUEST_TERMINATED_WITH_ERROR); 433 MHD_REQUEST_TERMINATED_WITH_ERROR);
436 MHD_request_handle_idle_ (&con->request); 434 MHD_request_handle_idle_ (&con->request);
437 }
438exit: 435exit:
439 if (NULL != con->request.response) 436 if (NULL != con->request.response)
440 { 437 {
@@ -892,7 +889,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
892#endif 889#endif
893 } 890 }
894 return MHD_SC_OK; 891 return MHD_SC_OK;
895 892
896 cleanup: 893 cleanup:
897 if (NULL != daemon->notify_connection_cb) 894 if (NULL != daemon->notify_connection_cb)
898 daemon->notify_connection_cb (daemon->notify_connection_cb_cls, 895 daemon->notify_connection_cb (daemon->notify_connection_cb_cls,
@@ -908,7 +905,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
908 addr, 905 addr,
909 addrlen); 906 addrlen);
910 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); 907 MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
911 if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_model) 908 if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_model)
912 { 909 {
913 XDLL_remove (daemon->normal_timeout_head, 910 XDLL_remove (daemon->normal_timeout_head,
914 daemon->normal_timeout_tail, 911 daemon->normal_timeout_tail,
@@ -976,7 +973,7 @@ MHD_daemon_add_connection (struct MHD_Daemon *daemon,
976 { 973 {
977 sk_nonbl = true; 974 sk_nonbl = true;
978 } 975 }
979 976
980 if ( (daemon->enable_turbo) && 977 if ( (daemon->enable_turbo) &&
981 (! MHD_socket_noninheritable_ (client_socket)) ) 978 (! MHD_socket_noninheritable_ (client_socket)) )
982 { 979 {
diff --git a/src/lib/connection_call_handlers.c b/src/lib/connection_call_handlers.c
index 22704d1b..f1c31cb6 100644
--- a/src/lib/connection_call_handlers.c
+++ b/src/lib/connection_call_handlers.c
@@ -971,9 +971,6 @@ MHD_request_handle_write_ (struct MHD_Request *request)
971 return; 971 return;
972 case MHD_REQUEST_CLOSED: 972 case MHD_REQUEST_CLOSED:
973 return; 973 return;
974 case MHD_REQUEST_IN_CLEANUP:
975 mhd_assert (0);
976 return;
977#ifdef UPGRADE_SUPPORT 974#ifdef UPGRADE_SUPPORT
978 case MHD_REQUEST_UPGRADE: 975 case MHD_REQUEST_UPGRADE:
979 mhd_assert (0); 976 mhd_assert (0);
@@ -3048,9 +3045,6 @@ connection_update_event_loop_info (struct MHD_Connection *connection)
3048 case MHD_REQUEST_CLOSED: 3045 case MHD_REQUEST_CLOSED:
3049 request->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; 3046 request->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
3050 return; /* do nothing, not even reading */ 3047 return; /* do nothing, not even reading */
3051 case MHD_REQUEST_IN_CLEANUP:
3052 mhd_assert (0);
3053 break;
3054#ifdef UPGRADE_SUPPORT 3048#ifdef UPGRADE_SUPPORT
3055 case MHD_REQUEST_UPGRADE: 3049 case MHD_REQUEST_UPGRADE:
3056 mhd_assert (0); 3050 mhd_assert (0);
diff --git a/src/lib/internal.h b/src/lib/internal.h
index 52be90d9..97024683 100644
--- a/src/lib/internal.h
+++ b/src/lib/internal.h
@@ -209,7 +209,7 @@ typedef ssize_t
209 * not have to be completed yet). A transition to 209 * not have to be completed yet). A transition to
210 * #MHD_REQUEST_CLOSED or #MHD_REQUEST_INIT requires the write 210 * #MHD_REQUEST_CLOSED or #MHD_REQUEST_INIT requires the write
211 * to be complete. 211 * to be complete.
212 */ 212 */
213enum MHD_REQUEST_STATE // FIXME: fix capitalization! 213enum MHD_REQUEST_STATE // FIXME: fix capitalization!
214{ 214{
215 /** 215 /**
@@ -317,11 +317,6 @@ enum MHD_REQUEST_STATE // FIXME: fix capitalization!
317 */ 317 */
318 MHD_REQUEST_CLOSED = MHD_REQUEST_FOOTERS_SENT + 1, 318 MHD_REQUEST_CLOSED = MHD_REQUEST_FOOTERS_SENT + 1,
319 319
320 /**
321 * 20: This request is finished (only to be freed)
322 */
323 MHD_REQUEST_IN_CLEANUP = MHD_REQUEST_CLOSED + 1,
324
325#ifdef UPGRADE_SUPPORT 320#ifdef UPGRADE_SUPPORT
326 /** 321 /**
327 * Request was "upgraded" and socket is now under the 322 * Request was "upgraded" and socket is now under the
@@ -369,7 +364,7 @@ struct MHD_Request
369{ 364{
370 365
371 /** 366 /**
372 * Reference to the `struct MHD_Daemon`. 367 * Reference to the `struct MHD_Daemon`.
373 */ 368 */
374 struct MHD_Daemon *daemon; 369 struct MHD_Daemon *daemon;
375 370
@@ -383,7 +378,7 @@ struct MHD_Request
383 * it is available. 378 * it is available.
384 */ 379 */
385 struct MHD_Response *response; 380 struct MHD_Response *response;
386 381
387 /** 382 /**
388 * Linked list of parsed headers. 383 * Linked list of parsed headers.
389 */ 384 */
@@ -554,7 +549,7 @@ struct MHD_Request
554 * HTTP method, as an enum. 549 * HTTP method, as an enum.
555 */ 550 */
556 enum MHD_Method method; 551 enum MHD_Method method;
557 552
558 /** 553 /**
559 * What is this request waiting for? 554 * What is this request waiting for?
560 */ 555 */
@@ -633,7 +628,7 @@ enum MHD_EpollState
633 628
634/** 629/**
635 * State kept per HTTP connection. 630 * State kept per HTTP connection.
636 */ 631 */
637struct MHD_Connection 632struct MHD_Connection
638{ 633{
639 634
@@ -687,7 +682,7 @@ struct MHD_Connection
687 * address (which persists across individual requests). 682 * address (which persists across individual requests).
688 */ 683 */
689 struct MemoryPool *pool; 684 struct MemoryPool *pool;
690 685
691 /** 686 /**
692 * We allow the main application to associate some pointer with the 687 * We allow the main application to associate some pointer with the
693 * TCP connection (which may span multiple HTTP requests). Here is 688 * TCP connection (which may span multiple HTTP requests). Here is
@@ -703,7 +698,7 @@ struct MHD_Connection
703 */ 698 */
704 struct MHD_TLS_ConnectionState *tls_cs; 699 struct MHD_TLS_ConnectionState *tls_cs;
705#endif 700#endif
706 701
707 /** 702 /**
708 * Function used for reading HTTP request stream. 703 * Function used for reading HTTP request stream.
709 */ 704 */
@@ -727,7 +722,7 @@ struct MHD_Connection
727 MHD_thread_handle_ID_ pid; 722 MHD_thread_handle_ID_ pid;
728 723
729 /** 724 /**
730 * Foreign address (of length @e addr_len). 725 * Foreign address (of length @e addr_len).
731 */ 726 */
732 struct sockaddr_storage addr; 727 struct sockaddr_storage addr;
733 728
@@ -794,7 +789,7 @@ struct MHD_Connection
794 * from this socket). 789 * from this socket).
795 */ 790 */
796 bool read_closed; 791 bool read_closed;
797 792
798}; 793};
799 794
800 795
@@ -1013,7 +1008,7 @@ struct MHD_Daemon
1013 */ 1008 */
1014 void *rc_cls; 1009 void *rc_cls;
1015 1010
1016 /** 1011 /**
1017 * Function to call for logging. 1012 * Function to call for logging.
1018 */ 1013 */
1019 MHD_LoggingCallback logger; 1014 MHD_LoggingCallback logger;
@@ -1021,7 +1016,7 @@ struct MHD_Daemon
1021 /** 1016 /**
1022 * Closure for @e logger. 1017 * Closure for @e logger.
1023 */ 1018 */
1024 void *logger_cls; 1019 void *logger_cls;
1025 1020
1026 /** 1021 /**
1027 * Function to call to accept/reject connections based on 1022 * Function to call to accept/reject connections based on
@@ -1076,7 +1071,7 @@ struct MHD_Daemon
1076 */ 1071 */
1077 struct MHD_Daemon *worker_pool; 1072 struct MHD_Daemon *worker_pool;
1078 1073
1079 1074
1080#if HTTPS_SUPPORT 1075#if HTTPS_SUPPORT
1081#ifdef UPGRADE_SUPPORT 1076#ifdef UPGRADE_SUPPORT
1082 /** 1077 /**
@@ -1098,7 +1093,7 @@ struct MHD_Daemon
1098 * Which TLS backend should be used. NULL for no TLS. 1093 * Which TLS backend should be used. NULL for no TLS.
1099 * This is merely the handle to the dlsym() object, not 1094 * This is merely the handle to the dlsym() object, not
1100 * the API. 1095 * the API.
1101 */ 1096 */
1102 void *tls_backend_lib; 1097 void *tls_backend_lib;
1103 1098
1104 /** 1099 /**
@@ -1152,7 +1147,7 @@ struct MHD_Daemon
1152 * Not used in MHD_USE_THREAD_PER_CONNECTION mode. 1147 * Not used in MHD_USE_THREAD_PER_CONNECTION mode.
1153 */ 1148 */
1154 struct MHD_Connection *manual_timeout_tail; 1149 struct MHD_Connection *manual_timeout_tail;
1155 1150
1156 /** 1151 /**
1157 * Head of doubly-linked list of our current, active connections. 1152 * Head of doubly-linked list of our current, active connections.
1158 */ 1153 */
@@ -1251,8 +1246,8 @@ struct MHD_Daemon
1251 * The select thread handle (if we have internal select) 1246 * The select thread handle (if we have internal select)
1252 */ 1247 */
1253 MHD_thread_handle_ID_ pid; 1248 MHD_thread_handle_ID_ pid;
1254 1249
1255 /** 1250 /**
1256 * Socket address to bind to for the listen socket. 1251 * Socket address to bind to for the listen socket.
1257 */ 1252 */
1258 struct sockaddr_storage listen_sa; 1253 struct sockaddr_storage listen_sa;
@@ -1267,8 +1262,8 @@ struct MHD_Daemon
1267 * "manual_timeout" DLLs. 1262 * "manual_timeout" DLLs.
1268 */ 1263 */
1269 MHD_mutex_ cleanup_connection_mutex; 1264 MHD_mutex_ cleanup_connection_mutex;
1270 1265
1271 /** 1266 /**
1272 * Number of (valid) bytes in @e listen_sa. Zero 1267 * Number of (valid) bytes in @e listen_sa. Zero
1273 * if @e listen_sa is not initialized. 1268 * if @e listen_sa is not initialized.
1274 */ 1269 */
@@ -1277,7 +1272,7 @@ struct MHD_Daemon
1277/** 1272/**
1278 * Default size of the per-connection memory pool. 1273 * Default size of the per-connection memory pool.
1279 */ 1274 */
1280#define POOL_SIZE_DEFAULT (32 * 1024) 1275#define POOL_SIZE_DEFAULT (32 * 1024)
1281 /** 1276 /**
1282 * Buffer size to use for each connection. Default 1277 * Buffer size to use for each connection. Default
1283 * is #POOL_SIZE_DEFAULT. 1278 * is #POOL_SIZE_DEFAULT.
@@ -1292,7 +1287,7 @@ struct MHD_Daemon
1292 * space). 1287 * space).
1293 */ 1288 */
1294#define BUF_INC_SIZE_DEFAULT 1024 1289#define BUF_INC_SIZE_DEFAULT 1024
1295 1290
1296 /** 1291 /**
1297 * Increment to use when growing the read buffer. Smaller 1292 * Increment to use when growing the read buffer. Smaller
1298 * than @e connection_memory_limit_b. 1293 * than @e connection_memory_limit_b.
@@ -1306,7 +1301,7 @@ struct MHD_Daemon
1306 size_t thread_stack_limit_b; 1301 size_t thread_stack_limit_b;
1307 1302
1308#if ENABLE_DAUTH 1303#if ENABLE_DAUTH
1309 1304
1310 /** 1305 /**
1311 * Size of @e digest_auth_random_buf. 1306 * Size of @e digest_auth_random_buf.
1312 */ 1307 */
@@ -1316,14 +1311,14 @@ struct MHD_Daemon
1316 * Default value for @e digest_nc_length. 1311 * Default value for @e digest_nc_length.
1317 */ 1312 */
1318#define DIGEST_NC_LENGTH_DEFAULT 4 1313#define DIGEST_NC_LENGTH_DEFAULT 4
1319 1314
1320 /** 1315 /**
1321 * Desired length of the internal array with the nonce and 1316 * Desired length of the internal array with the nonce and
1322 * nonce counters for digest authentication. 1317 * nonce counters for digest authentication.
1323 */ 1318 */
1324 size_t digest_nc_length; 1319 size_t digest_nc_length;
1325#endif 1320#endif
1326 1321
1327 /** 1322 /**
1328 * Default value we use for the listen backlog. 1323 * Default value we use for the listen backlog.
1329 */ 1324 */
@@ -1332,13 +1327,13 @@ struct MHD_Daemon
1332#else /* !SOMAXCONN */ 1327#else /* !SOMAXCONN */
1333#define LISTEN_BACKLOG_DEFAULT 511 1328#define LISTEN_BACKLOG_DEFAULT 511
1334#endif 1329#endif
1335 1330
1336 /** 1331 /**
1337 * Backlog argument to use for listen. See 1332 * Backlog argument to use for listen. See
1338 * #MHD_daemon_listen_backlog(). 1333 * #MHD_daemon_listen_backlog().
1339 */ 1334 */
1340 int listen_backlog; 1335 int listen_backlog;
1341 1336
1342 /** 1337 /**
1343 * Default queue length to use with fast open. 1338 * Default queue length to use with fast open.
1344 */ 1339 */
@@ -1373,8 +1368,8 @@ struct MHD_Daemon
1373 * Default timeout in seconds for idle connections. 1368 * Default timeout in seconds for idle connections.
1374 */ 1369 */
1375 time_t connection_default_timeout; 1370 time_t connection_default_timeout;
1376 1371
1377 /** 1372 /**
1378 * Listen socket we should use, MHD_INVALID_SOCKET means 1373 * Listen socket we should use, MHD_INVALID_SOCKET means
1379 * we are to initialize the socket from the other options given. 1374 * we are to initialize the socket from the other options given.
1380 */ 1375 */
@@ -1407,23 +1402,23 @@ struct MHD_Daemon
1407#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 1402#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
1408 1403
1409#endif 1404#endif
1410 1405
1411 /** 1406 /**
1412 * Inter-thread communication channel. 1407 * Inter-thread communication channel.
1413 */ 1408 */
1414 struct MHD_itc_ itc; 1409 struct MHD_itc_ itc;
1415 1410
1416 /** 1411 /**
1417 * Which threading model do we use? Postive 1412 * Which threading model do we use? Postive
1418 * numbers indicate the number of worker threads to be used. 1413 * numbers indicate the number of worker threads to be used.
1419 * Values larger than 1 imply a thread pool. 1414 * Values larger than 1 imply a thread pool.
1420 */ 1415 */
1421 enum MHD_ThreadingModel threading_model; 1416 enum MHD_ThreadingModel threading_model;
1422 1417
1423 /** 1418 /**
1424 * When should we use TCP_FASTOPEN? 1419 * When should we use TCP_FASTOPEN?
1425 * See #MHD_daemon_tcp_fastopen(). 1420 * See #MHD_daemon_tcp_fastopen().
1426 */ 1421 */
1427 enum MHD_FastOpenMethod fast_open_method; 1422 enum MHD_FastOpenMethod fast_open_method;
1428 1423
1429 /** 1424 /**
@@ -1445,36 +1440,36 @@ struct MHD_Daemon
1445 */ 1440 */
1446 enum MHD_ProtocolStrictLevel protocol_strict_level; 1441 enum MHD_ProtocolStrictLevel protocol_strict_level;
1447 1442
1448 /** 1443 /**
1449 * On which port should we listen on? Only effective if we were not 1444 * On which port should we listen on? Only effective if we were not
1450 * given a listen socket or a full address via 1445 * given a listen socket or a full address via
1451 * #MHD_daemon_bind_sa(). 0 means to bind to random free port. 1446 * #MHD_daemon_bind_sa(). 0 means to bind to random free port.
1452 */ 1447 */
1453 uint16_t listen_port; 1448 uint16_t listen_port;
1454 1449
1455 /** 1450 /**
1456 * Suppress generating the "Date:" header, this system 1451 * Suppress generating the "Date:" header, this system
1457 * lacks an RTC (or developer is hyper-optimizing). See 1452 * lacks an RTC (or developer is hyper-optimizing). See
1458 * #MHD_daemon_suppress_date_no_clock(). 1453 * #MHD_daemon_suppress_date_no_clock().
1459 */ 1454 */
1460 bool suppress_date; 1455 bool suppress_date;
1461 1456
1462 /** 1457 /**
1463 * The use of the inter-thread communication channel is disabled. 1458 * The use of the inter-thread communication channel is disabled.
1464 * See #MHD_daemon_disable_itc(). 1459 * See #MHD_daemon_disable_itc().
1465 */ 1460 */
1466 bool disable_itc; 1461 bool disable_itc;
1467 1462
1468 /** 1463 /**
1469 * Disable #MHD_action_suspend() functionality. See 1464 * Disable #MHD_action_suspend() functionality. See
1470 * #MHD_daemon_disallow_suspend_resume(). 1465 * #MHD_daemon_disallow_suspend_resume().
1471 */ 1466 */
1472 bool disallow_suspend_resume; 1467 bool disallow_suspend_resume;
1473 1468
1474 /** 1469 /**
1475 * Disable #MHD_action_upgrade() functionality. See 1470 * Disable #MHD_action_upgrade() functionality. See
1476 * #MHD_daemon_disallow_upgrade(). 1471 * #MHD_daemon_disallow_upgrade().
1477 */ 1472 */
1478 bool disallow_upgrade; 1473 bool disallow_upgrade;
1479 1474
1480 /** 1475 /**
@@ -1523,12 +1518,12 @@ struct MHD_Daemon
1523 * MHD should speak SHOUTcast instead of HTTP. 1518 * MHD should speak SHOUTcast instead of HTTP.
1524 */ 1519 */
1525 bool enable_shoutcast; 1520 bool enable_shoutcast;
1526 1521
1527 /** 1522 /**
1528 * Are we shutting down? 1523 * Are we shutting down?
1529 */ 1524 */
1530 volatile bool shutdown; 1525 volatile bool shutdown;
1531 1526
1532}; 1527};
1533 1528
1534 1529
@@ -1559,9 +1554,9 @@ struct MHD_Action
1559 1554
1560 /** 1555 /**
1561 * Closure for @a action 1556 * Closure for @a action
1562 */ 1557 */
1563 void *action_cls; 1558 void *action_cls;
1564 1559
1565}; 1560};
1566 1561
1567 1562
@@ -1577,7 +1572,7 @@ struct MHD_Response
1577 * must be the first field in a response! 1572 * must be the first field in a response!
1578 */ 1573 */
1579 struct MHD_Action action; 1574 struct MHD_Action action;
1580 1575
1581 /** 1576 /**
1582 * Headers to send for the response. Initially 1577 * Headers to send for the response. Initially
1583 * the linked list is created in inverse order; 1578 * the linked list is created in inverse order;
@@ -1610,7 +1605,7 @@ struct MHD_Response
1610 MHD_ContentReaderFreeCallback crfc; 1605 MHD_ContentReaderFreeCallback crfc;
1611 1606
1612 /** 1607 /**
1613 * Function to call once MHD is finished with 1608 * Function to call once MHD is finished with
1614 * the request, may be NULL. 1609 * the request, may be NULL.
1615 */ 1610 */
1616 MHD_RequestTerminationCallback termination_cb; 1611 MHD_RequestTerminationCallback termination_cb;
@@ -1619,7 +1614,7 @@ struct MHD_Response
1619 * Closure for @e termination_cb. 1614 * Closure for @e termination_cb.
1620 */ 1615 */
1621 void *termination_cb_cls; 1616 void *termination_cb_cls;
1622 1617
1623#ifdef UPGRADE_SUPPORT 1618#ifdef UPGRADE_SUPPORT
1624 /** 1619 /**
1625 * Application function to call once we are done sending the headers 1620 * Application function to call once we are done sending the headers
@@ -1671,7 +1666,7 @@ struct MHD_Response
1671 * HTTP status code of the response. 1666 * HTTP status code of the response.
1672 */ 1667 */
1673 enum MHD_HTTP_StatusCode status_code; 1668 enum MHD_HTTP_StatusCode status_code;
1674 1669
1675 /** 1670 /**
1676 * Reference count for this response. Free once the counter hits 1671 * Reference count for this response. Free once the counter hits
1677 * zero. 1672 * zero.
@@ -1692,7 +1687,7 @@ struct MHD_Response
1692 * Use ShoutCAST format. 1687 * Use ShoutCAST format.
1693 */ 1688 */
1694 bool icy; 1689 bool icy;
1695 1690
1696}; 1691};
1697 1692
1698 1693
diff --git a/src/lib/request_info.c b/src/lib/request_info.c
index a7342e0a..5f481d98 100644
--- a/src/lib/request_info.c
+++ b/src/lib/request_info.c
@@ -48,7 +48,7 @@ MHD_request_get_information_sz (struct MHD_Request *request,
48{ 48{
49#define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \ 49#define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \
50 return MHD_NO 50 return MHD_NO
51 51
52 switch (info_type) 52 switch (info_type)
53 { 53 {
54 case MHD_REQUEST_INFORMATION_CONNECTION: 54 case MHD_REQUEST_INFORMATION_CONNECTION:
@@ -70,8 +70,7 @@ MHD_request_get_information_sz (struct MHD_Request *request,
70 case MHD_REQUEST_INFORMATION_HEADER_SIZE: 70 case MHD_REQUEST_INFORMATION_HEADER_SIZE:
71 CHECK_SIZE (size_t); 71 CHECK_SIZE (size_t);
72 if ( (MHD_REQUEST_HEADERS_RECEIVED > request->state) || 72 if ( (MHD_REQUEST_HEADERS_RECEIVED > request->state) ||
73 (MHD_REQUEST_CLOSED == request->state) || 73 (MHD_REQUEST_CLOSED == request->state) )
74 (MHD_REQUEST_IN_CLEANUP == request->state) )
75 return MHD_NO; /* invalid, too early! */ 74 return MHD_NO; /* invalid, too early! */
76 return_value->header_size = request->header_size; 75 return_value->header_size = request->header_size;
77 return MHD_YES; 76 return MHD_YES;
@@ -79,7 +78,7 @@ MHD_request_get_information_sz (struct MHD_Request *request,
79 default: 78 default:
80 return MHD_NO; 79 return MHD_NO;
81 } 80 }
82 81
83#undef CHECK_SIZE 82#undef CHECK_SIZE
84} 83}
85 84
diff --git a/src/lib/request_resume.c b/src/lib/request_resume.c
index 5742f6ac..b4bd651e 100644
--- a/src/lib/request_resume.c
+++ b/src/lib/request_resume.c
@@ -159,8 +159,6 @@ MHD_resume_suspended_connections_ (struct MHD_Daemon *daemon)
159 /* Data forwarding was finished (for TLS connections) AND 159 /* Data forwarding was finished (for TLS connections) AND
160 * application was closed upgraded connection. 160 * application was closed upgraded connection.
161 * Insert connection into cleanup list. */ 161 * Insert connection into cleanup list. */
162 MHD_connection_close_ (pos,
163 MHD_CONNECTION_NOTIFY_CLOSED);
164 DLL_insert (daemon->cleanup_head, 162 DLL_insert (daemon->cleanup_head,
165 daemon->cleanup_tail, 163 daemon->cleanup_tail,
166 pos); 164 pos);
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 691aa427..d8d12c70 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1948,9 +1948,6 @@ MHD_connection_update_event_loop_info (struct MHD_Connection *connection)
1948 case MHD_CONNECTION_CLOSED: 1948 case MHD_CONNECTION_CLOSED:
1949 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; 1949 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
1950 return; /* do nothing, not even reading */ 1950 return; /* do nothing, not even reading */
1951 case MHD_CONNECTION_IN_CLEANUP:
1952 mhd_assert (0);
1953 break;
1954#ifdef UPGRADE_SUPPORT 1951#ifdef UPGRADE_SUPPORT
1955 case MHD_CONNECTION_UPGRADE: 1952 case MHD_CONNECTION_UPGRADE:
1956 mhd_assert (0); 1953 mhd_assert (0);
@@ -3151,9 +3148,6 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
3151 return; 3148 return;
3152 case MHD_CONNECTION_CLOSED: 3149 case MHD_CONNECTION_CLOSED:
3153 return; 3150 return;
3154 case MHD_CONNECTION_IN_CLEANUP:
3155 mhd_assert (0);
3156 return;
3157#ifdef UPGRADE_SUPPORT 3151#ifdef UPGRADE_SUPPORT
3158 case MHD_CONNECTION_UPGRADE: 3152 case MHD_CONNECTION_UPGRADE:
3159 mhd_assert (0); 3153 mhd_assert (0);
@@ -3857,8 +3851,7 @@ MHD_get_connection_info (struct MHD_Connection *connection,
3857 return (const union MHD_ConnectionInfo *) &connection->connection_timeout_dummy; 3851 return (const union MHD_ConnectionInfo *) &connection->connection_timeout_dummy;
3858 case MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE: 3852 case MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE:
3859 if ( (MHD_CONNECTION_HEADERS_RECEIVED > connection->state) || 3853 if ( (MHD_CONNECTION_HEADERS_RECEIVED > connection->state) ||
3860 (MHD_CONNECTION_CLOSED == connection->state) || 3854 (MHD_CONNECTION_CLOSED == connection->state) )
3861 (MHD_CONNECTION_IN_CLEANUP == connection->state) )
3862 return NULL; /* invalid, too early! */ 3855 return NULL; /* invalid, too early! */
3863 return (const union MHD_ConnectionInfo *) &connection->header_size; 3856 return (const union MHD_ConnectionInfo *) &connection->header_size;
3864 default: 3857 default:
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 14cc0121..24fbe082 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2066,21 +2066,18 @@ thread_main_handle_connection (void *data)
2066 } 2066 }
2067#endif /* UPGRADE_SUPPORT */ 2067#endif /* UPGRADE_SUPPORT */
2068 } 2068 }
2069 if (MHD_CONNECTION_IN_CLEANUP != con->state)
2070 {
2071#if DEBUG_CLOSE 2069#if DEBUG_CLOSE
2072#ifdef HAVE_MESSAGES 2070#ifdef HAVE_MESSAGES
2073 MHD_DLOG (con->daemon, 2071 MHD_DLOG (con->daemon,
2074 _("Processing thread terminating. Closing connection\n")); 2072 _("Processing thread terminating. Closing connection\n"));
2075#endif 2073#endif
2076#endif 2074#endif
2077 if (MHD_CONNECTION_CLOSED != con->state) 2075 if (MHD_CONNECTION_CLOSED != con->state)
2078 MHD_connection_close_ (con, 2076 MHD_connection_close_ (con,
2079 (daemon->shutdown) ? 2077 (daemon->shutdown) ?
2080 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN: 2078 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN:
2081 MHD_REQUEST_TERMINATED_WITH_ERROR); 2079 MHD_REQUEST_TERMINATED_WITH_ERROR);
2082 MHD_connection_handle_idle (con); 2080 MHD_connection_handle_idle (con);
2083 }
2084exit: 2081exit:
2085 if (NULL != con->response) 2082 if (NULL != con->response)
2086 { 2083 {
@@ -2790,8 +2787,6 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
2790 /* Data forwarding was finished (for TLS connections) AND 2787 /* Data forwarding was finished (for TLS connections) AND
2791 * application was closed upgraded connection. 2788 * application was closed upgraded connection.
2792 * Insert connection into cleanup list. */ 2789 * Insert connection into cleanup list. */
2793 MHD_connection_close_ (pos,
2794 MHD_REQUEST_TERMINATED_COMPLETED_OK);
2795 DLL_insert (daemon->cleanup_head, 2790 DLL_insert (daemon->cleanup_head,
2796 daemon->cleanup_tail, 2791 daemon->cleanup_tail,
2797 pos); 2792 pos);
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 5668a8f8..01f2dbea 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -507,11 +507,6 @@ enum MHD_CONNECTION_STATE
507 */ 507 */
508 MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1, 508 MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1,
509 509
510 /**
511 * 20: This connection is finished (only to be freed)
512 */
513 MHD_CONNECTION_IN_CLEANUP = MHD_CONNECTION_CLOSED + 1,
514
515#ifdef UPGRADE_SUPPORT 510#ifdef UPGRADE_SUPPORT
516 /** 511 /**
517 * Connection was "upgraded" and socket is now under the 512 * Connection was "upgraded" and socket is now under the