diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-04-01 06:16:16 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-04-01 06:16:16 +0000 |
commit | 5f9dfdb2b7663611df85e9d4b9d26d777a3bdd52 (patch) | |
tree | 82247cd166241f855f9a760549b3b8c1d31f1bd6 /src/microhttpd/response.c | |
parent | 60d4fbee43fdb6abb2f122017bdb0e084fa4a9c6 (diff) | |
download | libmicrohttpd-5f9dfdb2b7663611df85e9d4b9d26d777a3bdd52.tar.gz libmicrohttpd-5f9dfdb2b7663611df85e9d4b9d26d777a3bdd52.zip |
Use MHD mutex macros
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r-- | src/microhttpd/response.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index abaa64ca..ad05c5fb 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -27,6 +27,13 @@ | |||
27 | #include "internal.h" | 27 | #include "internal.h" |
28 | #include "response.h" | 28 | #include "response.h" |
29 | 29 | ||
30 | #if defined(_WIN32) && defined(MHD_W32_MUTEX_) | ||
31 | #ifndef WIN32_LEAN_AND_MEAN | ||
32 | #define WIN32_LEAN_AND_MEAN 1 | ||
33 | #endif /* !WIN32_LEAN_AND_MEAN */ | ||
34 | #include <windows.h> | ||
35 | #endif /* _WIN32 && MHD_W32_MUTEX_ */ | ||
36 | |||
30 | 37 | ||
31 | /** | 38 | /** |
32 | * Add a header or footer line to the response. | 39 | * Add a header or footer line to the response. |
@@ -244,7 +251,7 @@ MHD_create_response_from_callback (uint64_t size, | |||
244 | response->fd = -1; | 251 | response->fd = -1; |
245 | response->data = (void *) &response[1]; | 252 | response->data = (void *) &response[1]; |
246 | response->data_buffer_size = block_size; | 253 | response->data_buffer_size = block_size; |
247 | if (0 != pthread_mutex_init (&response->mutex, NULL)) | 254 | if (MHD_YES != MHD_mutex_create_ (&response->mutex)) |
248 | { | 255 | { |
249 | free (response); | 256 | free (response); |
250 | return NULL; | 257 | return NULL; |
@@ -381,7 +388,7 @@ MHD_create_response_from_data (size_t size, | |||
381 | return NULL; | 388 | return NULL; |
382 | memset (response, 0, sizeof (struct MHD_Response)); | 389 | memset (response, 0, sizeof (struct MHD_Response)); |
383 | response->fd = -1; | 390 | response->fd = -1; |
384 | if (0 != pthread_mutex_init (&response->mutex, NULL)) | 391 | if (MHD_YES != MHD_mutex_create_ (&response->mutex)) |
385 | { | 392 | { |
386 | free (response); | 393 | free (response); |
387 | return NULL; | 394 | return NULL; |
@@ -390,7 +397,7 @@ MHD_create_response_from_data (size_t size, | |||
390 | { | 397 | { |
391 | if (NULL == (tmp = malloc (size))) | 398 | if (NULL == (tmp = malloc (size))) |
392 | { | 399 | { |
393 | pthread_mutex_destroy (&response->mutex); | 400 | MHD_mutex_destroy_ (&response->mutex); |
394 | free (response); | 401 | free (response); |
395 | return NULL; | 402 | return NULL; |
396 | } | 403 | } |
@@ -447,14 +454,14 @@ MHD_destroy_response (struct MHD_Response *response) | |||
447 | 454 | ||
448 | if (NULL == response) | 455 | if (NULL == response) |
449 | return; | 456 | return; |
450 | pthread_mutex_lock (&response->mutex); | 457 | MHD_mutex_lock_ (&response->mutex); |
451 | if (0 != --(response->reference_count)) | 458 | if (0 != --(response->reference_count)) |
452 | { | 459 | { |
453 | pthread_mutex_unlock (&response->mutex); | 460 | MHD_mutex_unlock_ (&response->mutex); |
454 | return; | 461 | return; |
455 | } | 462 | } |
456 | pthread_mutex_unlock (&response->mutex); | 463 | MHD_mutex_unlock_ (&response->mutex); |
457 | pthread_mutex_destroy (&response->mutex); | 464 | MHD_mutex_destroy_ (&response->mutex); |
458 | if (response->crfc != NULL) | 465 | if (response->crfc != NULL) |
459 | response->crfc (response->crc_cls); | 466 | response->crfc (response->crc_cls); |
460 | while (NULL != response->first_header) | 467 | while (NULL != response->first_header) |
@@ -472,9 +479,9 @@ MHD_destroy_response (struct MHD_Response *response) | |||
472 | void | 479 | void |
473 | MHD_increment_response_rc (struct MHD_Response *response) | 480 | MHD_increment_response_rc (struct MHD_Response *response) |
474 | { | 481 | { |
475 | pthread_mutex_lock (&response->mutex); | 482 | MHD_mutex_lock_ (&response->mutex); |
476 | (response->reference_count)++; | 483 | (response->reference_count)++; |
477 | pthread_mutex_unlock (&response->mutex); | 484 | MHD_mutex_unlock_ (&response->mutex); |
478 | } | 485 | } |
479 | 486 | ||
480 | 487 | ||