commit e0c14df575785d06c22b28ecc9433e2b5d7a69d7
parent 48b38bdbbea2ce2b7ea6aabfbbf95c54ad8cb014
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 9 Oct 2016 18:43:27 +0000
-fix locking issue
Diffstat:
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
@@ -2460,8 +2460,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
MHD_mutex_lock_ (&response->mutex);
if (MHD_YES != try_ready_normal_body (connection))
{
- if (NULL != response->crc)
- MHD_mutex_unlock_ (&response->mutex);
+ /* mutex was already unlocked by try_ready_normal_body */
break;
}
data_write_offset = connection->response_write_position
@@ -2925,6 +2924,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
socket_start_no_buffering (connection);
break;
}
+ /* mutex was already unlocked by "try_ready_normal_body */
/* not ready, no socket action */
break;
case MHD_CONNECTION_CHUNKED_BODY_READY:
@@ -2950,7 +2950,6 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
/* Buffering for flushable socket was already enabled */
if (MHD_NO == socket_flush_possible (connection))
socket_start_no_buffering (connection);
-
continue;
}
if (NULL != connection->response->crc)
diff --git a/src/microhttpd/mhd_locks.h b/src/microhttpd/mhd_locks.h
@@ -82,9 +82,8 @@
* @param pmutex pointer to mutex
*/
#define MHD_mutex_destroy_(pmutex) do { \
- if ( (0 != pthread_mutex_destroy((pmutex))) && \
- (EAGAIN != errno) && \
- (EINPROGRESS != errno) ) \
+ errno = 0; \
+ if (0 != pthread_mutex_destroy((pmutex))) \
MHD_PANIC (_("Failed to destroy mutex\n")); \
} while (0)
#elif defined(MHD_W32_MUTEX_)