diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 1a75eb28..7157d6d1 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -317,7 +317,9 @@ connection_close_error (struct MHD_Connection *connection, | |||
317 | * #MHD_NO). | 317 | * #MHD_NO). |
318 | * | 318 | * |
319 | * @param connection the connection | 319 | * @param connection the connection |
320 | * @return #MHD_NO if readying the response failed | 320 | * @return #MHD_NO if readying the response failed (the |
321 | * lock on the response will have been released already | ||
322 | * in this case). | ||
321 | */ | 323 | */ |
322 | static int | 324 | static int |
323 | try_ready_normal_body (struct MHD_Connection *connection) | 325 | try_ready_normal_body (struct MHD_Connection *connection) |
@@ -364,8 +366,10 @@ try_ready_normal_body (struct MHD_Connection *connection) | |||
364 | { | 366 | { |
365 | /* either error or http 1.0 transfer, close socket! */ | 367 | /* either error or http 1.0 transfer, close socket! */ |
366 | response->total_size = connection->response_write_position; | 368 | response->total_size = connection->response_write_position; |
369 | if (NULL != response->crc) | ||
370 | pthread_mutex_unlock (&response->mutex); | ||
367 | if (MHD_CONTENT_READER_END_OF_STREAM == ret) | 371 | if (MHD_CONTENT_READER_END_OF_STREAM == ret) |
368 | MHD_connection_close (connection, MHD_REQUEST_TERMINATED_COMPLETD_OK); | 372 | MHD_connection_close (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); |
369 | else | 373 | else |
370 | CONNECTION_CLOSE_ERROR (connection, | 374 | CONNECTION_CLOSE_ERROR (connection, |
371 | "Closing connection (stream error)\n"); | 375 | "Closing connection (stream error)\n"); |
@@ -376,6 +380,8 @@ try_ready_normal_body (struct MHD_Connection *connection) | |||
376 | if (0 == ret) | 380 | if (0 == ret) |
377 | { | 381 | { |
378 | connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; | 382 | connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; |
383 | if (NULL != response->crc) | ||
384 | pthread_mutex_unlock (&response->mutex); | ||
379 | return MHD_NO; | 385 | return MHD_NO; |
380 | } | 386 | } |
381 | return MHD_YES; | 387 | return MHD_YES; |
@@ -1978,12 +1984,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1978 | response = connection->response; | 1984 | response = connection->response; |
1979 | if (response->crc != NULL) | 1985 | if (response->crc != NULL) |
1980 | pthread_mutex_lock (&response->mutex); | 1986 | pthread_mutex_lock (&response->mutex); |
1981 | if (MHD_YES != try_ready_normal_body (connection)) | 1987 | if (MHD_YES != try_ready_normal_body (connection)) |
1982 | { | 1988 | break; |
1983 | if (response->crc != NULL) | ||
1984 | pthread_mutex_unlock (&response->mutex); | ||
1985 | break; | ||
1986 | } | ||
1987 | ret = connection->send_cls (connection, | 1989 | ret = connection->send_cls (connection, |
1988 | &response->data | 1990 | &response->data |
1989 | [connection->response_write_position | 1991 | [connection->response_write_position |
@@ -2351,8 +2353,6 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2351 | } | 2353 | } |
2352 | if (MHD_YES == try_ready_normal_body (connection)) | 2354 | if (MHD_YES == try_ready_normal_body (connection)) |
2353 | { | 2355 | { |
2354 | if (connection->response->crc != NULL) | ||
2355 | pthread_mutex_unlock (&connection->response->mutex); | ||
2356 | connection->state = MHD_CONNECTION_NORMAL_BODY_READY; | 2356 | connection->state = MHD_CONNECTION_NORMAL_BODY_READY; |
2357 | break; | 2357 | break; |
2358 | } | 2358 | } |