diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 91 |
1 files changed, 49 insertions, 42 deletions
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)) ) |