From d20d747a6310a3f3a0771abbc001787116687e21 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 6 Aug 2012 16:03:24 +0000 Subject: [PATCH] since xmlrpc is still segfaulting even in its own process, disable core dumps in the child and retry the xmlrpc call up to 3 times if the child terminates abnormally. jumping through hoops ftw! --- daemon/aux.h | 9 +++++++++ daemon/call.c | 20 ++++++++++++++++++-- daemon/main.c | 8 -------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/daemon/aux.h b/daemon/aux.h index 38d0c1b3d..faa5031ba 100644 --- a/daemon/aux.h +++ b/daemon/aux.h @@ -13,6 +13,7 @@ #include #include #include +#include @@ -177,4 +178,12 @@ void thread_create_detach(void (*)(void *), void *); +static inline int rlim(int res, rlim_t val) { + struct rlimit rlim; + + ZERO(rlim); + rlim.rlim_cur = rlim.rlim_max = val; + return setrlimit(res, &rlim); +} + #endif diff --git a/daemon/call.c b/daemon/call.c index 2f878f122..6a4f692a8 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -549,19 +549,35 @@ void xmlrpc_kill_calls(void *p) { xmlrpc_value *r; pid_t pid; sigset_t ss; + int i = 0; + int status; while (xh->tags) { pid = fork(); if (pid) { - waitpid(pid, NULL, 0); - xh->tags = g_slist_delete_link(xh->tags, xh->tags); +retry: + pid = waitpid(pid, &status, 0); + if ((pid > 0 && WIFEXITED(status)) || i >= 3) { + xh->tags = g_slist_delete_link(xh->tags, xh->tags); + i = 0; + } + else { + if (pid == -1 && errno == EINTR) + goto retry; + i++; + } continue; } /* child process */ + rlim(RLIMIT_CORE, 0); sigemptyset(&ss); sigprocmask(SIG_SETMASK, &ss, NULL); + + for (i = 0; i < 100; i++) + close(i); + alarm(5); xmlrpc_env_init(&e); diff --git a/daemon/main.c b/daemon/main.c index 551dd32fe..8ea7defb8 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -105,14 +105,6 @@ static void signals(void) { pthread_sigmask(SIG_SETMASK, &ss, NULL); } -static int rlim(int res, rlim_t val) { - struct rlimit rlim; - - ZERO(rlim); - rlim.rlim_cur = rlim.rlim_max = val; - return setrlimit(res, &rlim); -} - static void resources(void) { int tryv;