diff options
author | venaas <venaas> | 2008-04-16 08:38:31 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-04-16 08:38:31 +0000 |
commit | aa6e2e9e4cfc0dc21d5362cbd9b687fab2883dc1 (patch) | |
tree | c7c02b96b427dc7513a0c07886f443df55ddf33e | |
parent | 552ac29aba625224dce5d9843349d87b559ecf7a (diff) |
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
-rw-r--r-- | radsecproxy.c | 34 |
1 files 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 <venaas@uninett.no> + * Copyright (C) 2006-2008 Stig Venaas <venaas@uninett.no> * * 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 <signal.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> @@ -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)) |