aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-09-14 13:09:33 -0700
committerBen Pfaff <blp@nicira.com>2012-09-18 10:23:01 -0700
commitab678217dd626b1bf3f17f784272438e46190834 (patch)
treee6dcbacc93bb2908ea7d2900f09d7c74bb09224d /python
parentaf1ac4b91a1435e7280bec73bc3fd511075d093c (diff)
jsonrpc: Fix Python implementation of inactivity logic.
When a JSON-RPC session receives bytes, or when it successfully sends queued bytes, then it should count that as activity. However, the code here was reversed, in that it used the wrong check in each place. That is, when it tried to receive data, it would check whether data had just been sent, and when it tried to send data, it would check whether data had just been received. Neither one makes sense and doesn't work. Bug #13214. Reported-by: Luca Giraudo <lgiraudo@nicira.com> CC: James Schmidt <jschmidt@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'python')
-rw-r--r--python/ovs/jsonrpc.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/python/ovs/jsonrpc.py b/python/ovs/jsonrpc.py
index fa66aaba..c1540eb7 100644
--- a/python/ovs/jsonrpc.py
+++ b/python/ovs/jsonrpc.py
@@ -449,14 +449,16 @@ class Session(object):
self.pstream = None
if self.rpc:
- received_bytes = self.rpc.get_received_bytes()
+ backlog = self.rpc.get_backlog()
self.rpc.run()
- if received_bytes != self.rpc.get_received_bytes():
- # Data was successfully received.
+ if self.rpc.get_backlog() < backlog:
+ # Data previously caught in a queue was successfully sent (or
+ # there's an error, which we'll catch below).
#
- # Previously we only counted receiving a full message as
- # activity, but with large messages or a slow connection that
- # policy could time out the session mid-message.
+ # We don't count data that is successfully sent immediately as
+ # activity, because there's a lot of queuing downstream from
+ # us, which means that we can push a lot of data into a
+ # connection that has stalled and won't ever recover.
self.reconnect.activity(ovs.timeval.msec())
error = self.rpc.get_status()
@@ -516,16 +518,14 @@ class Session(object):
def recv(self):
if self.rpc is not None:
- backlog = self.rpc.get_backlog()
+ received_bytes = self.rpc.get_received_bytes()
error, msg = self.rpc.recv()
- if self.rpc.get_backlog() < backlog:
- # Data previously caught in a queue was successfully sent (or
- # there's an error, which we'll catch below).
+ if received_bytes != self.rpc.get_received_bytes():
+ # Data was successfully received.
#
- # We don't count data that is successfully sent immediately as
- # activity, because there's a lot of queuing downstream from
- # us, which means that we can push a lot of data into a
- # connection that has stalled and won't ever recover.
+ # Previously we only counted receiving a full message as
+ # activity, but with large messages or a slow connection that
+ # policy could time out the session mid-message.
self.reconnect.activity(ovs.timeval.msec())
if not error: