rconn: Time out connection attempts when the backoff deadline passes.
authorBen Pfaff <blp@nicira.com>
Mon, 14 Jul 2008 20:34:14 +0000 (13:34 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 18 Jul 2008 21:07:03 +0000 (14:07 -0700)
Otherwise, the TCP/IP implementation is responsible for connection
attempt backoff, but we want to have some control over it ourselves.
In particular we want to initially back off faster and to log a
message upon connection attempt retransmission, to make it easier
to see what has happened from the log.

lib/rconn.c

index db21b6c..066a546 100644 (file)
@@ -39,6 +39,7 @@
 #include "buffer.h"
 #include "poll-loop.h"
 #include "ofp-print.h"
+#include "timeval.h"
 #include "util.h"
 #include "vconn.h"
 
@@ -155,6 +156,10 @@ rconn_run(struct rconn *rc)
         } else if (error != EAGAIN) {
             VLOG_WARN("%s: connection failed (%s)", rc->name, strerror(error));
             disconnect(rc, 0);
+        } else if (time(0) >= rc->backoff_deadline) {
+            VLOG_WARN("%s: connection timed out", rc->name);
+            rc->backoff_deadline = TIME_MAX; /* Prevent resetting backoff. */
+            disconnect(rc, 0);
         }
     } else {
         if (rc->probe_interval) {