diff options
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r-- | src/microhttpd/response.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 29edef4f..263f8303 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -350,11 +350,13 @@ MHD_create_response_from_callback (uint64_t size, | |||
350 | response->fd = -1; | 350 | response->fd = -1; |
351 | response->data = (void *) &response[1]; | 351 | response->data = (void *) &response[1]; |
352 | response->data_buffer_size = block_size; | 352 | response->data_buffer_size = block_size; |
353 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
353 | if (! MHD_mutex_init_ (&response->mutex)) | 354 | if (! MHD_mutex_init_ (&response->mutex)) |
354 | { | 355 | { |
355 | free (response); | 356 | free (response); |
356 | return NULL; | 357 | return NULL; |
357 | } | 358 | } |
359 | #endif | ||
358 | response->crc = crc; | 360 | response->crc = crc; |
359 | response->crfc = crfc; | 361 | response->crfc = crfc; |
360 | response->crc_cls = crc_cls; | 362 | response->crc_cls = crc_cls; |
@@ -649,16 +651,20 @@ MHD_create_response_from_data (size_t size, | |||
649 | if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response)))) | 651 | if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response)))) |
650 | return NULL; | 652 | return NULL; |
651 | response->fd = -1; | 653 | response->fd = -1; |
654 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
652 | if (! MHD_mutex_init_ (&response->mutex)) | 655 | if (! MHD_mutex_init_ (&response->mutex)) |
653 | { | 656 | { |
654 | free (response); | 657 | free (response); |
655 | return NULL; | 658 | return NULL; |
656 | } | 659 | } |
660 | #endif | ||
657 | if ((must_copy) && (size > 0)) | 661 | if ((must_copy) && (size > 0)) |
658 | { | 662 | { |
659 | if (NULL == (tmp = malloc (size))) | 663 | if (NULL == (tmp = malloc (size))) |
660 | { | 664 | { |
665 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
661 | MHD_mutex_destroy_chk_ (&response->mutex); | 666 | MHD_mutex_destroy_chk_ (&response->mutex); |
667 | #endif | ||
662 | free (response); | 668 | free (response); |
663 | return NULL; | 669 | return NULL; |
664 | } | 670 | } |
@@ -1084,11 +1090,13 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, | |||
1084 | response = MHD_calloc_ (1, sizeof (struct MHD_Response)); | 1090 | response = MHD_calloc_ (1, sizeof (struct MHD_Response)); |
1085 | if (NULL == response) | 1091 | if (NULL == response) |
1086 | return NULL; | 1092 | return NULL; |
1093 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
1087 | if (! MHD_mutex_init_ (&response->mutex)) | 1094 | if (! MHD_mutex_init_ (&response->mutex)) |
1088 | { | 1095 | { |
1089 | free (response); | 1096 | free (response); |
1090 | return NULL; | 1097 | return NULL; |
1091 | } | 1098 | } |
1099 | #endif | ||
1092 | response->upgrade_handler = upgrade_handler; | 1100 | response->upgrade_handler = upgrade_handler; |
1093 | response->upgrade_handler_cls = upgrade_handler_cls; | 1101 | response->upgrade_handler_cls = upgrade_handler_cls; |
1094 | response->total_size = MHD_SIZE_UNKNOWN; | 1102 | response->total_size = MHD_SIZE_UNKNOWN; |
@@ -1122,14 +1130,20 @@ MHD_destroy_response (struct MHD_Response *response) | |||
1122 | 1130 | ||
1123 | if (NULL == response) | 1131 | if (NULL == response) |
1124 | return; | 1132 | return; |
1133 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
1125 | MHD_mutex_lock_chk_ (&response->mutex); | 1134 | MHD_mutex_lock_chk_ (&response->mutex); |
1135 | #endif | ||
1126 | if (0 != --(response->reference_count)) | 1136 | if (0 != --(response->reference_count)) |
1127 | { | 1137 | { |
1138 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
1128 | MHD_mutex_unlock_chk_ (&response->mutex); | 1139 | MHD_mutex_unlock_chk_ (&response->mutex); |
1140 | #endif | ||
1129 | return; | 1141 | return; |
1130 | } | 1142 | } |
1143 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
1131 | MHD_mutex_unlock_chk_ (&response->mutex); | 1144 | MHD_mutex_unlock_chk_ (&response->mutex); |
1132 | MHD_mutex_destroy_chk_ (&response->mutex); | 1145 | MHD_mutex_destroy_chk_ (&response->mutex); |
1146 | #endif | ||
1133 | if (NULL != response->crfc) | 1147 | if (NULL != response->crfc) |
1134 | response->crfc (response->crc_cls); | 1148 | response->crfc (response->crc_cls); |
1135 | while (NULL != response->first_header) | 1149 | while (NULL != response->first_header) |
@@ -1152,9 +1166,13 @@ MHD_destroy_response (struct MHD_Response *response) | |||
1152 | void | 1166 | void |
1153 | MHD_increment_response_rc (struct MHD_Response *response) | 1167 | MHD_increment_response_rc (struct MHD_Response *response) |
1154 | { | 1168 | { |
1169 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
1155 | MHD_mutex_lock_chk_ (&response->mutex); | 1170 | MHD_mutex_lock_chk_ (&response->mutex); |
1171 | #endif | ||
1156 | (response->reference_count)++; | 1172 | (response->reference_count)++; |
1173 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | ||
1157 | MHD_mutex_unlock_chk_ (&response->mutex); | 1174 | MHD_mutex_unlock_chk_ (&response->mutex); |
1175 | #endif | ||
1158 | } | 1176 | } |
1159 | 1177 | ||
1160 | 1178 | ||