diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 6bb17d80..1121772a 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2466,13 +2466,16 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2466 | continue; | 2466 | continue; |
2467 | if (NULL == connection->response) | 2467 | if (NULL == connection->response) |
2468 | break; /* try again next time */ | 2468 | break; /* try again next time */ |
2469 | (void) MHD_mutex_lock_ (&connection->response->mutex); | ||
2469 | if (MHD_NO == build_header_response (connection)) | 2470 | if (MHD_NO == build_header_response (connection)) |
2470 | { | 2471 | { |
2471 | /* oops - close! */ | 2472 | /* oops - close! */ |
2473 | (void) MHD_mutex_unlock_ (&connection->response->mutex); | ||
2472 | CONNECTION_CLOSE_ERROR (connection, | 2474 | CONNECTION_CLOSE_ERROR (connection, |
2473 | "Closing connection (failed to create response header)\n"); | 2475 | "Closing connection (failed to create response header)\n"); |
2474 | continue; | 2476 | continue; |
2475 | } | 2477 | } |
2478 | (void) MHD_mutex_unlock_ (&connection->response->mutex); | ||
2476 | connection->state = MHD_CONNECTION_HEADERS_SENDING; | 2479 | connection->state = MHD_CONNECTION_HEADERS_SENDING; |
2477 | 2480 | ||
2478 | #if HAVE_DECL_TCP_CORK | 2481 | #if HAVE_DECL_TCP_CORK |
@@ -2539,7 +2542,16 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2539 | (void) MHD_mutex_unlock_ (&connection->response->mutex); | 2542 | (void) MHD_mutex_unlock_ (&connection->response->mutex); |
2540 | break; | 2543 | break; |
2541 | case MHD_CONNECTION_BODY_SENT: | 2544 | case MHD_CONNECTION_BODY_SENT: |
2542 | build_header_response (connection); | 2545 | (void) MHD_mutex_lock_ (&connection->response->mutex); |
2546 | if (MHD_NO == build_header_response (connection)) | ||
2547 | { | ||
2548 | /* oops - close! */ | ||
2549 | (void) MHD_mutex_unlock_ (&connection->response->mutex); | ||
2550 | CONNECTION_CLOSE_ERROR (connection, | ||
2551 | "Closing connection (failed to create response header)\n"); | ||
2552 | continue; | ||
2553 | } | ||
2554 | (void) MHD_mutex_unlock_ (&connection->response->mutex); | ||
2543 | if ( (MHD_NO == connection->have_chunked_upload) || | 2555 | if ( (MHD_NO == connection->have_chunked_upload) || |
2544 | (connection->write_buffer_send_offset == | 2556 | (connection->write_buffer_send_offset == |
2545 | connection->write_buffer_append_offset) ) | 2557 | connection->write_buffer_append_offset) ) |