aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-25 21:51:08 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-25 21:51:08 +0000
commit74e0a68567054b20e24ea79fecf1ccf2940fda9b (patch)
tree156175b745c6ced5d7b80cc0d647a23d90ddd4a6
parent015495e47128fa1d31ad2106a60b9654fe6e0666 (diff)
downloadlibmicrohttpd-74e0a68567054b20e24ea79fecf1ccf2940fda9b.tar.gz
libmicrohttpd-74e0a68567054b20e24ea79fecf1ccf2940fda9b.zip
-fixes to MHD_suspend_connection
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog5
-rw-r--r--configure.ac2
-rw-r--r--src/microhttpd/connection.c7
-rw-r--r--src/microhttpd/daemon.c91
-rw-r--r--src/microhttpd/internal.h8
6 files changed, 68 insertions, 46 deletions
diff --git a/AUTHORS b/AUTHORS
index 88b81698..258759c4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -44,6 +44,7 @@ Brecht Sanders <brecht@sanders.org>
44Jan Janak <jan@janakj.org> 44Jan Janak <jan@janakj.org>
45Matthew Mundell <matthew.mundell@greenbone.net> 45Matthew Mundell <matthew.mundell@greenbone.net>
46Scott Goldman <scottjg@github.com> 46Scott Goldman <scottjg@github.com>
47Jared Cantwell
47 48
48Documentation contributions also came from: 49Documentation contributions also came from:
49Marco Maggi <marco.maggi-ipsu@poste.it> 50Marco Maggi <marco.maggi-ipsu@poste.it>
diff --git a/ChangeLog b/ChangeLog
index 158a045d..46eeb380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
1Sun Nov 24 13:41:15 CET 2013
2 Introduce state to mark connections in suspended state (with
3 epoll); add missing locking operations in MHD_suspend_connection.
4 Fix definition of MHD_TLS_CONNECTION_INIT. -MH/JC
5
1Wed Oct 30 09:34:20 CET 2013 6Wed Oct 30 09:34:20 CET 2013
2 Fixing issue in PostProcessor when getting partial boundary 7 Fixing issue in PostProcessor when getting partial boundary
3 at the beginning, expanding test suite. -CG 8 at the beginning, expanding test suite. -CG
diff --git a/configure.ac b/configure.ac
index 4c3f588d..f387b9e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
22# 22#
23AC_PREREQ(2.57) 23AC_PREREQ(2.57)
24AC_INIT([libmicrohttpd], [0.9.31],[libmicrohttpd@gnu.org]) 24AC_INIT([libmicrohttpd], [0.9.31],[libmicrohttpd@gnu.org])
25AM_INIT_AUTOMAKE([silent-rules serial-tests]) 25AM_INIT_AUTOMAKE([silent-rules])
26AC_CONFIG_HEADERS([MHD_config.h]) 26AC_CONFIG_HEADERS([MHD_config.h])
27AC_CONFIG_MACRO_DIR([m4]) 27AC_CONFIG_MACRO_DIR([m4])
28AH_TOP([#define _GNU_SOURCE 1]) 28AH_TOP([#define _GNU_SOURCE 1])
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 63df4b94..858540c2 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2474,6 +2474,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2474 { 2474 {
2475 case MHD_EVENT_LOOP_INFO_READ: 2475 case MHD_EVENT_LOOP_INFO_READ:
2476 if ( (0 != (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) && 2476 if ( (0 != (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) &&
2477 (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) &&
2477 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) ) 2478 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) )
2478 { 2479 {
2479 EDLL_insert (daemon->eready_head, 2480 EDLL_insert (daemon->eready_head,
@@ -2485,6 +2486,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2485 case MHD_EVENT_LOOP_INFO_WRITE: 2486 case MHD_EVENT_LOOP_INFO_WRITE:
2486 if ( (connection->read_buffer_size > connection->read_buffer_offset) && 2487 if ( (connection->read_buffer_size > connection->read_buffer_offset) &&
2487 (0 != (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) && 2488 (0 != (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) &&
2489 (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) &&
2488 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) ) 2490 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) )
2489 { 2491 {
2490 EDLL_insert (daemon->eready_head, 2492 EDLL_insert (daemon->eready_head,
@@ -2493,6 +2495,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2493 connection->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; 2495 connection->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL;
2494 } 2496 }
2495 if ( (0 != (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) && 2497 if ( (0 != (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) &&
2498 (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) &&
2496 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) ) 2499 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) )
2497 { 2500 {
2498 EDLL_insert (daemon->eready_head, 2501 EDLL_insert (daemon->eready_head,
@@ -2504,7 +2507,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2504 case MHD_EVENT_LOOP_INFO_BLOCK: 2507 case MHD_EVENT_LOOP_INFO_BLOCK:
2505 /* we should look at this connection again in the next iteration 2508 /* we should look at this connection again in the next iteration
2506 of the event loop, as we're waiting on the application */ 2509 of the event loop, as we're waiting on the application */
2507 if (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 2510 if ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) &&
2511 (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED))) )
2508 { 2512 {
2509 EDLL_insert (daemon->eready_head, 2513 EDLL_insert (daemon->eready_head,
2510 daemon->eready_tail, 2514 daemon->eready_tail,
@@ -2539,6 +2543,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection)
2539 2543
2540 if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && 2544 if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) &&
2541 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) && 2545 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) &&
2546 (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) &&
2542 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) || 2547 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ||
2543 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) && 2548 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) &&
2544 ( (MHD_EVENT_LOOP_INFO_READ == connection->event_loop_info) || 2549 ( (MHD_EVENT_LOOP_INFO_READ == connection->event_loop_info) ||
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 61416a7b..219e822f 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1398,6 +1398,9 @@ MHD_suspend_connection (struct MHD_Connection *connection)
1398 daemon = connection->daemon; 1398 daemon = connection->daemon;
1399 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) 1399 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
1400 MHD_PANIC ("Cannot suspend connections in THREAD_PER_CONNECTION mode!\n"); 1400 MHD_PANIC ("Cannot suspend connections in THREAD_PER_CONNECTION mode!\n");
1401 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
1402 (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )
1403 MHD_PANIC ("Failed to acquire cleanup mutex\n");
1401 DLL_remove (daemon->connections_head, 1404 DLL_remove (daemon->connections_head,
1402 daemon->connections_tail, 1405 daemon->connections_tail,
1403 connection); 1406 connection);
@@ -1410,22 +1413,29 @@ MHD_suspend_connection (struct MHD_Connection *connection)
1410 daemon->manual_timeout_tail, 1413 daemon->manual_timeout_tail,
1411 connection); 1414 connection);
1412#if EPOLL_SUPPORT 1415#if EPOLL_SUPPORT
1413 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 1416 if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY))
1414 { 1417 {
1415 EDLL_remove (daemon->eready_head, 1418 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
1416 daemon->eready_tail, 1419 {
1417 connection); 1420 EDLL_remove (daemon->eready_head,
1418 } 1421 daemon->eready_tail,
1419 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) 1422 connection);
1420 { 1423 }
1421 if (0 != epoll_ctl (daemon->epoll_fd, 1424 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET))
1422 EPOLL_CTL_DEL, 1425 {
1423 connection->socket_fd, 1426 if (0 != epoll_ctl (daemon->epoll_fd,
1424 NULL)) 1427 EPOLL_CTL_DEL,
1425 MHD_PANIC ("Failed to remove FD from epoll set\n"); 1428 connection->socket_fd,
1426 connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; 1429 NULL))
1427 } 1430 MHD_PANIC ("Failed to remove FD from epoll set\n");
1431 connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET;
1432 }
1433 connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED;
1434 }
1428#endif 1435#endif
1436 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
1437 (0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) )
1438 MHD_PANIC ("Failed to release cleanup mutex\n");
1429} 1439}
1430 1440
1431 1441
@@ -1460,33 +1470,30 @@ MHD_resume_connection (struct MHD_Connection *connection)
1460 daemon->manual_timeout_tail, 1470 daemon->manual_timeout_tail,
1461 connection); 1471 connection);
1462#if EPOLL_SUPPORT 1472#if EPOLL_SUPPORT
1463 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 1473 if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY))
1464 { 1474 {
1465 EDLL_insert (daemon->eready_head, 1475 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
1466 daemon->eready_tail, 1476 {
1467 connection); 1477 EDLL_insert (daemon->eready_head,
1468 } 1478 daemon->eready_tail,
1469 else 1479 connection);
1470 { 1480 }
1471 struct epoll_event event; 1481 else
1472 1482 {
1473 event.events = EPOLLIN | EPOLLOUT | EPOLLET; 1483 struct epoll_event event;
1474 event.data.ptr = connection; 1484
1475 if (0 != epoll_ctl (daemon->epoll_fd, 1485 event.events = EPOLLIN | EPOLLOUT | EPOLLET;
1476 EPOLL_CTL_ADD, 1486 event.data.ptr = connection;
1477 connection->socket_fd, 1487 if (0 != epoll_ctl (daemon->epoll_fd,
1478 &event)) 1488 EPOLL_CTL_ADD,
1479 { 1489 connection->socket_fd,
1480#if HAVE_MESSAGES 1490 &event))
1481 MHD_DLOG (daemon, 1491 MHD_PANIC ("Failed to add FD to epoll set\n");
1482 "Call to epoll_ctl failed: %s\n", 1492 else
1483 STRERROR (errno)); 1493 connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET;
1484#endif 1494 }
1485 /* and now, good luck with this... */ 1495 connection->epoll_state &= ~MHD_EPOLL_STATE_SUSPENDED;
1486 } 1496 }
1487 else
1488 connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET;
1489 }
1490#endif 1497#endif
1491 if ( (-1 != daemon->wpipe[1]) && 1498 if ( (-1 != daemon->wpipe[1]) &&
1492 (1 != WRITE (daemon->wpipe[1], "n", 1)) ) 1499 (1 != WRITE (daemon->wpipe[1], "n", 1)) )
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index b540a1fc..adf2c660 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -116,8 +116,12 @@ enum MHD_EpollState
116 /** 116 /**
117 * Is this connection currently in the 'epoll' set? 117 * Is this connection currently in the 'epoll' set?
118 */ 118 */
119 MHD_EPOLL_STATE_IN_EPOLL_SET = 8 119 MHD_EPOLL_STATE_IN_EPOLL_SET = 8,
120 120
121 /**
122 * Is this connection currently suspended?
123 */
124 MHD_EPOLL_STATE_SUSPENDED = 16
121 }; 125 };
122 126
123 127
@@ -452,7 +456,7 @@ enum MHD_CONNECTION_STATE
452 * Handshake messages will be processed in this state & while 456 * Handshake messages will be processed in this state & while
453 * in the 'MHD_TLS_HELLO_REQUEST' state 457 * in the 'MHD_TLS_HELLO_REQUEST' state
454 */ 458 */
455 MHD_TLS_CONNECTION_INIT = MHD_CONNECTION_CLOSED + 1 459 MHD_TLS_CONNECTION_INIT = MHD_CONNECTION_IN_CLEANUP + 1
456 460
457}; 461};
458 462