From 1974dbac0e01a5187e24950cb0506916cd90b94d Mon Sep 17 00:00:00 2001 From: venaas Date: Wed, 3 Jan 2007 13:29:46 +0000 Subject: tlsconnect changes git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@5 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- radsecproxy.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/radsecproxy.c b/radsecproxy.c index 5374403..0a405d1 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -227,7 +227,7 @@ void tlsconnect(struct peer *peer, struct timeval *when, char *text) { struct timeval now; time_t elapsed; unsigned long error; - + pthread_mutex_lock(&peer->lock); if (when && memcmp(&peer->lastconnecttry, when, sizeof(struct timeval))) { /* already reconnected, nothing to do */ @@ -241,16 +241,15 @@ void tlsconnect(struct peer *peer, struct timeval *when, char *text) { for (;;) { printf("tlsconnect: trying to open TLS connection to %s port %s\n", peer->host, peer->port); gettimeofday(&now, NULL); - if (when) { // don't wait first time - elapsed = now.tv_sec - peer->lastconnecttry.tv_sec; - if (peer->connectionok) { - peer->connectionok = 0; - sleep(10); - } else if (elapsed < 5) - sleep(10); - else if (elapsed < 600) - sleep(elapsed * 2); - else + elapsed = now.tv_sec - peer->lastconnecttry.tv_sec; + if (peer->connectionok) { + peer->connectionok = 0; + sleep(10); + } else if (elapsed < 5) + sleep(10); + else if (elapsed < 600) + sleep(elapsed * 2); + else if (elapsed < 10000) /* no sleep at startup */ sleep(900); } if (peer->sockcl >= 0) -- cgit v1.1