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.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 414c4b17..26bf6cc0 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1583,7 +1583,9 @@ do_read (struct MHD_Connection *connection)
1583 connection->read_buffer_offset); 1583 connection->read_buffer_offset);
1584 if (bytes_read < 0) 1584 if (bytes_read < 0)
1585 { 1585 {
1586 if ((EINTR == errno) || (EAGAIN == errno) || (ECONNRESET == errno)) 1586 const int err = MHD_socket_errno_;
1587 if ((EINTR == err) || (EAGAIN == err) || (ECONNRESET == err)
1588 || (EWOULDBLOCK == err))
1587 return MHD_NO; 1589 return MHD_NO;
1588#if HAVE_MESSAGES 1590#if HAVE_MESSAGES
1589#if HTTPS_SUPPORT 1591#if HTTPS_SUPPORT
@@ -1595,7 +1597,7 @@ do_read (struct MHD_Connection *connection)
1595#endif 1597#endif
1596 MHD_DLOG (connection->daemon, 1598 MHD_DLOG (connection->daemon,
1597 "Failed to receive data: %s\n", 1599 "Failed to receive data: %s\n",
1598 STRERROR (errno)); 1600 MHD_socket_last_strerr_ ());
1599#endif 1601#endif
1600 CONNECTION_CLOSE_ERROR (connection, NULL); 1602 CONNECTION_CLOSE_ERROR (connection, NULL);
1601 return MHD_YES; 1603 return MHD_YES;
@@ -1636,7 +1638,8 @@ do_write (struct MHD_Connection *connection)
1636 1638
1637 if (ret < 0) 1639 if (ret < 0)
1638 { 1640 {
1639 if ((EINTR == errno) || (EAGAIN == errno)) 1641 const int err = MHD_socket_errno_;
1642 if ((EINTR == err) || (EAGAIN == err) || (EWOULDBLOCK == err))
1640 return MHD_NO; 1643 return MHD_NO;
1641#if HAVE_MESSAGES 1644#if HAVE_MESSAGES
1642#if HTTPS_SUPPORT 1645#if HTTPS_SUPPORT
@@ -1647,7 +1650,7 @@ do_write (struct MHD_Connection *connection)
1647 else 1650 else
1648#endif 1651#endif
1649 MHD_DLOG (connection->daemon, 1652 MHD_DLOG (connection->daemon,
1650 "Failed to send data: %s\n", STRERROR (errno)); 1653 "Failed to send data: %s\n", MHD_socket_last_strerr_ ());
1651#endif 1654#endif
1652 CONNECTION_CLOSE_ERROR (connection, NULL); 1655 CONNECTION_CLOSE_ERROR (connection, NULL);
1653 return MHD_YES; 1656 return MHD_YES;
@@ -2022,12 +2025,13 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
2022 connection->continue_message_write_offset); 2025 connection->continue_message_write_offset);
2023 if (ret < 0) 2026 if (ret < 0)
2024 { 2027 {
2025 if ((errno == EINTR) || (errno == EAGAIN)) 2028 const int err = MHD_socket_errno_;
2029 if ((err == EINTR) || (err == EAGAIN) || (EWOULDBLOCK == err))
2026 break; 2030 break;
2027#if HAVE_MESSAGES 2031#if HAVE_MESSAGES
2028 MHD_DLOG (connection->daemon, 2032 MHD_DLOG (connection->daemon,
2029 "Failed to send data: %s\n", 2033 "Failed to send data: %s\n",
2030 STRERROR (errno)); 2034 MHD_socket_last_strerr_ ());
2031#endif 2035#endif
2032 CONNECTION_CLOSE_ERROR (connection, NULL); 2036 CONNECTION_CLOSE_ERROR (connection, NULL);
2033 return MHD_YES; 2037 return MHD_YES;
@@ -2068,6 +2072,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
2068 response->data_size - 2072 response->data_size -
2069 (connection->response_write_position 2073 (connection->response_write_position
2070 - response->data_start)); 2074 - response->data_start));
2075 const int err = MHD_socket_errno_;
2071#if DEBUG_SEND_DATA 2076#if DEBUG_SEND_DATA
2072 if (ret > 0) 2077 if (ret > 0)
2073 FPRINTF (stderr, 2078 FPRINTF (stderr,
@@ -2080,12 +2085,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
2080 pthread_mutex_unlock (&response->mutex); 2085 pthread_mutex_unlock (&response->mutex);
2081 if (ret < 0) 2086 if (ret < 0)
2082 { 2087 {
2083 if ((errno == EINTR) || (errno == EAGAIN)) 2088 if ((err == EINTR) || (err == EAGAIN) || (EWOULDBLOCK == err))
2084 return MHD_YES; 2089 return MHD_YES;
2085#if HAVE_MESSAGES 2090#if HAVE_MESSAGES
2086 MHD_DLOG (connection->daemon, 2091 MHD_DLOG (connection->daemon,
2087 "Failed to send data: %s\n", 2092 "Failed to send data: %s\n",
2088 STRERROR (errno)); 2093 MHD_socket_last_strerr_ ());
2089#endif 2094#endif
2090 CONNECTION_CLOSE_ERROR (connection, NULL); 2095 CONNECTION_CLOSE_ERROR (connection, NULL);
2091 return MHD_YES; 2096 return MHD_YES;
@@ -2658,7 +2663,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection)
2658 if (0 != (daemon->options & MHD_USE_DEBUG)) 2663 if (0 != (daemon->options & MHD_USE_DEBUG))
2659 MHD_DLOG (daemon, 2664 MHD_DLOG (daemon,
2660 "Call to epoll_ctl failed: %s\n", 2665 "Call to epoll_ctl failed: %s\n",
2661 STRERROR (errno)); 2666 MHD_socket_last_strerr_ ());
2662#endif 2667#endif
2663 connection->state = MHD_CONNECTION_CLOSED; 2668 connection->state = MHD_CONNECTION_CLOSED;
2664 cleanup_connection (connection); 2669 cleanup_connection (connection);