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

Message ID 20171007004458.5788-9-blp@ovn.org
State New
Headers show
Series
  • clustering implementation, part 1
Related show

Commit Message

Ben Pfaff Oct. 7, 2017, 12:44 a.m.
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@ovn.org>
---
 lib/jsonrpc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Russell Bryant Oct. 9, 2017, 7:58 p.m. | #1
On Fri, Oct 6, 2017 at 8:44 PM, Ben Pfaff <blp@ovn.org> wrote:
> 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@ovn.org>

Acked-by: Russell Bryant <russell@ovn.org>

Patch

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);