summaryrefslogtreecommitdiff
path: root/accel-pptpd/log.c
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-12-27 15:25:38 +0300
committerKozlov Dmitry <dima@server>2010-12-27 15:25:38 +0300
commit2b34d862111f1fd84cdb9d744ac34c1c933f34da (patch)
tree1e758ddc96689793e1c4c1b55cf3671bb05f2884 /accel-pptpd/log.c
parentccaeb500e38d82c37568292d7850b66691793626 (diff)
downloadaccel-ppp-2b34d862111f1fd84cdb9d744ac34c1c933f34da.tar.gz
accel-ppp-2b34d862111f1fd84cdb9d744ac34c1c933f34da.zip
implemented partial config reload via SIGUSR1 signal or cli
Diffstat (limited to 'accel-pptpd/log.c')
-rw-r--r--accel-pptpd/log.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/accel-pptpd/log.c b/accel-pptpd/log.c
index 5fbd93a..6994d86 100644
--- a/accel-pptpd/log.c
+++ b/accel-pptpd/log.c
@@ -447,13 +447,10 @@ static void sighup(int n)
t->reopen();
}
-static void __init log_init(void)
+static void load_config(void)
{
char *opt;
- struct sigaction sa = {
- .sa_handler = sighup,
- };
-
+ FILE *f;
opt = conf_get_opt("log", "level");
if (opt && atoi(opt) >= 0)
@@ -461,23 +458,45 @@ static void __init log_init(void)
opt = conf_get_opt("log", "log-emerg");
if (opt) {
- emerg_file = fopen(opt, "a");
+ if (emerg_file)
+ emerg_file = freopen(opt, "a", emerg_file);
+ else
+ emerg_file = fopen(opt, "a");
if (!emerg_file)
fprintf(stderr, "log:open: %s\n", strerror(errno));
+ } else if (emerg_file) {
+ fclose(emerg_file);
+ emerg_file = NULL;
}
opt = conf_get_opt("log", "log-debug");
if (opt) {
- debug_file = fopen(opt, "a");
- if (!emerg_file)
+ if (debug_file)
+ debug_file = freopen(opt, "a", debug_file);
+ else
+ debug_file = fopen(opt, "a");
+ if (!debug_file)
fprintf(stderr, "log:open: %s\n", strerror(errno));
+ } else if (debug_file) {
+ fclose(debug_file);
+ debug_file = NULL;
}
+}
+
+static void __init log_init(void)
+{
+ struct sigaction sa = {
+ .sa_handler = sighup,
+ };
msg_pool = mempool_create(sizeof(struct log_msg_t));
_msg_pool = mempool_create(sizeof(struct _log_msg_t));
chunk_pool = mempool_create(sizeof(struct log_chunk_t) + LOG_CHUNK_SIZE + 1);
- sigaction(SIGHUP, &sa, NULL);
+ load_config();
+ triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
+
+ sigaction(SIGHUP, &sa, NULL);
}