[ovs-dev] [PATCH monitor_cond V3 07/10] lib: add to ovsdb-idl monitor_id

Liran Schour lirans at il.ibm.com
Wed Feb 3 13:53:31 UTC 2016


IDL uses now a uuid to specify a monitoring session that is being
sent to the server on "monitor_cond" request.
This uuid will be used to issue ongoing "monitor_cond_change" requests
for this monitoring session.

Signed-off-by: Liran Schour <lirans at il.ibm.com>
---
 lib/ovsdb-idl.c | 13 +++++++++----
 lib/ovsdb-idl.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 18d4b8b..a05b420 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -86,6 +86,7 @@ enum ovsdb_idl_state {
 struct ovsdb_idl {
     const struct ovsdb_idl_class *class;
     struct jsonrpc_session *session;
+    struct uuid uuid;
     struct shash table_by_name;
     struct ovsdb_idl_table *tables; /* Contains "struct ovsdb_idl_table *"s.*/
     unsigned int change_seqno;
@@ -267,6 +268,7 @@ ovsdb_idl_create(const char *remote, const struct ovsdb_idl_class *class,
     idl->schema = NULL;
 
     hmap_init(&idl->outstanding_txns);
+    uuid_generate(&idl->uuid);
 
     return idl;
 }
@@ -378,7 +380,7 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
             && !strcmp(msg->method, "update2")
             && msg->params->type == JSON_ARRAY
             && msg->params->u.array.n == 2
-            && msg->params->u.array.elems[0]->type == JSON_NULL) {
+            && msg->params->u.array.elems[0]->type == JSON_STRING) {
             /* Database contents changed. */
             ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1],
                                    OVSDB_UPDATE2);
@@ -423,8 +425,8 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
         } else if (msg->type == JSONRPC_NOTIFY
             && !strcmp(msg->method, "update")
             && msg->params->type == JSON_ARRAY
-            && msg->params->u.array.n == 2
-            && msg->params->u.array.elems[0]->type == JSON_NULL) {
+                   && msg->params->u.array.n == 2
+                   && msg->params->u.array.elems[0]->type == JSON_STRING) {
             /* Database contents changed. */
             ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1],
                                    OVSDB_UPDATE);
@@ -935,6 +937,7 @@ ovsdb_idl_send_monitor_request__(struct ovsdb_idl *idl,
     struct shash *schema;
     struct json *monitor_requests;
     struct jsonrpc_msg *msg;
+    char uuid[UUID_LEN + 1];
     size_t i;
 
     schema = parse_schema(idl->schema);
@@ -986,10 +989,12 @@ ovsdb_idl_send_monitor_request__(struct ovsdb_idl *idl,
     free_schema(schema);
 
     json_destroy(idl->request_id);
+
+    snprintf(uuid, sizeof uuid, UUID_FMT, UUID_ARGS(&idl->uuid));
     msg = jsonrpc_create_request(
         method,
         json_array_create_3(json_string_create(idl->class->database),
-                            json_null_create(), monitor_requests),
+                            json_string_create(uuid), monitor_requests),
         &idl->request_id);
     jsonrpc_session_send(idl->session, msg);
 }
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index 136c38c..1cbaf35 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -60,6 +60,7 @@ void ovsdb_idl_set_lock(struct ovsdb_idl *, const char *lock_name);
 bool ovsdb_idl_has_lock(const struct ovsdb_idl *);
 bool ovsdb_idl_is_lock_contended(const struct ovsdb_idl *);
 
+const struct uuid  * ovsdb_idl_get_monitor_id(const 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_enable_reconnect(struct ovsdb_idl *);
-- 
2.1.4





More information about the dev mailing list