diff options
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r-- | src/daemon/daemon.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 34a94922..950239a6 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -597,32 +597,35 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
597 | prev = NULL; | 597 | prev = NULL; |
598 | while (pos != NULL) | 598 | while (pos != NULL) |
599 | { | 599 | { |
600 | if (pos->socket_fd == -1) | 600 | if ( (pos->socket_fd == -1) || |
601 | { | 601 | ( ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
602 | (daemon->shutdown) && | ||
603 | (pos->socket_fd != -1) ) ) ) | ||
604 | { | ||
602 | if (prev == NULL) | 605 | if (prev == NULL) |
603 | daemon->connections = pos->next; | 606 | daemon->connections = pos->next; |
604 | else | 607 | else |
605 | prev->next = pos->next; | 608 | prev->next = pos->next; |
606 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 609 | if (0 != (pos->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
607 | { | 610 | { |
608 | pthread_kill (pos->pid, SIGALRM); | 611 | pthread_kill (pos->pid, SIGALRM); |
609 | pthread_join (pos->pid, &unused); | 612 | pthread_join (pos->pid, &unused); |
610 | } | 613 | } |
611 | MHD_destroy_response (pos->response); | 614 | MHD_destroy_response (pos->response); |
612 | MHD_pool_destroy (pos->pool); | 615 | MHD_pool_destroy (pos->pool); |
613 | #if HTTPS_SUPPORT | 616 | #if HTTPS_SUPPORT |
614 | if (pos->tls_session != NULL) | 617 | if (pos->tls_session != NULL) |
615 | MHD_gnutls_deinit (pos->tls_session); | 618 | MHD_gnutls_deinit (pos->tls_session); |
616 | #endif | 619 | #endif |
617 | free (pos->addr); | 620 | free (pos->addr); |
618 | free (pos); | 621 | free (pos); |
619 | daemon->max_connections++; | 622 | daemon->max_connections++; |
620 | if (prev == NULL) | 623 | if (prev == NULL) |
621 | pos = daemon->connections; | 624 | pos = daemon->connections; |
622 | else | 625 | else |
623 | pos = prev->next; | 626 | pos = prev->next; |
624 | continue; | 627 | continue; |
625 | } | 628 | } |
626 | prev = pos; | 629 | prev = pos; |
627 | pos = pos->next; | 630 | pos = pos->next; |
628 | } | 631 | } |