Decouple handle destroying from committing, add fw3_ipt_close() instead
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 3 Jun 2013 16:28:10 +0000 (18:28 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 3 Jun 2013 16:28:10 +0000 (18:28 +0200)
iptables.c
iptables.h
main.c

index 2fc8d36fec329b08ad8c9887237ea82d55ef30a7..4ae88750d0df42ff1826bdcbd80d44791389f73d 100644 (file)
@@ -311,7 +311,11 @@ fw3_ipt_commit(struct fw3_ipt_handle *h)
                if (!rv)
                        fprintf(stderr, "iptc_commit(): %s\n", iptc_strerror(errno));
        }
+}
 
+void
+fw3_ipt_close(struct fw3_ipt_handle *h)
+{
        if (h->libv)
        {
                while (h->libc > 0)
index e86162d42be506225beee84d3383f444b6d82811..b97e5c58908d36b03a37ba29f2e10c777e0d96f7 100644 (file)
@@ -126,6 +126,8 @@ void fw3_ipt_flush(struct fw3_ipt_handle *h);
 
 void fw3_ipt_commit(struct fw3_ipt_handle *h);
 
+void fw3_ipt_close(struct fw3_ipt_handle *h);
+
 struct fw3_ipt_rule *fw3_ipt_rule_new(struct fw3_ipt_handle *h);
 
 void fw3_ipt_rule_proto(struct fw3_ipt_rule *r, struct fw3_protocol *proto);
diff --git a/main.c b/main.c
index 8b10d083eb85c91a3f6e9cec2308661c7e39438c..32ff87dbf1d42d2a54b02b2f3b26f18e23f595f2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -205,6 +205,7 @@ stop(bool complete)
                        }
 
                        fw3_ipt_commit(handle);
+                       fw3_ipt_close(handle);
                }
 
                family_set(run_state, family, false);
@@ -280,6 +281,8 @@ start(void)
 
                        if (!print_family)
                                fw3_ipt_commit(handle);
+
+                       fw3_ipt_close(handle);
                }
 
                if (!print_family)
@@ -339,6 +342,7 @@ reload(void)
                        fw3_flush_rules(handle, run_state, true);
                        fw3_flush_zones(handle, run_state, true);
                        fw3_ipt_commit(handle);
+                       fw3_ipt_close(handle);
                }
 
                family_set(run_state, family, false);
@@ -369,6 +373,7 @@ start:
                        fw3_print_default_tail_rules(handle, cfg_state, true);
 
                        fw3_ipt_commit(handle);
+                       fw3_ipt_close(handle);
                }
 
                fw3_print_includes(cfg_state, family, true);