Be slightly pickier about going into fail-open mode.
authorBen Pfaff <blp@nicira.com>
Mon, 28 Jul 2008 14:08:38 +0000 (07:08 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 28 Jul 2008 14:08:38 +0000 (07:08 -0700)
Before, the amount of time disconnected was measured relative to the
last time we connected, that is, the last time connect(2) succeeded.
Thus, if we were connected for a long time, and then disconnected,
we would immediately go into fail-open mode.

This change make the disconnected time relative to the last OpenFlow
message received.  Thus, if we are connected for a long time and
receive plenty of packets, and then disconnect, there will still be
an opportunity to reconnect before failing open.

lib/rconn.c

index 5bd352b..278ab57 100644 (file)
@@ -496,7 +496,7 @@ rconn_is_connected(const struct rconn *rconn)
 int
 rconn_disconnected_duration(const struct rconn *rconn)
 {
-    return rconn_is_connected(rconn) ? 0 : time(0) - rconn->last_connected;
+    return rconn_is_connected(rconn) ? 0 : time(0) - rconn->last_received;
 }
 
 /* Returns the IP address of the peer, or 0 if the peer is not connected over