}
}
-void
+bool
ovsdb_idl_run(struct ovsdb_idl *idl)
{
+ unsigned int initial_change_seqno = idl->change_seqno;
int i;
assert(!idl->txn);
}
jsonrpc_msg_destroy(msg);
}
+
+ return initial_change_seqno != idl->change_seqno;
}
void
const struct ovsdb_idl_class *);
void ovsdb_idl_destroy(struct ovsdb_idl *);
-void ovsdb_idl_run(struct ovsdb_idl *);
+bool ovsdb_idl_run(struct ovsdb_idl *);
void ovsdb_idl_wait(struct ovsdb_idl *);
unsigned int ovsdb_idl_get_seqno(const struct ovsdb_idl *);
}
}
-static unsigned int
-print_updated_idl(struct ovsdb_idl *idl, struct jsonrpc *rpc,
- int step, unsigned int seqno)
-{
- for (;;) {
- unsigned int new_seqno;
-
- if (rpc) {
- jsonrpc_run(rpc);
- }
- ovsdb_idl_run(idl);
- new_seqno = ovsdb_idl_get_seqno(idl);
- if (new_seqno != seqno) {
- print_idl(idl, step);
- return new_seqno;
- }
-
- if (rpc) {
- jsonrpc_wait(rpc);
- }
- ovsdb_idl_wait(idl);
- poll_block();
- }
-}
-
static void
parse_uuids(const struct json *json, struct ovsdb_symbol_table *symtab,
size_t *n)
/* The previous transaction didn't change anything. */
arg++;
} else {
- seqno = print_updated_idl(idl, rpc, step++, seqno);
+ /* Wait for update. */
+ while (ovsdb_idl_get_seqno(idl) == seqno && !ovsdb_idl_run(idl)) {
+ jsonrpc_run(rpc);
+
+ ovsdb_idl_wait(idl);
+ jsonrpc_wait(rpc);
+ poll_block();
+ }
+
+ /* Print update. */
+ print_idl(idl, step++);
}
+ seqno = ovsdb_idl_get_seqno(idl);
if (!strcmp(arg, "reconnect")) {
printf("%03d: reconnect\n", step++);
if (rpc) {
jsonrpc_close(rpc);
}
- print_updated_idl(idl, NULL, step++, seqno);
+ while (ovsdb_idl_get_seqno(idl) == seqno && !ovsdb_idl_run(idl)) {
+ ovsdb_idl_wait(idl);
+ poll_block();
+ }
+ print_idl(idl, step++);
ovsdb_idl_destroy(idl);
printf("%03d: done\n", step);
}
main(int argc, char *argv[])
{
struct ovsdb_idl *idl;
- unsigned int seqno;
struct vsctl_command *commands;
size_t n_commands;
char *args;
/* Now execute the commands. */
idl = the_idl = ovsdb_idl_create(db, &ovsrec_idl_class);
- seqno = ovsdb_idl_get_seqno(idl);
trials = 0;
for (;;) {
- unsigned int new_seqno;
-
- ovsdb_idl_run(idl);
- new_seqno = ovsdb_idl_get_seqno(idl);
- if (new_seqno != seqno) {
+ if (ovsdb_idl_run(idl)) {
if (++trials > 5) {
vsctl_fatal("too many database inconsistency failures");
}
do_vsctl(args, commands, n_commands, idl);
- seqno = new_seqno;
}
ovsdb_idl_wait(idl);
struct signal *sighup;
struct ovsdb_idl *idl;
const char *remote;
- bool need_reconfigure;
bool inited, exiting;
- unsigned int idl_seqno;
int retval;
proctitle_init(argc, argv);
daemonize_complete();
idl = ovsdb_idl_create(remote, &ovsrec_idl_class);
- idl_seqno = ovsdb_idl_get_seqno(idl);
- need_reconfigure = false;
inited = false;
exiting = false;
while (!exiting) {
+ bool need_reconfigure;
+
if (signal_poll(sighup)) {
vlog_reopen_log_file();
}
+
+ need_reconfigure = false;
if (inited && bridge_run()) {
need_reconfigure = true;
}
- ovsdb_idl_run(idl);
- if (idl_seqno != ovsdb_idl_get_seqno(idl)) {
- idl_seqno = ovsdb_idl_get_seqno(idl);
+ if (ovsdb_idl_run(idl)) {
need_reconfigure = true;
}
+
if (need_reconfigure) {
const struct ovsrec_open_vswitch *cfg;
- need_reconfigure = false;
cfg = ovsrec_open_vswitch_first(idl);
if (cfg) {
if (inited) {