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 2fc8d36..4ae8875 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 e86162d..b97e5c5 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 8b10d08..32ff87d 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);