sender: Deplete ACLs on exit.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 16 Nov 2017 02:35:01 +0000 (03:35 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Mar 2018 02:28:56 +0000 (03:28 +0100)
This teaches the dccp and the http sender to empty their access control
lists during shutdown, avoiding some (harmless) memory leaks at exit.

dccp_send.c
http_send.c
send.h
send_common.c

index bd6c025..0b454e7 100644 (file)
@@ -80,6 +80,12 @@ static void dccp_shutdown_clients(void)
                dccp_shutdown_client(sc);
 }
 
+static void dccp_shutdown(void)
+{
+       dccp_shutdown_clients();
+       generic_acl_deplete(&dss->acl);
+}
+
 /** * Obtain current MPS according to RFC 4340, sec. 14. */
 static int dccp_init_fec(struct sender_client *sc)
 {
@@ -238,7 +244,7 @@ static void dccp_send_init(void)
 const struct sender dccp_sender = {
        .name = "dccp",
        .init = dccp_send_init,
-       .shutdown = dccp_shutdown_clients,
+       .shutdown = dccp_shutdown,
        .pre_select = dccp_pre_select,
        .post_select = dccp_post_select,
        .shutdown_clients = dccp_shutdown_clients,
index fb9fd9b..9a35fc9 100644 (file)
@@ -75,6 +75,12 @@ static void http_shutdown_clients(void)
        shutdown_clients(hss);
 }
 
+static void http_shutdown(void)
+{
+       http_shutdown_clients();
+       generic_acl_deplete(&hss->acl);
+}
+
 static int queue_chunk_or_shutdown(struct sender_client *sc,
                struct sender_status *ss, const char *buf, size_t num_bytes)
 {
@@ -264,7 +270,7 @@ static void http_send_init(void)
 const struct sender http_sender = {
        .name = "http",
        .init = http_send_init,
-       .shutdown = http_shutdown_clients,
+       .shutdown = http_shutdown,
        .pre_select = http_pre_select,
        .post_select = http_post_select,
        .send = http_send,
diff --git a/send.h b/send.h
index bca03b2..212fb4a 100644 (file)
--- a/send.h
+++ b/send.h
@@ -190,6 +190,7 @@ void generic_com_allow(struct sender_command_data *scd,
                struct sender_status *ss);
 void generic_com_deny(struct sender_command_data *scd,
                struct sender_status *ss);
+void generic_acl_deplete(struct list_head *acl);
 int generic_com_on(struct sender_status *ss, unsigned protocol);
 void generic_com_off(struct sender_status *ss);
 char *generic_sender_help(void);
index 2088c8b..3e8a7c0 100644 (file)
@@ -218,6 +218,22 @@ void generic_com_allow(struct sender_command_data *scd,
        acl_allow(scd->host, scd->netmask, &ss->acl, ss->default_deny);
 }
 
+/**
+ * Empty the access control list of a sender.
+ *
+ * \param acl The access control list of the sender.
+ *
+ * This is called from the ->shutdown methods of the http and the dccp sender.
+ */
+void generic_acl_deplete(struct list_head *acl)
+{
+       /*
+        * Since default_deny is false, the ACL is considered a blacklist. A
+        * netmask of zero matches any IP address, so this call empties the ACL.
+        */
+       acl_allow("0.0.0.0", 0 /* netmask */, acl, 0 /* default_deny */);
+}
+
 /**
  * Deny connections from the given range of IP addresses.
  *