summaryrefslogtreecommitdiff
path: root/accel-pptpd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-11-26 22:33:33 +0300
committerDmitry Kozlov <xeb@mail.ru>2010-11-26 22:33:33 +0300
commitb414b2026ca90c5b8d7015ccde4f8fafb2558b2d (patch)
tree308785fbf5705bb485c5026e255b67720e0fc35c /accel-pptpd
parente5eddec6f9baf27aab61931bb657bc9764a2f6b4 (diff)
downloadaccel-ppp-b414b2026ca90c5b8d7015ccde4f8fafb2558b2d.tar.gz
accel-ppp-b414b2026ca90c5b8d7015ccde4f8fafb2558b2d.zip
log-tcp: cleanup code on daemon terminate
Diffstat (limited to 'accel-pptpd')
-rw-r--r--accel-pptpd/logs/log_tcp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/accel-pptpd/logs/log_tcp.c b/accel-pptpd/logs/log_tcp.c
index fdef63e..98b8a41 100644
--- a/accel-pptpd/logs/log_tcp.c
+++ b/accel-pptpd/logs/log_tcp.c
@@ -43,6 +43,8 @@ static const char* level_name[]={" msg", "error", " warn", " info", "debug"};
static void start_connect(struct tcp_target_t *t);
+static LIST_HEAD(targets);
+
static void disconnect(struct tcp_target_t *t)
{
triton_md_unregister_handler(&t->hnd);
@@ -226,6 +228,25 @@ static void start_connect(struct tcp_target_t *t)
triton_md_enable_handler(&t->hnd, MD_MODE_WRITE);
}
+static void log_tcp_close(struct triton_context_t *ctx)
+{
+ struct tcp_target_t *t;
+
+ while (!list_empty(&targets)) {
+ t = list_entry(targets.next, typeof(*t), entry);
+ list_del(&t->entry);
+ if (t->conn_timer.tpd)
+ triton_timer_del(&t->conn_timer);
+ else {
+ t->connected = 0;
+ triton_md_unregister_handler(&t->hnd);
+ close(t->hnd.fd);
+ }
+ }
+
+ triton_context_unregister(&tcp_ctx);
+}
+
static int start_log(const char *_opt)
{
struct tcp_target_t *t;
@@ -266,6 +287,8 @@ static int start_log(const char *_opt)
log_register_target(&t->target);
+ list_add_tail(&t->entry, &targets);
+
return 0;
err:
@@ -273,6 +296,10 @@ err:
return -1;
}
+static struct triton_context_t tcp_ctx ={
+ .close = log_tcp_close,
+};
+
static void __init init(void)
{
struct conf_sect_t *s = conf_get_section("log");