From: Jo-Philipp Wich Date: Mon, 3 Jun 2013 16:28:10 +0000 (+0200) Subject: Decouple handle destroying from committing, add fw3_ipt_close() instead X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=commitdiff_plain;h=cecf523b7bc055cb38ac66844f6ec039d88023ca;hp=2dbfd733c34311df6217da809c0045c195ba8b9e Decouple handle destroying from committing, add fw3_ipt_close() instead --- diff --git a/iptables.c b/iptables.c index 2fc8d36..4ae8875 100644 --- a/iptables.c +++ b/iptables.c @@ -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) diff --git a/iptables.h b/iptables.h index e86162d..b97e5c5 100644 --- a/iptables.h +++ b/iptables.h @@ -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 --- 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);