]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
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 bd6c0257e432161c3d468505ec275638c70f010e..0b454e792a84d679ec322561a00d7b383b1ef5b3 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 fb9fd9b3d1b42a1f3841ef88e261178e66efc302..9a35fc99f920beed52e19c12bab9f9dc308027e4 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 bca03b2027492a211bdaa5fa02eeaa1b50878ae1..212fb4a12582610034593398c3d1dca93dc77de4 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 2088c8b4de2947c94c238b41a471c2ecb89914d5..3e8a7c0dc85049dcfc52a5982083a69d3e1babc6 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.
  *