Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / python / ovs / jsonrpc.py
index fa66aab..6e7a2cc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, 2011, 2012 Nicira, Inc.
+# Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -226,7 +226,8 @@ class Connection(object):
         return self.received_bytes
 
     def __log_msg(self, title, msg):
-        vlog.dbg("%s: %s %s" % (self.name, title, msg))
+        if vlog.dbg_is_enabled():
+            vlog.dbg("%s: %s %s" % (self.name, title, msg))
 
     def send(self, msg):
         if self.status:
@@ -449,14 +450,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 +519,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: