[ovs-dev] [PATCH 08/13] jsonrpc: Increment sequence number when connection actually made.

Ben Pfaff blp at ovn.org
Sat Oct 7 00:44:53 UTC 2017


The purpose of the sequence number is to allow the client to figure out
when the connection status has changed.  The significant event for the
client is when a connection completes, not when a connection attempt
starts.  Thus, this commit changes the code to increment the sequence
number at completion, not at the attempt.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/jsonrpc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 36fbdb4a622d..c9e4010b9b39 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -857,7 +857,7 @@ jsonrpc_session_open_unreliably(struct jsonrpc *jsonrpc, uint8_t dscp)
     s->rpc = jsonrpc;
     s->stream = NULL;
     s->pstream = NULL;
-    s->seqno = 0;
+    s->seqno = 1;
 
     return s;
 }
@@ -919,7 +919,6 @@ jsonrpc_session_connect(struct jsonrpc_session *s)
         reconnect_connect_failed(s->reconnect, time_msec(), error);
         jsonrpc_session_pick_remote(s);
     }
-    s->seqno++;
 }
 
 void
@@ -939,6 +938,7 @@ jsonrpc_session_run(struct jsonrpc_session *s)
             }
             reconnect_connected(s->reconnect, time_msec());
             s->rpc = jsonrpc_open(stream);
+            s->seqno++;
         } else if (error != EAGAIN) {
             reconnect_listen_error(s->reconnect, time_msec(), error);
             pstream_close(s->pstream);
@@ -979,6 +979,7 @@ jsonrpc_session_run(struct jsonrpc_session *s)
             reconnect_connected(s->reconnect, time_msec());
             s->rpc = jsonrpc_open(s->stream);
             s->stream = NULL;
+            s->seqno++;
         } else if (error != EAGAIN) {
             reconnect_connect_failed(s->reconnect, time_msec(), error);
             jsonrpc_session_pick_remote(s);
-- 
2.10.2



More information about the dev mailing list