From fcf009ded7a77959da5592e298de93fb044a6757 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 10 Dec 2010 00:41:52 +0000 Subject: re-reading the config file after sig-hup git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@43 e61f0598-a718-4e21-a8f0-0aadfa62ad6b --- src/tcpproxy.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/tcpproxy.c') diff --git a/src/tcpproxy.c b/src/tcpproxy.c index fcc871f..1007b80 100644 --- a/src/tcpproxy.c +++ b/src/tcpproxy.c @@ -71,9 +71,16 @@ int main_loop(options_t* opt, listeners_t* listeners) continue; if(FD_ISSET(sig_fd, &readfds)) { - if(signal_handle()) { - return_value = 1; - break; + return_value = signal_handle(); + if(return_value == 1) break; + if(return_value == 2) { + if(opt->config_file_) { + log_printf(NOTICE, "re-reading config file: %s", opt->config_file_); + read_configfile(opt->config_file_, listeners); + } else + log_printf(NOTICE, "ignoring SIGHUP: no config file specified"); + + return_value = 0; } } @@ -149,6 +156,7 @@ int main(int argc, char* argv[]) if(opt.local_port_) { ret = listeners_add(&listeners, opt.local_addr_, opt.lresolv_type_, opt.local_port_, opt.remote_addr_, opt.rresolv_type_, opt.remote_port_, opt.source_addr_); + if(!ret) ret = listeners_update(&listeners); if(ret) { listeners_clear(&listeners); options_clear(&opt); @@ -167,14 +175,6 @@ int main(int argc, char* argv[]) } } - ret = listeners_activate(&listeners); - if(ret) { - listeners_clear(&listeners); - options_clear(&opt); - log_close(); - exit(-1); - } - priv_info_t priv; if(opt.username_) if(priv_init(&priv, opt.username_, opt.groupname_)) { -- cgit v1.2.3