From: Liran Schour Date: Mon, 18 Jul 2016 08:45:56 +0000 (+0300) Subject: lib: add to ovsdb-idl monitor_id X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=7152b6fa956541448faa6442ae8f178cf26afc6b lib: add to ovsdb-idl monitor_id 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 Signed-off-by: Ben Pfaff --- diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index ae82f1039..0e7cdc591 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -87,6 +87,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; @@ -275,6 +276,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; } @@ -399,7 +401,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); @@ -443,10 +445,10 @@ ovsdb_idl_run(struct ovsdb_idl *idl) OVS_NOT_REACHED(); } } 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) { + && !strcmp(msg->method, "update") + && msg->params->type == JSON_ARRAY + && 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); @@ -989,6 +991,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); @@ -1040,10 +1043,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 5edffc4b6..70449fa3e 100644 --- a/lib/ovsdb-idl.h +++ b/lib/ovsdb-idl.h @@ -61,6 +61,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 *);