[ovs-dev] [PATCH 2/2] ovsdb: Provide helper function to determine if IDL has ever connected

Justin Pettit jpettit at nicira.com
Thu Jan 14 21:20:25 UTC 2010


---
 lib/ovsdb-idl.c          |    6 ++++++
 lib/ovsdb-idl.h          |    2 ++
 vswitchd/ovs-brcompatd.c |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 635dccc..a4407a5 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -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)
 {
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index fb551b4..88514b9 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -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 {
diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c
index 34162f3..a45bee1 100644
--- a/vswitchd/ovs-brcompatd.c
+++ b/vswitchd/ovs-brcompatd.c
@@ -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);
-- 
1.6.5.5





More information about the dev mailing list