X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Freconnect.c;h=d7357c2025c7a4897c78bac882cc393090d90ce2;hb=0574f71b4b6820cecb8247a6e0269606c8ef2edf;hp=372c2ebdceae167e509082c9324092dfc4be1a16;hpb=36a7b32d790f2cee735520060a9b6221b7ae25ef;p=openvswitch diff --git a/lib/reconnect.c b/lib/reconnect.c index 372c2ebd..d7357c20 100644 --- a/lib/reconnect.c +++ b/lib/reconnect.c @@ -21,10 +21,10 @@ #include #include "poll-loop.h" - -#define THIS_MODULE VLM_reconnect #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(reconnect); + #define STATES \ STATE(VOID, 1 << 0) \ STATE(BACKOFF, 1 << 1) \ @@ -95,9 +95,9 @@ reconnect_create(long long int now) struct reconnect *fsm = xzalloc(sizeof *fsm); fsm->name = xstrdup("void"); - fsm->min_backoff = 1000; - fsm->max_backoff = 8000; - fsm->probe_interval = 5000; + fsm->min_backoff = RECONNECT_DEFAULT_MIN_BACKOFF; + fsm->max_backoff = RECONNECT_DEFAULT_MAX_BACKOFF; + fsm->probe_interval = RECONNECT_DEFAULT_PROBE_INTERVAL; fsm->passive = false; fsm->info = VLL_INFO; @@ -157,7 +157,7 @@ reconnect_set_name(struct reconnect *fsm, const char *name) } /* Return the minimum number of milliseconds to back off between consecutive - * connection attempts. The default is 1000 ms. */ + * connection attempts. The default is RECONNECT_DEFAULT_MIN_BACKOFF. */ int reconnect_get_min_backoff(const struct reconnect *fsm) { @@ -165,7 +165,7 @@ reconnect_get_min_backoff(const struct reconnect *fsm) } /* Return the maximum number of milliseconds to back off between consecutive - * connection attempts. The default is 8000 ms. */ + * connection attempts. The default is RECONNECT_DEFAULT_MAX_BACKOFF. */ int reconnect_get_max_backoff(const struct reconnect *fsm) { @@ -209,12 +209,16 @@ reconnect_get_max_tries(struct reconnect *fsm) * attempts. * * 'min_backoff' must be at least 1000, and 'max_backoff' must be greater than - * or equal to 'min_backoff'. */ + * or equal to 'min_backoff'. + * + * Pass 0 for 'min_backoff' or 'max_backoff' or both to use the defaults. */ void reconnect_set_backoff(struct reconnect *fsm, int min_backoff, int max_backoff) { fsm->min_backoff = MAX(min_backoff, 1000); - fsm->max_backoff = max_backoff ? MAX(max_backoff, 1000) : 8000; + fsm->max_backoff = (max_backoff + ? MAX(max_backoff, 1000) + : RECONNECT_DEFAULT_MAX_BACKOFF); if (fsm->min_backoff > fsm->max_backoff) { fsm->max_backoff = fsm->min_backoff; } @@ -379,7 +383,8 @@ reconnect_disconnected(struct reconnect *fsm, long long int now, int error) /* Tell 'fsm' that a connection or listening attempt is in progress. * * The FSM will start a timer, after which the connection or listening attempt - * will be aborted (by returning RECONNECT_DISCONNECT from reconect_run()). */ + * will be aborted (by returning RECONNECT_DISCONNECT from + * reconnect_run()). */ void reconnect_connecting(struct reconnect *fsm, long long int now) {