commit 60cdf5f9e638e0831eda1feac857e8a940e155a6
parent 8a9bb841b8aa936072a0f52898de8433b3434f21
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Tue, 26 Oct 2021 13:16:59 +0300
chunked responses: alway unlock response if closing the connection
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
@@ -1135,7 +1135,7 @@ try_ready_chunked_body (struct MHD_Connection *connection,
_ ("Closing connection (out of memory)."));
return MHD_NO;
}
- /* Limit the buffer size to the large usable size for chunks */
+ /* Limit the buffer size to the largest usable size for chunks */
if ( (max_chunk + max_chunk_overhead) < size)
size = max_chunk + max_chunk_overhead;
connection->write_buffer = MHD_pool_reallocate (connection->pool,
@@ -1183,6 +1183,9 @@ try_ready_chunked_body (struct MHD_Connection *connection,
{
if (NULL == response->crc)
{ /* There is no way to reach this code */
+#if defined(MHD_USE_THREADS)
+ MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
CONNECTION_CLOSE_ERROR (connection,
_ ("No callback for the chunked data."));
return MHD_NO;
@@ -1222,6 +1225,9 @@ try_ready_chunked_body (struct MHD_Connection *connection,
}
if (size_to_fill < (size_t) ret)
{
+#if defined(MHD_USE_THREADS)
+ MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
CONNECTION_CLOSE_ERROR (connection,
_ ("Closing connection (application returned " \
"more data than requested)."));