summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2011-05-05 16:25:48 +0800
committerAn-Cheng Huang <ancheng@vyatta.com>2011-05-10 09:25:13 +0800
commit7d40a9f96cddcaaed6abc83b54101d8d5eeeeb60 (patch)
tree9e0e0faa0660f1a1b0e8b2bf92ef3d2d89ae557c /src
parent491b4c361f3a612835e76604fbd751e6e6905c3d (diff)
downloadvyatta-cfg-7d40a9f96cddcaaed6abc83b54101d8d5eeeeb60.tar.gz
vyatta-cfg-7d40a9f96cddcaaed6abc83b54101d8d5eeeeb60.zip
clean up when committing no changes
(cherry picked from commit 113b5ee593fd3196e2b1c828c3dd82032758e492)
Diffstat (limited to 'src')
-rw-r--r--src/commit/commit-algorithm.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/commit/commit-algorithm.cpp b/src/commit/commit-algorithm.cpp
index 89a6dfe..ad775df 100644
--- a/src/commit/commit-algorithm.cpp
+++ b/src/commit/commit-algorithm.cpp
@@ -1136,6 +1136,21 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2)
CfgNode *root = getCommitTree(&cfg1, &cfg2, p);
if (!root) {
OUTPUT_USER("No configuration changes to commit\n");
+ /* call the low-level commitConfig() function with a dummy structure
+ * representing successful commit on the whole tree. this is equivalent
+ * to copying the whole working config back to the active config. since
+ * the two are "logically" the same, this is redundant in most cases.
+ * however, in some cases, this gives the low-level implementation a
+ * chance to clean up any intermediate state that are no longer needed.
+ */
+ Cpath rp;
+ auto_ptr<CfgNode> cn(new CfgNode(rp, NULL, NULL, NULL, 0, &cs, false));
+ PrioNode pn(cn.get());
+ pn.setSucceeded(true);
+ if (!cs.commitConfig(pn)) {
+ OUTPUT_USER("Failed to generate committed config\n");
+ return false;
+ }
return true;
}
@@ -1186,6 +1201,9 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2)
OUTPUT_USER("Failed to clear committed markers\n");
ret = false;
}
+ if (ret) {
+ ret = cs.markSessionUnsaved();
+ }
return ret;
}