Skip to content

Commit

Permalink
only retry statusserver-autodetect after successful traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Mauchle committed Sep 17, 2018
1 parent d067512 commit 719094b
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions radsecproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1818,11 +1818,9 @@ void *clientwr(void *arg) {

memset(&timeout, 0, sizeof(struct timespec));

if (conf->statusserver != RSP_STATSRV_OFF) {
gettimeofday(&server->lastrcv, NULL);
gettimeofday(&laststatsrv, NULL);
}
gettimeofday(&server->lastreply, NULL);
server->lastrcv = server->lastreply;
laststatsrv = server->lastreply;

if (conf->pdef->connecter) {
if (!conf->pdef->connecter(server, NULL, server->dynamiclookuparg ? 5 : 0, "clientwr")) {
Expand All @@ -1842,9 +1840,6 @@ void *clientwr(void *arg) {
}
server->state = RSP_SERVER_STATE_CONNECTED;

if (conf->statusserver == RSP_STATSRV_AUTO)
statusserver_requested = 1;

for (;;) {
pthread_mutex_lock(&server->newrq_mutex);
if (!server->newrq) {
Expand Down Expand Up @@ -1929,7 +1924,7 @@ void *clientwr(void *arg) {
}
} else {
if (conf->statusserver == RSP_STATSRV_AUTO && *rqout->rq->buf == RAD_Status_Server) {
if (server->lastrcv.tv_sec >= laststatsrv.tv_sec) {
if (server->lastreply.tv_sec >= laststatsrv.tv_sec) {
debug(DBG_DBG, "clientwr: status server autodetect faild, disabling status server for %s", conf->name);
conf->statusserver = RSP_STATSRV_OFF;
}
Expand All @@ -1956,11 +1951,10 @@ void *clientwr(void *arg) {
}
do_resend = 0;
if (server->state == RSP_SERVER_STATE_CONNECTED && !conf->statusserver == RSP_STATSRV_OFF) {
secs = server->lastrcv.tv_sec > laststatsrv.tv_sec ? server->lastrcv.tv_sec : laststatsrv.tv_sec;
gettimeofday(&now, NULL);
if ((conf->statusserver == RSP_STATSRV_ON && now.tv_sec - secs > STATUS_SERVER_PERIOD) ||
((conf->statusserver == RSP_STATSRV_MINIMAL || conf->statusserver == RSP_STATSRV_AUTO) &&
statusserver_requested && now.tv_sec - laststatsrv.tv_sec > STATUS_SERVER_PERIOD)) {
if ((conf->statusserver == RSP_STATSRV_ON && now.tv_sec - (laststatsrv.tv_sec ? server->lastrcv.tv_sec : laststatsrv.tv_sec) > STATUS_SERVER_PERIOD) ||
(conf->statusserver == RSP_STATSRV_MINIMAL && statusserver_requested && now.tv_sec - laststatsrv.tv_sec > STATUS_SERVER_PERIOD) ||
(conf->statusserver == RSP_STATSRV_AUTO && server->lastreply.tv_sec >= laststatsrv.tv_sec)) {

laststatsrv = now;
statsrvrq = createstatsrvrq();
Expand Down

0 comments on commit 719094b

Please sign in to comment.