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.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index a009cddf..6963c228 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3683,12 +3683,16 @@ MHD_update_last_activity_ (struct MHD_Connection *connection)
3683 3683
3684/** 3684/**
3685 * This function handles a particular connection when it has been 3685 * This function handles a particular connection when it has been
3686 * determined that there is data to be read off a socket. 3686 * determined that there is data to be read off a socket. All
3687 * implementations (multithreaded, external polling, internal polling)
3688 * call this function to handle reads.
3687 * 3689 *
3688 * @param connection connection to handle 3690 * @param connection connection to handle
3691 * @param socket_error set to true if socket error was detected
3689 */ 3692 */
3690void 3693void
3691MHD_connection_handle_read (struct MHD_Connection *connection) 3694MHD_connection_handle_read (struct MHD_Connection *connection,
3695 bool socket_error)
3692{ 3696{
3693 ssize_t bytes_read; 3697 ssize_t bytes_read;
3694 3698
@@ -3721,10 +3725,15 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
3721 [connection->read_buffer_offset], 3725 [connection->read_buffer_offset],
3722 connection->read_buffer_size 3726 connection->read_buffer_size
3723 - connection->read_buffer_offset); 3727 - connection->read_buffer_offset);
3724 if (bytes_read < 0) 3728 if ((bytes_read < 0) || socket_error)
3725 { 3729 {
3726 if (MHD_ERR_AGAIN_ == bytes_read) 3730 if ((MHD_ERR_AGAIN_ == bytes_read) && ! socket_error)
3727 return; /* No new data to process. */ 3731 return; /* No new data to process. */
3732 if ((bytes_read > 0) && connection->sk_nonblck)
3733 { /* Try to detect the socket error */
3734 int dummy;
3735 bytes_read = connection->recv_cls (connection, &dummy, sizeof (dummy));
3736 }
3728 if (MHD_ERR_CONNRESET_ == bytes_read) 3737 if (MHD_ERR_CONNRESET_ == bytes_read)
3729 { 3738 {
3730 if ( (MHD_CONNECTION_INIT < connection->state) && 3739 if ( (MHD_CONNECTION_INIT < connection->state) &&
@@ -3746,7 +3755,8 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
3746 MHD_DLOG (connection->daemon, 3755 MHD_DLOG (connection->daemon,
3747 _ ("Connection socket is closed when reading " \ 3756 _ ("Connection socket is closed when reading " \
3748 "request due to the error: %s\n"), 3757 "request due to the error: %s\n"),
3749 str_conn_error_ (bytes_read)); 3758 (bytes_read < 0) ? str_conn_error_ (bytes_read) :
3759 "detected connection closure");
3750#endif 3760#endif
3751 CONNECTION_CLOSE_ERROR (connection, 3761 CONNECTION_CLOSE_ERROR (connection,
3752 NULL); 3762 NULL);