summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-02 19:19:42 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-02 19:19:42 +0300
commit92db94f91b7c4b39859b4af251dd333ebbfbf748 (patch)
tree6cc1451753cfc4de67696e0be0c91c7a2ab83fb4
parent2fdf31355f00996dac96794b3b5d825fe7a53aef (diff)
downloadrspamd-92db94f91b7c4b39859b4af251dd333ebbfbf748.tar.gz
rspamd-92db94f91b7c4b39859b4af251dd333ebbfbf748.zip
Block signals in worker threads.
-rw-r--r--src/kvstorage_server.c7
-rw-r--r--src/kvstorage_server.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/src/kvstorage_server.c b/src/kvstorage_server.c
index 50497f919..0ac84f7a3 100644
--- a/src/kvstorage_server.c
+++ b/src/kvstorage_server.c
@@ -480,6 +480,8 @@ kvstorage_thread (gpointer ud)
{
struct kvstorage_worker_thread *thr = ud;
+ /* Block signals as it is dispatcher deity */
+ sigprocmask (SIG_BLOCK, thr->signals, NULL);
/* Init thread specific events */
thr->ev_base = event_init ();
event_set (&thr->bind_ev, thr->worker->cf->listen_sock, EV_READ | EV_PERSIST, thr_accept_socket, (void *)thr);
@@ -495,7 +497,7 @@ kvstorage_thread (gpointer ud)
* Create new thread, set it detached
*/
static struct kvstorage_worker_thread *
-create_kvstorage_thread (struct rspamd_worker *worker, struct kvstorage_worker_ctx *ctx, guint id)
+create_kvstorage_thread (struct rspamd_worker *worker, struct kvstorage_worker_ctx *ctx, guint id, sigset_t *signals)
{
struct kvstorage_worker_thread *new;
GError *err = NULL;
@@ -509,6 +511,7 @@ create_kvstorage_thread (struct rspamd_worker *worker, struct kvstorage_worker_c
new->id = id;
new->thr = g_thread_create (kvstorage_thread, new, FALSE, &err);
new->ev_base = NULL;
+ new->signals = signals;
if (new->thr == NULL) {
msg_err ("cannot create thread: %s", err->message);
@@ -568,7 +571,7 @@ start_kvstorage_worker (struct rspamd_worker *worker)
g_static_mutex_init (&ctx->log_mtx);
g_static_mutex_init (&ctx->accept_mtx);
for (i = 0; i < worker->cf->count; i ++) {
- thr = create_kvstorage_thread (worker, ctx, i);
+ thr = create_kvstorage_thread (worker, ctx, i, &signals.sa_mask);
ctx->threads = g_list_prepend (ctx->threads, thr);
}
diff --git a/src/kvstorage_server.h b/src/kvstorage_server.h
index 827b34c9c..808ead805 100644
--- a/src/kvstorage_server.h
+++ b/src/kvstorage_server.h
@@ -51,6 +51,7 @@ struct kvstorage_worker_thread {
GStaticMutex *log_mtx;
GStaticMutex *accept_mtx;
guint id;
+ sigset_t *signals;
};
struct kvstorage_session {