diff options
author | venaas <venaas> | 2008-04-15 09:22:35 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-04-15 09:22:35 +0000 |
commit | 7ca3197e8da2add69e17437f1b8f3f2ac669990b (patch) | |
tree | 3273572cddfe5cd96e5b2899c689618bb7c3d78c /radsecproxy.c | |
parent | d94f34f7ae6dee9bdd9dcc9f2ab7fd8b370d0b62 (diff) |
blocking SIGPIPE
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@229 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'radsecproxy.c')
-rw-r--r-- | radsecproxy.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/radsecproxy.c b/radsecproxy.c index 9a769ef..030ffba 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -29,6 +29,7 @@ * 1 + (2 + 2 * 3) + (2 * 30) + (2 * 30) = 129 threads */ +#include <signal.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> @@ -3081,8 +3082,29 @@ int daemon(int a, int b) { } #endif +void *sighandler(void *arg) { + sigset_t sigset; + int sig; + + for(;;) { + sigfillset(&sigset); + sigwait(&sigset, &sig); + 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, udpaccserverth, udpclient4rdth, udpclient6rdth; + pthread_t sigth, udpserverth, udpaccserverth, udpclient4rdth, udpclient6rdth; + sigset_t sigset; struct list_node *entry; uint8_t foreground = 0, pretend = 0, loglevel = 0; char *configfile = NULL; @@ -3120,6 +3142,12 @@ int main(int argc, char **argv) { debug(DBG_INFO, "radsecproxy revision $Rev$ 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_replyq = newreplyq(); if (pthread_create(&udpserverth, NULL, udpserverrd, NULL)) |