summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Larson <mike@vyatta.com>2011-01-06 13:56:56 -0800
committerStig Thormodsrud <stig@vyatta.com>2011-01-11 16:39:32 -0800
commita8f0172f6afc97d24329a99bbae8b5d09da51a3a (patch)
tree7c9916fde826bfd49cf0cc7f38a8cb67ffd90af4 /src
parent9280b45e11e1c877d466f34f939eb70f29a669e5 (diff)
downloadvyatta-cfg-a8f0172f6afc97d24329a99bbae8b5d09da51a3a.tar.gz
vyatta-cfg-a8f0172f6afc97d24329a99bbae8b5d09da51a3a.zip
re-enable concurrent configuration commit locking.
locking can be overrode though commit -l flag. (cherry picked from commit c13f949c55df81052c73d394d5ed5ea18a65502b)
Diffstat (limited to 'src')
-rw-r--r--src/cli_new.c5
-rw-r--r--src/commit2.c16
2 files changed, 18 insertions, 3 deletions
diff --git a/src/cli_new.c b/src/cli_new.c
index 87f8e8b..2db7996 100644
--- a/src/cli_new.c
+++ b/src/cli_new.c
@@ -461,7 +461,10 @@ get_config_lock()
} else if (fd != -1) {
close(fd);
}
- release_config_lock();
+ //code below will cause a concurrent commit to release lock on failure, and
+ //therefore, allow the concurrent to proceed the second time.
+ //lock can be forced via commit flag instead.
+ // release_config_lock();
}
return ret;
}
diff --git a/src/commit2.c b/src/commit2.c
index 4401d8d..96eb1fb 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -44,6 +44,8 @@ static const char* ActionNames[top_act] = {
"end" //7
};
+#define LOCK_FILE "/opt/vyatta/config/.lock"
+
GNode*
get_transactions(GNode*, boolean priority);
@@ -130,7 +132,8 @@ usage(void)
printf("\t-f\t\tfull iteration over configuration on commit check\n");
printf("\t-b\t\tbreak on each priority node (debug mode)\n");
printf("\t-r\t\tdisable run hook script on finishing commit\n");
- printf("\t-x\t\t\disable new print feature\n");
+ printf("\t-x\t\tdisable new print feature\n");
+ printf("\t-l\t\tforce removal of commit lock\n");
printf("\t-h\t\thelp\n");
}
@@ -154,7 +157,7 @@ main(int argc, char** argv)
g_type_init();
//grab inputs
- while ((ch = getopt(argc, argv, "xdpthsecoafbrC:")) != -1) {
+ while ((ch = getopt(argc, argv, "xdpthsecoafbrlC:")) != -1) {
switch (ch) {
case 'x':
g_old_print_output = TRUE;
@@ -199,6 +202,9 @@ main(int argc, char** argv)
case 'C':
commit_comment = strdup(optarg);
break;
+ case 'l':
+ unlink(LOCK_FILE);
+ break;
default:
usage();
exit(0);
@@ -222,6 +228,12 @@ main(int argc, char** argv)
syslog(LOG_DEBUG,"commit2: starting up");
}
+ if (get_config_lock() != 0) {
+ fprintf(out_stream,"Configuration system temporarily locked due to another commit in progress\n");
+ exit(1);
+ }
+
+
//get local session data plus configuration data
GNode *config_data = common_get_local_session_data();
if (g_node_n_children(config_data) == 0) {