X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=python%2Fovs%2Freconnect.py;h=8817494686678d3d3ff8eddc65d02ccdbfece1a4;hb=63b1a5213331cd962be05df57f1375db902216c5;hp=49c7a094cf75d4570f600fd40123e635624e327a;hpb=5eda645e36a9b5dd72c275b7e400dfefcba281d3;p=openvswitch diff --git a/python/ovs/reconnect.py b/python/ovs/reconnect.py index 49c7a094..88174946 100644 --- a/python/ovs/reconnect.py +++ b/python/ovs/reconnect.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 Nicira Networks +# Copyright (c) 2010, 2011 Nicira Networks # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ class Reconnect(object): % (fsm.name, (now - fsm.state_entered) / 1000.0)) return DISCONNECT - class Reconnect: + class Reconnect(object): name = "RECONNECT" is_connected = False @@ -332,15 +332,15 @@ class Reconnect(object): % self.name) else: if self.passive: - type = "listen" + type_ = "listen" else: - type = "connection" + type_ = "connection" if error > 0: logging.warning("%s: %s attempt failed (%s)" - % (self.name, type, os.strerror(error))) + % (self.name, type_, os.strerror(error))) else: self.info_level("%s: %s attempt timed out" - % (self.name, type)) + % (self.name, type_)) if (self.state in (Reconnect.Active, Reconnect.Idle)): self.last_disconnected = now @@ -513,8 +513,8 @@ class Reconnect(object): def timeout(self, now): """Returns the number of milliseconds after which self.run() should be - called if nothing else notable happens in the meantime, or a negative - number if this is currently unnecessary.""" + called if nothing else notable happens in the meantime, or None if this + is currently unnecessary.""" deadline = self.state.deadline(self) if deadline is not None: remaining = deadline - now @@ -558,8 +558,9 @@ class Reconnect(object): stats.is_connected = self.is_connected() stats.msec_since_connect = self.get_last_connect_elapsed(now) stats.msec_since_disconnect = self.get_last_disconnect_elapsed(now) - stats.total_connected_duration = self.total_connected_duration + \ - (self.get_last_connect_elapsed(now) if self.is_connected() else 0) + stats.total_connected_duration = self.total_connected_duration + if self.is_connected(): + stats.total_connected_duration += self.get_last_connect_elapsed(now) stats.n_attempted_connections = self.n_attempted_connections stats.n_successful_connections = self.n_successful_connections stats.state = self.state.name