+2008-02-07 Jonathan Pryor <jpryor@novell.com>
+
+ * signal.c: Make the signal handler thread-safe, so that it can safely be
+ invoked concurrently from multiple threads.
+
2008-02-05 Jonathan Pryor <jpryor@novell.com>
* signal.c: Fix the Win32 build.
{
int i;
for (i = 0; i < NUM_SIGNALS; ++i) {
+ int fd;
signal_info* h = &signals [i];
- if (h->signum != signum)
+ if (g_atomic_int_get (&h->signum) != signum)
continue;
- ++h->count;
- if (h->write_fd > 0) {
+ g_atomic_int_inc (&h->count);
+ fd = g_atomic_int_get (&h->write_fd);
+ if (fd > 0) {
char c = signum;
- write (h->write_fd, &c, 1);
+ write (fd, &c, 1);
}
}
}
break;
}
else {
- h->signum = sig;
- h->count = 0;
h->have_handler = 1;
}
}
h->handler = handler;
}
+ if (h) {
+ g_atomic_int_set (&h->count, 0);
+ g_atomic_int_set (&h->signum, sig);
+ }
+
pthread_mutex_unlock (&signals_mutex);
return h;