diff mbox

[ovs-dev,mointor2,8/9] lib: add monitor2 support in ovsdb-idl.

Message ID 20151110174543.GI31271@ovn.org
State Not Applicable
Headers show

Commit Message

Ben Pfaff Nov. 10, 2015, 5:45 p.m. UTC
On Wed, Oct 21, 2015 at 09:45:30PM -0700, Andy Zhou wrote:
> Add support for monitor2. When idl starts to run, monitor2 will be
> attempted first. In case the server is an older version that does
> not recognize monitor2.  IDL will then fall back to use "monitor"
> method.
> 
> Signed-off-by: Andy Zhou <azhou@nicira.com>

One more thing, there's a bit of code that can be factored out of two
switch cases into common code:

Comments

Andy Zhou Nov. 24, 2015, 10:27 a.m. UTC | #1
On Tue, Nov 10, 2015 at 9:45 AM, Ben Pfaff <blp@ovn.org> wrote:
> On Wed, Oct 21, 2015 at 09:45:30PM -0700, Andy Zhou wrote:
>> Add support for monitor2. When idl starts to run, monitor2 will be
>> attempted first. In case the server is an older version that does
>> not recognize monitor2.  IDL will then fall back to use "monitor"
>> method.
>>
>> Signed-off-by: Andy Zhou <azhou@nicira.com>
>
> One more thing, there's a bit of code that can be factored out of two
> switch cases into common code:
>
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index 1a30ad4..0a0c73a 100644
> --- a/lib/ovsdb-idl.c
> +++ b/lib/ovsdb-idl.c
> @@ -358,11 +358,12 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
>          } else if (msg->type == JSONRPC_REPLY
>                     && idl->request_id
>                     && json_equal(idl->request_id, msg->id)) {
> +            json_destroy(idl->request_id);
> +            idl->request_id = NULL;
> +
>              switch (idl->state) {
>              case IDL_S_SCHEMA_REQUESTED:
>                  /* Reply to our "get_schema" request. */
> -                json_destroy(idl->request_id);
> -                idl->request_id = NULL;
>                  idl->schema = json_clone(msg->result);
>                  ovsdb_idl_send_monitor2_request(idl);
>                  idl->state = IDL_S_MONITOR2_REQUESTED;
> @@ -372,8 +373,6 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
>              case IDL_S_MONITOR2_REQUESTED:
>                  /* Reply to our "monitor" or "monitor2" request. */
>                  idl->change_seqno++;
> -                json_destroy(idl->request_id);
> -                idl->request_id = NULL;
>                  ovsdb_idl_clear(idl);
>                  if (idl->state == IDL_S_MONITOR_REQUESTED) {
>                      idl->state = IDL_S_MONITORING;

Thanks, folded in V2
diff mbox

Patch

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 1a30ad4..0a0c73a 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -358,11 +358,12 @@  ovsdb_idl_run(struct ovsdb_idl *idl)
         } else if (msg->type == JSONRPC_REPLY
                    && idl->request_id
                    && json_equal(idl->request_id, msg->id)) {
+            json_destroy(idl->request_id);
+            idl->request_id = NULL;
+
             switch (idl->state) {
             case IDL_S_SCHEMA_REQUESTED:
                 /* Reply to our "get_schema" request. */
-                json_destroy(idl->request_id);
-                idl->request_id = NULL;
                 idl->schema = json_clone(msg->result);
                 ovsdb_idl_send_monitor2_request(idl);
                 idl->state = IDL_S_MONITOR2_REQUESTED;
@@ -372,8 +373,6 @@  ovsdb_idl_run(struct ovsdb_idl *idl)
             case IDL_S_MONITOR2_REQUESTED:
                 /* Reply to our "monitor" or "monitor2" request. */
                 idl->change_seqno++;
-                json_destroy(idl->request_id);
-                idl->request_id = NULL;
                 ovsdb_idl_clear(idl);
                 if (idl->state == IDL_S_MONITOR_REQUESTED) {
                     idl->state = IDL_S_MONITORING;