projects
/
project
/
firewall3.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
iptables.c: lock the xtables.lock
[project/firewall3.git]
/
iptables.c
diff --git
a/iptables.c
b/iptables.c
index a095621dc30873a2cb068d2ace6e59bc0d111e97..559fe7defef3be85c4eb2934884caf549f932bc5 100644
(file)
--- a/
iptables.c
+++ b/
iptables.c
@@
-55,6
+55,8
@@
#include "iptables.h"
#include "iptables.h"
+#define XT_LOCK_NAME "/var/run/xtables.lock"
+static int xt_lock_fd = -1;
struct fw3_ipt_rule {
struct fw3_ipt_handle *h;
struct fw3_ipt_rule {
struct fw3_ipt_handle *h;
@@
-168,6
+170,11
@@
fw3_ipt_open(enum fw3_family family, enum fw3_table table)
xtables_init();
xtables_init();
+ while (!fw3_lock_path(&xt_lock_fd, XT_LOCK_NAME)) {
+ warn("Currently busy xtables.lock - wait 1 second");
+ sleep(1);
+ }
+
if (family == FW3_FAMILY_V6)
{
#ifndef DISABLE_IPV6
if (family == FW3_FAMILY_V6)
{
#ifndef DISABLE_IPV6
@@
-192,6
+199,7
@@
fw3_ipt_open(enum fw3_family family, enum fw3_table table)
if (!h->handle)
{
free(h);
if (!h->handle)
{
free(h);
+ fw3_unlock_path(&xt_lock_fd, XT_LOCK_NAME);
return NULL;
}
return NULL;
}
@@
-561,6
+569,7
@@
fw3_ipt_commit(struct fw3_ipt_handle *h)
void
fw3_ipt_close(struct fw3_ipt_handle *h)
{
void
fw3_ipt_close(struct fw3_ipt_handle *h)
{
+ fw3_unlock_path(&xt_lock_fd, XT_LOCK_NAME);
free(h);
}
free(h);
}