Add reconnection interval support
This commit is contained in:
parent
6cd15183e8
commit
5bcbfe640b
|
@ -153,6 +153,12 @@ int run_main(Connection* conn, char* quitmsg, unsigned int timeout)
|
||||||
close(sendbuf.fd);
|
close(sendbuf.fd);
|
||||||
close(fifobuf.fd);
|
close(fifobuf.fd);
|
||||||
conn->state = CONN_PENDING;
|
conn->state = CONN_PENDING;
|
||||||
|
if (reconinter == 0)
|
||||||
|
reconinter = 10;
|
||||||
|
else if (reconinter > 300)
|
||||||
|
reconinter = 300;
|
||||||
|
else
|
||||||
|
reconinter *= 2;
|
||||||
continue;
|
continue;
|
||||||
} else if (conn->state == CONN_PENDING) {
|
} else if (conn->state == CONN_PENDING) {
|
||||||
if (ctime - conn->lastconnect < reconinter) continue;
|
if (ctime - conn->lastconnect < reconinter) continue;
|
||||||
|
@ -217,6 +223,7 @@ int run_main(Connection* conn, char* quitmsg, unsigned int timeout)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (conn->state == CONN_ACTIVE) {
|
} else if (conn->state == CONN_ACTIVE) {
|
||||||
|
reconinter = 0;
|
||||||
if (conn->lastmessage < ctime - timeout && conn->lastpong < conn->lastping - timeout) {
|
if (conn->lastmessage < ctime - timeout && conn->lastpong < conn->lastping - timeout) {
|
||||||
LOG(LOG_WARN, "Server " ADDRFMT " didn't respond to a PING in time.", conn->data.addr, conn->data.port);
|
LOG(LOG_WARN, "Server " ADDRFMT " didn't respond to a PING in time.", conn->data.addr, conn->data.port);
|
||||||
conn->state = CONN_RECONNECTING;
|
conn->state = CONN_RECONNECTING;
|
||||||
|
|
Reference in New Issue