[ovs-dev,v2,06/15] ovn-nbctl: Signal need to try again via an output param.

Message ID 20180712134016.14336-7-jkbs@redhat.com
State Superseded
Headers show
Series
  • Daemon mode for ovn-nbctl
Related show

Commit Message

Jakub Sitnicki July 12, 2018, 1:40 p.m.
Introduce an output parameter for the flag that signals need to retry
running the command. This leaves the return value for error reporting.

Preparatory work for reusing the main loop in daemon mode.

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

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index a700695fe..360b25a89 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -84,8 +84,8 @@  OVS_NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[], struct shash *local_options);
 static void run_prerequisites(struct ctl_command[], size_t n_commands,
                               struct ovsdb_idl *);
-static bool do_nbctl(const char *args, struct ctl_command *, size_t n,
-                     struct ovsdb_idl *);
+static void do_nbctl(const char *args, struct ctl_command *, size_t n,
+                     struct ovsdb_idl *, bool *retry);
 static const struct nbrec_dhcp_options *dhcp_options_get(
     struct ctl_context *ctx, const char *id, bool must_exist);
 static void main_loop(const char *args, struct ctl_command *commands,
@@ -164,7 +164,10 @@  main_loop(const char *args, struct ctl_command *commands, size_t n_commands,
 
         if (seqno != ovsdb_idl_get_seqno(idl)) {
             seqno = ovsdb_idl_get_seqno(idl);
-            if (do_nbctl(args, commands, n_commands, idl)) {
+
+            bool retry;
+            do_nbctl(args, commands, n_commands, idl, &retry);
+            if (!retry) {
                 return;
             }
         }
@@ -4134,9 +4137,9 @@  run_prerequisites(struct ctl_command *commands, size_t n_commands,
     }
 }
 
-static bool
+static void
 do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
-         struct ovsdb_idl *idl)
+         struct ovsdb_idl *idl, bool *retry)
 {
     struct ovsdb_idl_txn *txn;
     enum ovsdb_idl_txn_status status;
@@ -4146,6 +4149,8 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
     struct shash_node *node;
     int64_t next_cfg = 0;
 
+    ovs_assert(retry);
+
     txn = the_idl_txn = ovsdb_idl_txn_create(idl);
     if (dry_run) {
         ovsdb_idl_txn_set_dry_run(txn);
@@ -4303,7 +4308,8 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
 
     ovsdb_idl_txn_destroy(txn);
 
-    return true;
+    *retry = false;
+    return;
 
 try_again:
     /* Our transaction needs to be rerun, or a prerequisite was not met.  Free
@@ -4318,7 +4324,7 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
         table_destroy(c->table);
         free(c->table);
     }
-    return false;
+    *retry = true;
 }
 
 /* Frees the current transaction and the underlying IDL and then calls