aboutsummaryrefslogtreecommitdiffstats
path: root/iptables/iptables-restore.c
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-01-30 21:15:16 +0900
committerLorenzo Colitti <lorenzo@google.com>2017-03-22 17:09:41 +0900
commit0f6d7c31d091408cebe2d8066c551c111c9ffdc2 (patch)
treedad5ffbbb73eec11508ae9d843e0239ba5635793 /iptables/iptables-restore.c
parent8c7efe912f13460f4859daa39b3cf8f3a82411f2 (diff)
downloadplatform_external_iptables-0f6d7c31d091408cebe2d8066c551c111c9ffdc2.tar.gz
platform_external_iptables-0f6d7c31d091408cebe2d8066c551c111c9ffdc2.tar.bz2
platform_external_iptables-0f6d7c31d091408cebe2d8066c551c111c9ffdc2.zip
Revert "iptables: Change locking semantics."
This reverts commit d2a1e52615058ef55b65db02aa5e4ad21b635ef0. This is being reverted to minimize diffs with upstream and will be cherry-picked once upstream is merged. Bug: 36108349 Test: see top of change stack. Change-Id: If8136bfd230bf0079884ab94fad0dcdc35a67c47
Diffstat (limited to 'iptables/iptables-restore.c')
-rw-r--r--iptables/iptables-restore.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index a41a46d3..4d49b3c9 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -185,7 +185,7 @@ iptables_restore_main(int argc, char *argv[])
{
struct xtc_handle *handle = NULL;
char buffer[10240];
- int c, lock;
+ int c;
char curtable[XT_TABLE_MAXNAMELEN + 1];
FILE *in;
int in_table = 0, testing = 0;
@@ -193,7 +193,6 @@ iptables_restore_main(int argc, char *argv[])
const struct xtc_ops *ops = &iptc_ops;
line = 0;
- lock = XT_LOCK_NOT_ACQUIRED;
iptables_globals.program_name = "iptables-restore";
c = xtables_init_all(&iptables_globals, NFPROTO_IPV4);
@@ -255,6 +254,12 @@ iptables_restore_main(int argc, char *argv[])
}
else in = stdin;
+ if (!xtables_lock(wait)) {
+ fprintf(stderr, "Another app is currently holding the xtables lock. "
+ "Perhaps you want to use the -w option?\n");
+ exit(RESOURCE_PROBLEM);
+ }
+
/* Grab standard input. */
while (fgets(buffer, sizeof(buffer), in)) {
int ret = 0;
@@ -278,21 +283,8 @@ iptables_restore_main(int argc, char *argv[])
DEBUGP("Not calling commit, testing\n");
ret = 1;
}
-
- /* Release the lock since we're done with the current table. */
- if (lock >= 0) {
- xtables_unlock(lock);
- }
in_table = 0;
} else if ((buffer[0] == '*') && (!in_table)) {
- /* Acquire a lock before we create a new table handle */
- lock = xtables_lock(wait);
- if (lock == XT_LOCK_BUSY) {
- fprintf(stderr, "Another app is currently holding the xtables lock. "
- "Perhaps you want to use the -w option?\n");
- exit(RESOURCE_PROBLEM);
- }
-
/* New table */
char *table;