From aa6e2e9e4cfc0dc21d5362cbd9b687fab2883dc1 Mon Sep 17 00:00:00 2001 From: venaas Date: Wed, 16 Apr 2008 08:38:31 +0000 Subject: added new signal handling to 1.0 git-svn-id: https://svn.testnett.uninett.no/radsecproxy/branches/release-1.0@234 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- radsecproxy.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/radsecproxy.c b/radsecproxy.c index b3c892e..77d4895 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Stig Venaas + * Copyright (C) 2006-2008 Stig Venaas * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -29,6 +29,7 @@ * 1 + (2 + 2 * 3) + (2 * 30) + (2 * 30) = 129 threads */ +#include #include #include #include @@ -2378,8 +2379,31 @@ void getargs(int argc, char **argv, uint8_t *foreground, uint8_t *loglevel, char exit(1); } +void *sighandler(void *arg) { + sigset_t sigset; + int sig; + + for(;;) { + sigemptyset(&sigset); + sigaddset(&sigset, SIGPIPE); + sigwait(&sigset, &sig); + /* only get SIGPIPE right now, so could simplify below code */ + switch (sig) { + case 0: + /* completely ignoring this */ + break; + case SIGPIPE: + debug(DBG_WARN, "sighandler: got SIGPIPE, TLS write error?"); + break; + default: + debug(DBG_WARN, "sighandler: ignoring signal %d", sig); + } + } +} + int main(int argc, char **argv) { - pthread_t udpserverth; + pthread_t sigth, udpserverth; + sigset_t sigset; int i; uint8_t foreground = 0, loglevel = 0; char *configfile = NULL; @@ -2414,6 +2438,12 @@ int main(int argc, char **argv) { debug(DBG_INFO, "radsecproxy 1.0p1 starting"); + sigemptyset(&sigset); + /* exit on all but SIGPIPE, ignore more? */ + sigaddset(&sigset, SIGPIPE); + pthread_sigmask(SIG_BLOCK, &sigset, NULL); + pthread_create(&sigth, NULL, sighandler, NULL); + if (client_udp_count) { udp_server_listen = server_create('U'); if (pthread_create(&udpserverth, NULL, udpserverrd, NULL)) -- cgit v1.1