From ecf64f40ccd43416233357dc1c91baa459abbb81 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 7 Jun 2013 17:36:01 +1000 Subject: [PATCH] Add some TODO messages and change the reconnect backoff limits --- asyncqueue.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/asyncqueue.c b/asyncqueue.c index 576900e3..e258feb2 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -144,6 +144,9 @@ static int TimedReconnect(void *cntx, int mode) if (self->state != eAsyncConnected) SICSLogPrintf(eStatus, "Function: %s:%s\n", self->queue_name, __func__); + + /* TODO: if self->pSock is NULL we haven't connected yet */ + iRet = NETReconnect(self->pSock); /* * iRet can take the following values: @@ -158,10 +161,10 @@ static int TimedReconnect(void *cntx, int mode) NetWatchSetMode(self->nw_ctx, 0); /* implement an exponential backoff within limits */ self->retryTimer = 2 * self->retryTimer; - if (self->retryTimer < 250) - self->retryTimer = 250; - if (self->retryTimer > 30000) - self->retryTimer = 30000; + if (self->retryTimer < 125) + self->retryTimer = 125; + if (self->retryTimer > 16000) + self->retryTimer = 16000; NetWatchRegisterTimer(&self->nw_tmr, self->retryTimer, TimedReconnect, self); SICSLogPrintf(eStatus, "In %s:%s: state %s => eAsyncWaiting\n", @@ -982,6 +985,7 @@ static pAsyncQueue AQ_Create(const char *host, const char *port) } if (self == NULL) { + /* TODO: if channel (self->pSock) is NULL we haven't connected yet, do it later */ if (channel == NULL) return NULL; @@ -1001,6 +1005,15 @@ static pAsyncQueue AQ_Create(const char *host, const char *port) if (i == queue_index) queue_array[queue_index++] = self; + /* TODO: if self->pSock is NULL we haven't connected yet */ +#if 0 + if (channel == NULL) { + /* TODO: all the rest */ + NetWatchRegisterTimer(&self->nw_tmr, self->retryTimer, TimedReconnect, + self); + } +#endif + return self; }