ovs-vsctl: Fix assert-fail when an error occurs and "create" command used.
authorBen Pfaff <blp@nicira.com>
Tue, 18 May 2010 21:16:43 +0000 (14:16 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 17 Jun 2010 17:30:18 +0000 (10:30 -0700)
When the "create" command is used, post_create() calls
ovsdb_idl_txn_get_insert_uuid(), which asserts that the transaction
completed successfully.  This makes it clear that postprocess functions
should only run when the transaction completes successfully.  (Currently
post_create() is the only postprocess function.)

utilities/ovs-vsctl.c

index ba0be30665ca75c67cd23959f8921dff762ea8d6..acc7841cb8062373dcac40f4f96e74c1d21a9a01 100644 (file)
@@ -2604,13 +2604,15 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands,
     if (wait_for_reload && status == TXN_SUCCESS) {
         next_cfg = ovsdb_idl_txn_get_increment_new_value(txn);
     }
-    for (c = commands; c < &commands[n_commands]; c++) {
-        if (c->syntax->postprocess) {
-            struct vsctl_context ctx;
+    if (status == TXN_UNCHANGED || status == TXN_SUCCESS) {
+        for (c = commands; c < &commands[n_commands]; c++) {
+            if (c->syntax->postprocess) {
+                struct vsctl_context ctx;
 
-            vsctl_context_init(&ctx, c, idl, txn, ovs);
-            (c->syntax->postprocess)(&ctx);
-            vsctl_context_done(&ctx, c);
+                vsctl_context_init(&ctx, c, idl, txn, ovs);
+                (c->syntax->postprocess)(&ctx);
+                vsctl_context_done(&ctx, c);
+            }
         }
     }
     error = xstrdup(ovsdb_idl_txn_get_error(txn));