That will be used later to issue "monitor_cond_change" commands.

Signed-off-by: Liran Schour <lir...@il.ibm.com>
---
 lib/ovsdb-idl.c | 19 ++++++++++++++-----
 lib/ovsdb-idl.h |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 18d4b8b..1b8731e 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);
@@ -478,7 +480,11 @@ ovsdb_idl_wait(struct ovsdb_idl *idl)
     jsonrpc_session_wait(idl->session);
     jsonrpc_session_recv_wait(idl->session);
 }
-
+/* Returns the id of the monitor session. */
+const struct uuid * ovsdb_idl_get_monitor_id(const struct ovsdb_idl *idl)
+{
+    return &idl->uuid;
+}
 /* Returns a "sequence number" that represents the state of 'idl'.  When
  * ovsdb_idl_run() changes the database, the sequence number changes.  The
  * initial fetch of the entire contents of the remote database is considered to
@@ -935,6 +941,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 +993,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


_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to