]> git.pond.sub.org Git - empserver/commitdiff
(empth_start, empth_init, empth_alarm) [_EMPTH_POSIX]: We do raise
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 9 Dec 2005 20:52:30 +0000 (20:52 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 9 Dec 2005 20:52:30 +0000 (20:52 +0000)
SIGALRM!  Revert rev. 1.21.

(empth_alarm): Internal linkage.

src/lib/empthread/pthread.c

index 65438a84d0c3d5a42aae6683fdd662b5c8ccd692..d4ede07dc9697fb47cab7fdff56c5dca3c3b38e7 100644 (file)
@@ -88,7 +88,7 @@ static void **udata;
 static pthread_mutex_t mtx_ctxsw;
 
 static void empth_status(char *format, ...) ATTRIBUTE((format (printf, 1, 2)));
-
+static void empth_alarm(int sig);
 
 static void *
 empth_start(void *arg)
@@ -110,6 +110,9 @@ empth_start(void *arg)
     act.sa_handler = SIG_IGN;
     sigaction(SIGPIPE, &act, NULL);
 
+    act.sa_handler = empth_alarm;
+    sigaction(SIGALRM, &act, NULL);
+
     ctx->id = pthread_self();
     pthread_setspecific(ctx_key, ctx);
     pthread_mutex_lock(&mtx_ctxsw);
@@ -154,11 +157,17 @@ int
 empth_init(void **ctx_ptr, int flags)
 {
     empth_t *ctx;
+    struct sigaction act;
 
 
     pthread_key_create(&ctx_key, NULL);
     pthread_mutex_init(&mtx_ctxsw, NULL);
 
+    act.sa_flags = 0;
+    sigemptyset(&act.sa_mask);
+    act.sa_handler = empth_alarm;
+    sigaction(SIGALRM, &act, NULL);
+
     udata = ctx_ptr;
     ctx = malloc(sizeof(empth_t));
     if (!ctx) {
@@ -354,6 +363,19 @@ empth_select(int fd, int flags)
 }
 
 
+static void
+empth_alarm(int sig)
+{
+    struct sigaction act;
+    empth_status("got alarm signal");
+#ifdef SA_RESTART
+    act.sa_flags &= ~SA_RESTART;
+#endif
+    sigemptyset(&act.sa_mask);
+    act.sa_handler = empth_alarm;
+    sigaction(SIGALRM, &act, NULL);
+}
+
 void
 empth_wakeup(empth_t *a)
 {