diff mbox series

[ovs-dev,v4,04/21] ovn-nbctl: Pull up destroying commands from do_nbctl().

Message ID 20180719123632.19617-5-jkbs@redhat.com
State Superseded
Headers show
Series Daemon mode for ovn-nbctl | expand

Commit Message

Jakub Sitnicki July 19, 2018, 12:36 p.m. UTC
Destroy commands in the same routine where they were allocated.

Preparatory work for reusing the main loop in daemon mode.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
---
 ovn/utilities/ovn-nbctl.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index a027553b7..51527741b 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -126,6 +126,13 @@  main(int argc, char *argv[])
 
     main_loop(args, commands, n_commands, idl);
 
+    for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) {
+        ds_destroy(&c->output);
+        table_destroy(c->table);
+        free(c->table);
+        shash_destroy_free_data(&c->options);
+    }
+    free(commands);
     free(args);
     exit(EXIT_SUCCESS);
 }
@@ -4271,13 +4278,7 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
         } else {
             fputs(ds_cstr(ds), stdout);
         }
-        ds_destroy(&c->output);
-        table_destroy(c->table);
-        free(c->table);
-
-        shash_destroy_free_data(&c->options);
     }
-    free(commands);
 
     if (wait_type != NBCTL_WAIT_NONE && status != TXN_UNCHANGED) {
         ovsdb_idl_enable_reconnect(idl);