python: Honor zero probe interval in reconnect.py
authorEthan Jackson <ethan@nicira.com>
Thu, 12 Apr 2012 03:42:01 +0000 (20:42 -0700)
committerEthan Jackson <ethan@nicira.com>
Thu, 12 Apr 2012 07:43:22 +0000 (00:43 -0700)
The python reconnect library attempted to send a probe every 0
milliseconds instead of disabling probing when the probe_interval
was zero.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
lib/reconnect.c
python/ovs/reconnect.py

index 7737fcf7e7677f0bb83d658e24582bfddf74bcbf..c7500070cb79c710968a0de555764f08e26fd559 100644 (file)
@@ -541,7 +541,10 @@ reconnect_deadline__(const struct reconnect *fsm)
         return LLONG_MAX;
 
     case S_IDLE:
-        return fsm->state_entered + fsm->probe_interval;
+        if (fsm->probe_interval) {
+            return fsm->state_entered + fsm->probe_interval;
+        }
+        return LLONG_MAX;
 
     case S_RECONNECT:
         return fsm->state_entered;
index 7e58f5041b75b0fbbc76a5b26a916ee1bef75abc..f1da930a7d4dd36e7e4d32d36c3c71040c4a733b 100644 (file)
@@ -112,7 +112,9 @@ class Reconnect(object):
 
         @staticmethod
         def deadline(fsm):
-            return fsm.state_entered + fsm.probe_interval
+            if fsm.probe_interval:
+                return fsm.state_entered + fsm.probe_interval
+            return None
 
         @staticmethod
         def run(fsm, now):
@@ -504,7 +506,9 @@ class Reconnect(object):
               connection is indeed in working order.  (This will only be
               returned if the "probe interval" is nonzero--see
               self.set_probe_interval())."""
-        if now >= self.state.deadline(self):
+
+        deadline = self.state.deadline(self)
+        if deadline is not None and now >= deadline:
             return self.state.run(self, now)
         else:
             return None