From afb221c32aeeb2731e3b5362cc4ff8949d34edea Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Wed, 15 Mar 2017 21:34:59 +0300 Subject: [PATCH] Improved thread-safety with suspended connections. --- src/microhttpd/connection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 0d55fb3c..40182c4e 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -2404,7 +2404,8 @@ int MHD_connection_handle_read (struct MHD_Connection *connection) { update_last_activity (connection); - if (MHD_CONNECTION_CLOSED == connection->state) + if ( (MHD_CONNECTION_CLOSED == connection->state) || + (connection->suspended) ) return MHD_YES; /* make sure "read" has a reasonable number of bytes in buffer to use per system call (if possible) */ @@ -2474,6 +2475,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection) { struct MHD_Response *response; ssize_t ret; + if (connection->suspended) + return MHD_YES; update_last_activity (connection); while (1)