From cecf523b7bc055cb38ac66844f6ec039d88023ca Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 3 Jun 2013 18:28:10 +0200 Subject: [PATCH] Decouple handle destroying from committing, add fw3_ipt_close() instead --- iptables.c | 4 ++++ iptables.h | 2 ++ main.c | 5 +++++ 3 files changed, 11 insertions(+) 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); -- 2.25.1