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!

git.mgm/mediaproxy-ng/2.1
Richard Fuchs 13 years ago
parent 2ad1d6f65e
commit d20d747a63

@ -13,6 +13,7 @@
#include <stdarg.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <sys/resource.h>
@ -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

@ -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);

@ -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;

Loading…
Cancel
Save