ovsdb: Provide helper function to determine if IDL has ever connected
authorJustin Pettit <jpettit@nicira.com>
Thu, 14 Jan 2010 21:10:35 +0000 (13:10 -0800)
committerJustin Pettit <jpettit@nicira.com>
Thu, 14 Jan 2010 21:10:35 +0000 (13:10 -0800)
lib/ovsdb-idl.c
lib/ovsdb-idl.h
vswitchd/ovs-brcompatd.c

index 635dccc..a4407a5 100644 (file)
@@ -291,6 +291,12 @@ ovsdb_idl_get_seqno(const struct ovsdb_idl *idl)
     return idl->change_seqno;
 }
 
+bool
+ovsdb_idl_has_ever_connected(const struct ovsdb_idl *idl)
+{
+    return ovsdb_idl_get_seqno(idl) != 0;
+}
+
 void
 ovsdb_idl_force_reconnect(struct ovsdb_idl *idl)
 {
index fb551b4..88514b9 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef OVSDB_IDL_H
 #define OVSDB_IDL_H 1
 
+#include <stdbool.h>
 #include <stdint.h>
 
 struct json;
@@ -29,6 +30,7 @@ void ovsdb_idl_run(struct ovsdb_idl *);
 void ovsdb_idl_wait(struct ovsdb_idl *);
 
 unsigned int ovsdb_idl_get_seqno(const struct ovsdb_idl *);
+bool ovsdb_idl_has_ever_connected(const struct ovsdb_idl *);
 void ovsdb_idl_force_reconnect(struct ovsdb_idl *);
 
 enum ovsdb_idl_txn_status {
index 34162f3..a45bee1 100644 (file)
@@ -1190,7 +1190,7 @@ main(int argc, char *argv[])
         ovs = ovsrec_open_vswitch_first(idl);
         brc_recv_update(ovs);
 
-        if (!ovs && ovsdb_idl_get_seqno(idl)) {
+        if (!ovs && ovsdb_idl_has_ever_connected(idl)) {
             static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
             VLOG_WARN_RL(&rl, "%s: database does not contain any Open vSwitch "
                          "configuration", remote);