[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5048 - libmicrohttpd/src/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5048 - libmicrohttpd/src/daemon |
Date: |
Wed, 13 Jun 2007 18:37:55 -0600 (MDT) |
Author: grothoff
Date: 2007-06-13 18:37:55 -0600 (Wed, 13 Jun 2007)
New Revision: 5048
Modified:
libmicrohttpd/src/daemon/daemon.c
libmicrohttpd/src/daemon/daemontest1.c
libmicrohttpd/src/daemon/internal.h
Log:
stop nicely
Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c 2007-06-14 00:26:06 UTC (rev 5047)
+++ libmicrohttpd/src/daemon/daemon.c 2007-06-14 00:37:55 UTC (rev 5048)
@@ -286,8 +286,10 @@
daemon->connections = pos->next;
else
prev->next = pos->next;
- if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) {
+ pthread_kill(pos->pid, SIGALRM);
pthread_join(pos->pid, &unused);
+ }
free(pos->addr);
if (pos->url != NULL)
free(pos->url);
@@ -545,9 +547,10 @@
close(daemon->socket_fd);
daemon->socket_fd = -1;
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
- (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) )
+ (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) ) {
+ pthread_kill(daemon->pid, SIGALRM);
pthread_join(daemon->pid, &unused);
-
+ }
while (daemon->connections != NULL) {
if (-1 != daemon->connections->socket_fd) {
close(daemon->connections->socket_fd);
@@ -558,4 +561,27 @@
free(daemon);
}
+static struct sigaction sig;
+
+static struct sigaction old;
+
+static void sigalrmHandler(int sig) {
+}
+
+/**
+ * Initialize the signal handler for SIGALRM.
+ */
+void __attribute__ ((constructor)) pthread_handlers_ltdl_init() {
+ /* make sure SIGALRM does not kill us */
+ memset(&sig, 0, sizeof(struct sigaction));
+ memset(&old, 0, sizeof(struct sigaction));
+ sig.sa_flags = SA_NODEFER;
+ sig.sa_handler = &sigalrmHandler;
+ sigaction(SIGALRM, &sig, &old);
+}
+
+void __attribute__ ((destructor)) pthread_handlers_ltdl_fini() {
+ sigaction(SIGALRM, &old, &sig);
+}
+
/* end of daemon.c */
Modified: libmicrohttpd/src/daemon/daemontest1.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest1.c 2007-06-14 00:26:06 UTC (rev
5047)
+++ libmicrohttpd/src/daemon/daemontest1.c 2007-06-14 00:37:55 UTC (rev
5048)
@@ -142,7 +142,6 @@
MHD_stop_daemon(d);
return 8;
}
-
MHD_stop_daemon(d);
return 0;
Modified: libmicrohttpd/src/daemon/internal.h
===================================================================
--- libmicrohttpd/src/daemon/internal.h 2007-06-14 00:26:06 UTC (rev 5047)
+++ libmicrohttpd/src/daemon/internal.h 2007-06-14 00:37:55 UTC (rev 5048)
@@ -38,6 +38,7 @@
#include <stdarg.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <pthread.h>
#include <netinet/in.h>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5048 - libmicrohttpd/src/daemon,
gnunet <=