libmicrohttpd

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

commit 2dd1b43e09ad97149f6cc0aa4bdd6cc0942841df
parent b155d866625132f978e4e1af4bcfd5a4e365a5a5
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 29 Jan 2018 17:35:15 +0100

fix #5260 as suggested by reporter

Diffstat:
MChangeLog | 4++++
Msrc/include/microhttpd.h | 2+-
Msrc/microhttpd/connection.c | 5++++-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jan 29 17:33:54 CET 2018 + Fix deadlock when failing to prepare chunked response + (#5260). -CG/ghaderer + Thu Jan 4 12:24:33 CET 2018 Fix __clang_major__ related warnings for non-clang compilers reported by Tim on the mailinglist. -CG diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -126,7 +126,7 @@ typedef intptr_t ssize_t; * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00095800 +#define MHD_VERSION 0x00095801 /** * MHD-internal return code for "YES". diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -1155,6 +1155,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) size /= 2; if (size < 128) { + MHD_mutex_unlock_chk_ (&response->mutex); /* not enough memory */ CONNECTION_CLOSE_ERROR (connection, _("Closing connection (out of memory)\n")); @@ -1200,6 +1201,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) { /* error, close socket! */ response->total_size = connection->response_write_position; + MHD_mutex_unlock_chk_ (&response->mutex); CONNECTION_CLOSE_ERROR (connection, _("Closing connection (application error generating response)\n")); return MHD_NO; @@ -1218,6 +1220,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) if (0 == ret) { connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY; + MHD_mutex_unlock_chk_ (&response->mutex); return MHD_NO; } if (ret > 0xFFFFFF) @@ -3593,7 +3596,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) socket_start_no_buffering (connection); continue; } - MHD_mutex_unlock_chk_ (&connection->response->mutex); + /* mutex was already unlocked by try_ready_chunked_body */ break; case MHD_CONNECTION_BODY_SENT: if (MHD_NO == build_header_response (connection))