aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-01-27 17:21:48 +0000
committerChristian Grothoff <christian@grothoff.org>2010-01-27 17:21:48 +0000
commit5f12a6b18c43380806ad1180aadca7c676f584a4 (patch)
treeb6e0ae56968ccb89880a85964ca24ebf3e6b514c
parentab184006d70f70c647dbb9bae5df1e2003089e54 (diff)
downloadlibmicrohttpd-5f12a6b18c43380806ad1180aadca7c676f584a4.tar.gz
libmicrohttpd-5f12a6b18c43380806ad1180aadca7c676f584a4.zip
pthread_create may not always set errno, use return value instead
-rw-r--r--src/daemon/daemon.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 19180606..ab7c9057 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -655,7 +655,8 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
655#endif 655#endif
656 struct sockaddr *addr = (struct sockaddr *) &addrstorage; 656 struct sockaddr *addr = (struct sockaddr *) &addrstorage;
657 socklen_t addrlen; 657 socklen_t addrlen;
658 int s, res_thread_create; 658 int s;
659 int res_thread_create;
659#if OSX 660#if OSX
660 static int on = 1; 661 static int on = 1;
661#endif 662#endif
@@ -827,7 +828,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
827 { 828 {
828#if HAVE_MESSAGES 829#if HAVE_MESSAGES
829 MHD_DLOG (daemon, "Failed to create a thread: %s\n", 830 MHD_DLOG (daemon, "Failed to create a thread: %s\n",
830 STRERROR (errno)); 831 STRERROR (res_thread_create));
831#endif 832#endif
832 SHUTDOWN (s, SHUT_RDWR); 833 SHUTDOWN (s, SHUT_RDWR);
833 CLOSE (s); 834 CLOSE (s);
@@ -1601,15 +1602,15 @@ MHD_start_daemon_va (unsigned int options,
1601 return NULL; 1602 return NULL;
1602 } 1603 }
1603#endif 1604#endif
1604 if (((0 != (options & MHD_USE_THREAD_PER_CONNECTION)) || 1605 if ( ( (0 != (options & MHD_USE_THREAD_PER_CONNECTION)) ||
1605 ((0 != (options & MHD_USE_SELECT_INTERNALLY)) 1606 ( (0 != (options & MHD_USE_SELECT_INTERNALLY)) &&
1606 && (0 == retVal->worker_pool_size))) 1607 (0 == retVal->worker_pool_size)) ) &&
1607 && (0 != 1608 (0 != (res_thread_create =
1608 pthread_create (&retVal->pid, NULL, &MHD_select_thread, retVal))) 1609 pthread_create (&retVal->pid, NULL, &MHD_select_thread, retVal))))
1609 { 1610 {
1610#if HAVE_MESSAGES 1611#if HAVE_MESSAGES
1611 MHD_DLOG (retVal, 1612 MHD_DLOG (retVal,
1612 "Failed to create listen thread: %s\n", STRERROR (errno)); 1613 "Failed to create listen thread: %s\n", STRERROR (res_thread_create));
1613#endif 1614#endif
1614 pthread_mutex_destroy (&retVal->per_ip_connection_mutex); 1615 pthread_mutex_destroy (&retVal->per_ip_connection_mutex);
1615 free (retVal); 1616 free (retVal);
@@ -1682,11 +1683,12 @@ MHD_start_daemon_va (unsigned int options,
1682 ++d->max_connections; 1683 ++d->max_connections;
1683 1684
1684 /* Spawn the worker thread */ 1685 /* Spawn the worker thread */
1685 if (0 != pthread_create (&d->pid, NULL, &MHD_select_thread, d)) 1686 if (0 != (res_thread_create = pthread_create (&d->pid, NULL, &MHD_select_thread, d)))
1686 { 1687 {
1687#if HAVE_MESSAGES 1688#if HAVE_MESSAGES
1688 MHD_DLOG (retVal, 1689 MHD_DLOG (retVal,
1689 "Failed to create pool thread: %s\n", STRERROR (errno)); 1690 "Failed to create pool thread: %s\n",
1691 STRERROR (res_thread_create));
1690#endif 1692#endif
1691 /* Free memory for this worker; cleanup below handles 1693 /* Free memory for this worker; cleanup below handles
1692 * all previously-created workers. */ 1694 * all previously-created workers. */