diff options
-rw-r--r-- | src/cli_new.c | 5 | ||||
-rw-r--r-- | src/commit2.c | 16 |
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) { |