diff options
author | Heikki Lindholm <holin@iki.fi> | 2009-03-27 20:36:20 +0000 |
---|---|---|
committer | Heikki Lindholm <holin@iki.fi> | 2009-03-27 20:36:20 +0000 |
commit | 7a2272bc5d736f7cf5a36d193251a88bd3c01b14 (patch) | |
tree | 669767c4439bcc3d6e92b4f29b810b62d0b3827d | |
parent | 490c0a25e917b0862396fb34c5066b36de6ae10c (diff) | |
download | libmicrohttpd-7a2272bc5d736f7cf5a36d193251a88bd3c01b14.tar.gz libmicrohttpd-7a2272bc5d736f7cf5a36d193251a88bd3c01b14.zip |
better fix for OS X stop_daemon issue
-rw-r--r-- | src/daemon/daemon.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 841e0d67..23b446f9 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -1423,6 +1423,20 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
1423 | daemon->worker_pool[i].socket_fd = -1; | 1423 | daemon->worker_pool[i].socket_fd = -1; |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | #if OSX | ||
1427 | /* without this, either (thread pool = 0) threads would get stuck or | ||
1428 | * CLOSE would get stuck if attempted before (thread pool > 0) | ||
1429 | * threads have ended */ | ||
1430 | SHUTDOWN (fd, SHUT_RDWR); | ||
1431 | #else | ||
1432 | #if DEBUG_CLOSE | ||
1433 | #if HAVE_MESSAGES | ||
1434 | MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n"); | ||
1435 | #endif | ||
1436 | #endif | ||
1437 | CLOSE (fd); | ||
1438 | #endif | ||
1439 | |||
1426 | /* Signal workers to stop and clean them up */ | 1440 | /* Signal workers to stop and clean them up */ |
1427 | for (i = 0; i < daemon->worker_pool_size; ++i) | 1441 | for (i = 0; i < daemon->worker_pool_size; ++i) |
1428 | pthread_kill (daemon->worker_pool[i].pid, SIGALRM); | 1442 | pthread_kill (daemon->worker_pool[i].pid, SIGALRM); |
@@ -1437,26 +1451,19 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
1437 | ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) | 1451 | ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) |
1438 | && (0 == daemon->worker_pool_size))) | 1452 | && (0 == daemon->worker_pool_size))) |
1439 | { | 1453 | { |
1440 | #if DEBUG_CLOSE | ||
1441 | #if HAVE_MESSAGES | ||
1442 | MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n"); | ||
1443 | #endif | ||
1444 | #endif | ||
1445 | CLOSE (fd); | ||
1446 | pthread_kill (daemon->pid, SIGALRM); | 1454 | pthread_kill (daemon->pid, SIGALRM); |
1447 | pthread_join (daemon->pid, &unused); | 1455 | pthread_join (daemon->pid, &unused); |
1448 | } | 1456 | } |
1449 | MHD_close_connections (daemon); | 1457 | MHD_close_connections (daemon); |
1450 | 1458 | ||
1451 | if (0 < daemon->worker_pool_size) | 1459 | #if OSX |
1452 | { | ||
1453 | #if DEBUG_CLOSE | 1460 | #if DEBUG_CLOSE |
1454 | #if HAVE_MESSAGES | 1461 | #if HAVE_MESSAGES |
1455 | MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n"); | 1462 | MHD_DLOG (daemon, "MHD shutdown, closing listen socket\n"); |
1456 | #endif | 1463 | #endif |
1457 | #endif | 1464 | #endif |
1458 | CLOSE (fd); | 1465 | CLOSE (fd); |
1459 | } | 1466 | #endif |
1460 | 1467 | ||
1461 | /* TLS clean up */ | 1468 | /* TLS clean up */ |
1462 | #if HTTPS_SUPPORT | 1469 | #if HTTPS_SUPPORT |