aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 27bff077..eafcd98a 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1494,7 +1494,6 @@ do_read (struct MHD_Connection *connection)
1494 1494
1495 if (connection->read_buffer_size == connection->read_buffer_offset) 1495 if (connection->read_buffer_size == connection->read_buffer_offset)
1496 return MHD_NO; 1496 return MHD_NO;
1497
1498 bytes_read = connection->recv_cls (connection, 1497 bytes_read = connection->recv_cls (connection,
1499 &connection->read_buffer 1498 &connection->read_buffer
1500 [connection->read_buffer_offset], 1499 [connection->read_buffer_offset],
@@ -1520,11 +1519,11 @@ do_read (struct MHD_Connection *connection)
1520 } 1519 }
1521 if (0 == bytes_read) 1520 if (0 == bytes_read)
1522 { 1521 {
1523 /* other side closed connection */ 1522 /* other side closed connection; RFC 2616, section 8.1.4 suggests
1523 we should then shutdown ourselves as well. */
1524 connection->read_closed = MHD_YES; 1524 connection->read_closed = MHD_YES;
1525 /* shutdown is not required here, as the other side already 1525 MHD_connection_close (connection,
1526 knows; so flagging this internally should suffice */ 1526 MHD_REQUEST_TERMINATED_CLIENT_ABORT);
1527 /* SHUTDOWN (connection->socket_fd, SHUT_RD); */
1528 return MHD_YES; 1527 return MHD_YES;
1529 } 1528 }
1530 connection->read_buffer_offset += bytes_read; 1529 connection->read_buffer_offset += bytes_read;
@@ -2465,6 +2464,15 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2465 } 2464 }
2466 break; 2465 break;
2467 case MHD_EVENT_LOOP_INFO_WRITE: 2466 case MHD_EVENT_LOOP_INFO_WRITE:
2467 if ( (connection->read_buffer_size > connection->read_buffer_offset) &&
2468 (0 != (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) &&
2469 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) )
2470 {
2471 EDLL_insert (daemon->eready_head,
2472 daemon->eready_tail,
2473 connection);
2474 connection->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL;
2475 }
2468 if ( (0 != (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) && 2476 if ( (0 != (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) &&
2469 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) ) 2477 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) )
2470 { 2478 {
@@ -2498,8 +2506,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2498 2506
2499#if EPOLL_SUPPORT 2507#if EPOLL_SUPPORT
2500/** 2508/**
2501 * Perform epoll processing, possibly moving the connection back into 2509 * Perform epoll() processing, possibly moving the connection back into
2502 * the epoll set if needed. 2510 * the epoll() set if needed.
2503 * 2511 *
2504 * @param connection connection to process 2512 * @param connection connection to process
2505 * @return MHD_YES if we should continue to process the 2513 * @return MHD_YES if we should continue to process the
@@ -2514,7 +2522,8 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection)
2514 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) && 2522 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) &&
2515 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) || 2523 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ||
2516 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) && 2524 ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) &&
2517 (MHD_EVENT_LOOP_INFO_READ == connection->event_loop_info) && 2525 ( (MHD_EVENT_LOOP_INFO_READ == connection->event_loop_info) ||
2526 (connection->read_buffer_size > connection->read_buffer_offset) ) &&
2518 (MHD_NO == connection->read_closed) ) ) ) 2527 (MHD_NO == connection->read_closed) ) ) )
2519 { 2528 {
2520 /* add to epoll set */ 2529 /* add to epoll set */
@@ -2694,11 +2703,8 @@ MHD_queue_response (struct MHD_Connection *connection,
2694 (0 == strcasecmp (connection->method, 2703 (0 == strcasecmp (connection->method,
2695 MHD_HTTP_METHOD_PUT))) ) 2704 MHD_HTTP_METHOD_PUT))) )
2696 { 2705 {
2697 /* response was queued "early", 2706 /* response was queued "early", refuse to read body / footers or
2698 refuse to read body / footers or further 2707 further requests! */
2699 requests! */
2700 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
2701 (void) SHUTDOWN (connection->socket_fd, SHUT_RD);
2702 connection->read_closed = MHD_YES; 2708 connection->read_closed = MHD_YES;
2703 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; 2709 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
2704 } 2710 }