commit c36962f2c19a8d97f4faa0446b93984a75842c8e
parent 41be6325c89377b9a2d9aff1493c3d4fb62e0fb4
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 21 Sep 2011 07:58:16 +0000
fix
Diffstat:
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Sep 21 09:53:18 CEST 2011
+ Reverting to using pipes for signalling select on non-Linux
+ platforms where shutdown-on-listen-sockets does not work. -WB/CG
+
Mon Sep 19 14:06:30 CEST 2011
Fixing problem introduced with prompt response cleanup code. -CG
diff --git a/configure.ac b/configure.ac
@@ -85,6 +85,7 @@ case "$host_os" in
;;
linux*)
AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
+ AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets])
AM_CONDITIONAL(HAVE_GNU_LD, true)
AM_CONDITIONAL(HAVE_W32, false)
;;
@@ -116,6 +117,7 @@ netbsd*)
;;
*arm-linux*)
AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux system])
+ AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets])
CFLAGS="-D_REENTRANT -fPIC -pipe $CFLAGS"
AM_CONDITIONAL(HAVE_GNU_LD, true)
AM_CONDITIONAL(HAVE_W32, false)
@@ -147,6 +149,10 @@ netbsd*)
*)
AC_MSG_RESULT(Unrecognised OS $host_os)
AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
+# You might want to find out if your OS supports shutdown on listen sockets,
+# and extend the switch statement; if we do not have 'HAVE_LISTEN_SHUTDOWN',
+# pipes are used instead to signal 'select'.
+# AC_DEFINE_UNQUOTED(HAVE_LISTEN_SHUTDOWN,1,[can use shutdown on listen sockets])
AM_CONDITIONAL(HAVE_GNU_LD, false)
AM_CONDITIONAL(HAVE_W32, false)
;;
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
@@ -2517,23 +2517,24 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
int fd;
unsigned int i;
int rc;
- char c;
if (daemon == NULL)
return;
daemon->shutdown = MHD_YES;
fd = daemon->socket_fd;
daemon->socket_fd = -1;
- if (daemon->wpipe[1] != -1)
- write (daemon->wpipe[1], "e", 1);
-
/* Prepare workers for shutdown */
for (i = 0; i < daemon->worker_pool_size; ++i)
{
daemon->worker_pool[i].shutdown = MHD_YES;
daemon->worker_pool[i].socket_fd = -1;
}
+#ifdef HAVE_LISTEN_SHUTDOWN
SHUTDOWN (fd, SHUT_RDWR);
+#else
+ if (daemon->wpipe[1] != -1)
+ write (daemon->wpipe[1], "e", 1);
+#endif
#if DEBUG_CLOSE
#if HAVE_MESSAGES
MHD_DLOG (daemon, "MHD listen socket shutdown\n");
@@ -2608,6 +2609,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
#ifndef HAVE_LISTEN_SHUTDOWN
if (daemon->wpipe[1] != -1)
{
+ char c;
+
/* just to be sure, remove the one char we
wrote into the pipe */
(void) read (daemon->wpipe[0], &c, 1);