ovn-nbctl: Signal need to try again via an output param.
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.
@@ -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 char * OVS_WARN_UNUSED_RESULT dhcp_options_get(
struct ctl_context *ctx, const char *id, bool must_exist,
const struct nbrec_dhcp_options **);
@@ -165,7 +165,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;
}
}
@@ -4285,9 +4288,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;
@@ -4297,6 +4300,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);
@@ -4454,7 +4459,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
@@ -4469,7 +4475,7 @@ try_again:
table_destroy(c->table);
free(c->table);
}
- return false;
+ *retry = true;
}
/* Frees the current transaction and the underlying IDL and then calls
