mirror of
https://github.com/g4klx/DAPNETGateway.git
synced 2026-08-26 12:32:45 -04:00
Merge pull request #11 from dd5xl/master
Moved Flo's variable delay code to recover() to prevent re-logins at f…
This commit is contained in:
commit
18815b7437
2 changed files with 13 additions and 1 deletions
|
|
@ -278,6 +278,9 @@ int CDAPNETGateway::run()
|
|||
}
|
||||
|
||||
bool ok = m_dapnetNetwork->read();
|
||||
if (!ok)
|
||||
recover();
|
||||
/*
|
||||
if (!ok) {
|
||||
int i = 0;
|
||||
const unsigned int backoff[] = {
|
||||
|
|
@ -290,7 +293,7 @@ int CDAPNETGateway::run()
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
CPOCSAGMessage* message = m_dapnetNetwork->readMessage();
|
||||
if (message != NULL) {
|
||||
bool found = true;
|
||||
|
|
@ -404,14 +407,21 @@ void CDAPNETGateway::sendMessages()
|
|||
|
||||
bool CDAPNETGateway::recover()
|
||||
{
|
||||
const unsigned int backoff[] = {2000u, 4000u, 8000u, 10000u, 20000u, 60000u, 120000u, 240000u, 480000u, 600000u};
|
||||
int i=0;
|
||||
|
||||
for (;;) {
|
||||
m_dapnetNetwork->close();
|
||||
CThread::sleep(backoff[i]);
|
||||
|
||||
bool ok = m_dapnetNetwork->open();
|
||||
if (ok) {
|
||||
ok = m_dapnetNetwork->login();
|
||||
if (ok)
|
||||
return true;
|
||||
}
|
||||
if (i < 9)
|
||||
i++;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ bool CDAPNETNetwork::read()
|
|||
unsigned char buffer[BUFFER_LENGTH];
|
||||
|
||||
int length = m_socket.read(buffer, BUFFER_LENGTH, 0U);
|
||||
if (length < 0)
|
||||
LogMessage ("socket.read: received error %d", length);
|
||||
if (length == -1) // Error
|
||||
return false;
|
||||
if (length == -2) // Connection lost
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue