libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit d686cb083345e50e5ce1f5de14fad756fe827a59
parent 961df2c72cddd5bc92dfa2ec9eb07d34515a99f1
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 27 Feb 2017 00:24:14 +0300

Fixed: EINTERRUPTED and GNUTLS_E_INTERRUPTED must not clear read/write ready flag

Diffstat:
Msrc/microhttpd/daemon.c | 33++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -436,7 +436,8 @@ recv_tls_adapter (struct MHD_Connection *connection, { MHD_socket_set_error_ (MHD_SCKT_EINTR_); #ifdef EPOLL_SUPPORT - connection->epoll_state &= ~MHD_EPOLL_STATE_READ_READY; + if (GNUTLS_E_AGAIN == res) + connection->epoll_state &= ~MHD_EPOLL_STATE_READ_READY; #endif return -1; } @@ -480,7 +481,8 @@ send_tls_adapter (struct MHD_Connection *connection, { MHD_socket_set_error_ (MHD_SCKT_EINTR_); #ifdef EPOLL_SUPPORT - connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; + if (GNUTLS_E_AGAIN == res) + connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; #endif return -1; } @@ -1068,11 +1070,8 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) res = gnutls_record_recv (connection->tls_session, &urh->in_buffer[urh->in_buffer_used], buf_size); - if ( (GNUTLS_E_AGAIN == res) || - (GNUTLS_E_INTERRUPTED == res) ) - { - urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; - } + if (GNUTLS_E_AGAIN == res) + urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; else if (res > 0) { urh->in_buffer_used += res; @@ -1081,7 +1080,8 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) connection->tls_read_ready = true; } } - else if (0 >= res) + else if ( (0 >= res ) && + (GNUTLS_E_INTERRUPTED != res) ) { /* Connection was shut down or got unrecoverable error. * signal by shrinking buffer so no more attempts will be @@ -1107,10 +1107,10 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) { int err = MHD_socket_get_error_ (); - if ( (MHD_SCKT_ERR_IS_EINTR_ (err)) || - (MHD_SCKT_ERR_IS_EAGAIN_ (err)) ) + if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; - else if (! MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)) + else if ( (! MHD_SCKT_ERR_IS_EINTR_ (err)) && + (! MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)) ) { /* persistent / unrecoverable error, treat as if connection was shut down. @@ -1178,10 +1178,10 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) else { const int err = MHD_socket_get_error_ (); - if ( (MHD_SCKT_ERR_IS_EINTR_ (err)) || - (MHD_SCKT_ERR_IS_EAGAIN_ (err)) ) + if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; - else if (! MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)) + else if ( (! MHD_SCKT_ERR_IS_EINTR_ (err)) && + (! MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)) ) { /* persistent / unrecoverable error, treat as if connection was shut down */ @@ -1216,8 +1216,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) res = gnutls_record_send (connection->tls_session, urh->out_buffer, data_size); - if ( (GNUTLS_E_AGAIN == res) || - (GNUTLS_E_INTERRUPTED == res) ) + if (GNUTLS_E_AGAIN == res) { urh->app.celi &= ~MHD_EPOLL_STATE_WRITE_READY; } @@ -1235,7 +1234,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) urh->out_buffer_used = 0; } } - else + else if (GNUTLS_E_INTERRUPTED != res) { /* persistent / unrecoverable error, treat as if connection was shut down.