diff options
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r-- | src/daemon/daemon.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 8119dfbf..afa4630e 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -773,15 +773,12 @@ create_thread (pthread_t * thread, | |||
773 | 773 | ||
774 | if (daemon->thread_stack_size != 0) | 774 | if (daemon->thread_stack_size != 0) |
775 | { | 775 | { |
776 | if ( (0 != (ret = pthread_attr_init (&attr))) || | 776 | if (0 != (ret = pthread_attr_init (&attr))) |
777 | (0 != (ret = pthread_attr_setstacksize (&attr, daemon->thread_stack_size))) ) | 777 | goto ERR; |
778 | if (0 != (ret = pthread_attr_setstacksize (&attr, daemon->thread_stack_size))) | ||
778 | { | 779 | { |
779 | #if HAVE_MESSAGES | 780 | pthread_attr_destroy (&attr); |
780 | MHD_DLOG (daemon, | 781 | goto ERR; |
781 | "Failed to set thread stack size\n"); | ||
782 | #endif | ||
783 | errno = EINVAL; | ||
784 | return ret; | ||
785 | } | 782 | } |
786 | pattr = &attr; | 783 | pattr = &attr; |
787 | } | 784 | } |
@@ -791,9 +788,16 @@ create_thread (pthread_t * thread, | |||
791 | } | 788 | } |
792 | ret = pthread_create (thread, pattr, | 789 | ret = pthread_create (thread, pattr, |
793 | start_routine, arg); | 790 | start_routine, arg); |
794 | if (pattr != NULL) | 791 | if (daemon->thread_stack_size != 0) |
795 | pthread_attr_destroy (&attr); | 792 | pthread_attr_destroy (&attr); |
796 | return ret; | 793 | return ret; |
794 | ERR: | ||
795 | #if HAVE_MESSAGES | ||
796 | MHD_DLOG (daemon, | ||
797 | "Failed to set thread stack size\n"); | ||
798 | #endif | ||
799 | errno = EINVAL; | ||
800 | return ret; | ||
797 | } | 801 | } |
798 | 802 | ||
799 | 803 | ||
@@ -1760,6 +1764,8 @@ MHD_start_daemon_va (unsigned int options, | |||
1760 | MHD_DLOG (retVal, | 1764 | MHD_DLOG (retVal, |
1761 | "MHD poll support only works with MHD_USE_THREAD_PER_CONNECTION\n"); | 1765 | "MHD poll support only works with MHD_USE_THREAD_PER_CONNECTION\n"); |
1762 | #endif | 1766 | #endif |
1767 | free (retVal->nnc); | ||
1768 | pthread_mutex_destroy (&retVal->nnc_lock); | ||
1763 | free (retVal); | 1769 | free (retVal); |
1764 | return NULL; | 1770 | return NULL; |
1765 | } | 1771 | } |
@@ -1945,6 +1951,10 @@ MHD_start_daemon_va (unsigned int options, | |||
1945 | "Failed to initialize TLS support\n"); | 1951 | "Failed to initialize TLS support\n"); |
1946 | #endif | 1952 | #endif |
1947 | CLOSE (socket_fd); | 1953 | CLOSE (socket_fd); |
1954 | #ifdef DAUTH_SUPPORT | ||
1955 | pthread_mutex_destroy (&retVal->nnc_lock); | ||
1956 | free (retVal->nnc); | ||
1957 | #endif | ||
1948 | pthread_mutex_destroy (&retVal->per_ip_connection_mutex); | 1958 | pthread_mutex_destroy (&retVal->per_ip_connection_mutex); |
1949 | free (retVal); | 1959 | free (retVal); |
1950 | return NULL; | 1960 | return NULL; |
@@ -1961,6 +1971,10 @@ MHD_start_daemon_va (unsigned int options, | |||
1961 | "Failed to create listen thread: %s\n", | 1971 | "Failed to create listen thread: %s\n", |
1962 | STRERROR (res_thread_create)); | 1972 | STRERROR (res_thread_create)); |
1963 | #endif | 1973 | #endif |
1974 | #ifdef DAUTH_SUPPORT | ||
1975 | pthread_mutex_destroy (&retVal->nnc_lock); | ||
1976 | free (retVal->nnc); | ||
1977 | #endif | ||
1964 | pthread_mutex_destroy (&retVal->per_ip_connection_mutex); | 1978 | pthread_mutex_destroy (&retVal->per_ip_connection_mutex); |
1965 | free (retVal); | 1979 | free (retVal); |
1966 | CLOSE (socket_fd); | 1980 | CLOSE (socket_fd); |