aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_threads.c')
-rw-r--r--src/microhttpd/mhd_threads.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/microhttpd/mhd_threads.c b/src/microhttpd/mhd_threads.c
index dffbfd00..477080cf 100644
--- a/src/microhttpd/mhd_threads.c
+++ b/src/microhttpd/mhd_threads.c
@@ -38,14 +38,6 @@
38#include <errno.h> 38#include <errno.h>
39 39
40 40
41
42#if defined(MHD_USE_POSIX_THREADS)
43typedef pthread_t MHD_thread_ID_;
44#elif defined(MHD_USE_W32_THREADS)
45typedef DWORD MHD_thread_ID_;
46#endif
47
48
49#ifndef MHD_USE_THREAD_NAME_ 41#ifndef MHD_USE_THREAD_NAME_
50 42
51#define MHD_set_thread_name_(t, n) (void) 43#define MHD_set_thread_name_(t, n) (void)
@@ -183,7 +175,7 @@ MHD_set_thread_name_(const MHD_thread_ID_ thread_id,
183 * @return non-zero on success; zero otherwise (with errno set) 175 * @return non-zero on success; zero otherwise (with errno set)
184 */ 176 */
185int 177int
186MHD_create_thread_ (MHD_thread_handle_ *thread, 178MHD_create_thread_ (MHD_thread_handle_ID_ *thread,
187 size_t stack_size, 179 size_t stack_size,
188 MHD_THREAD_START_ROUTINE_ start_routine, 180 MHD_THREAD_START_ROUTINE_ start_routine,
189 void *arg) 181 void *arg)
@@ -200,7 +192,7 @@ MHD_create_thread_ (MHD_thread_handle_ *thread,
200 res = pthread_attr_setstacksize (&attr, 192 res = pthread_attr_setstacksize (&attr,
201 stack_size); 193 stack_size);
202 if (0 == res) 194 if (0 == res)
203 res = pthread_create (thread, 195 res = pthread_create (&(thread->handle),
204 &attr, 196 &attr,
205 start_routine, 197 start_routine,
206 arg); 198 arg);
@@ -208,7 +200,7 @@ MHD_create_thread_ (MHD_thread_handle_ *thread,
208 } 200 }
209 } 201 }
210 else 202 else
211 res = pthread_create (thread, 203 res = pthread_create (&(thread->handle),
212 NULL, 204 NULL,
213 start_routine, 205 start_routine,
214 arg); 206 arg);
@@ -218,6 +210,7 @@ MHD_create_thread_ (MHD_thread_handle_ *thread,
218 210
219 return !res; 211 return !res;
220#elif defined(MHD_USE_W32_THREADS) 212#elif defined(MHD_USE_W32_THREADS)
213 unsigned int thread_ID;
221#if SIZE_MAX != UINT_MAX 214#if SIZE_MAX != UINT_MAX
222 if (stack_size > UINT_MAX) 215 if (stack_size > UINT_MAX)
223 { 216 {
@@ -226,15 +219,18 @@ MHD_create_thread_ (MHD_thread_handle_ *thread,
226 } 219 }
227#endif /* SIZE_MAX != UINT_MAX */ 220#endif /* SIZE_MAX != UINT_MAX */
228 221
229 *thread = (HANDLE) _beginthreadex (NULL, 222 thread->handle = (MHD_thread_handle_)
223 _beginthreadex (NULL,
230 (unsigned int) stack_size, 224 (unsigned int) stack_size,
231 start_routine, 225 start_routine,
232 arg, 226 arg,
233 0, 227 0,
234 NULL); 228 &thread_ID);
235 if ((MHD_thread_handle_)-1 == (*thread)) 229
230 if ((MHD_thread_handle_)-1 == thread->handle)
236 return 0; 231 return 0;
237 232
233 thread->ID = (MHD_thread_ID_)thread_ID;
238 return !0; 234 return !0;
239#endif 235#endif
240} 236}
@@ -294,7 +290,7 @@ named_thread_starter (void *data)
294 * @return non-zero on success; zero otherwise (with errno set) 290 * @return non-zero on success; zero otherwise (with errno set)
295 */ 291 */
296int 292int
297MHD_create_named_thread_ (MHD_thread_handle_ *thread, 293MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread,
298 const char* thread_name, 294 const char* thread_name,
299 size_t stack_size, 295 size_t stack_size,
300 MHD_THREAD_START_ROUTINE_ start_routine, 296 MHD_THREAD_START_ROUTINE_ start_routine,
@@ -323,7 +319,7 @@ MHD_create_named_thread_ (MHD_thread_handle_ *thread,
323 res = pthread_attr_setstacksize (&attr, 319 res = pthread_attr_setstacksize (&attr,
324 stack_size); 320 stack_size);
325 if (0 == res) 321 if (0 == res)
326 res = pthread_create (thread, 322 res = pthread_create (&(thread->handle),
327 &attr, 323 &attr,
328 start_routine, 324 start_routine,
329 arg); 325 arg);