Added watchdog to monitor server connection

This commit is contained in:
Artem Prilutskiy 2016-11-03 08:23:07 +03:00
parent 127db9d89d
commit cabecfe6dd

View file

@ -84,6 +84,7 @@
#define BUFFER_SIZE 2048
#define PROXY_PORT_COUNT 3
#define WATCH_THRESHOLD 20
int serviceMode = MODE_CONSOLE;
@ -394,6 +395,7 @@ int main(int argc, const char* argv[])
// Main loop
bool running = true;
int watchDog = 0;
print("Server started\n");
@ -415,6 +417,12 @@ int main(int argc, const char* argv[])
break;
}
if (watchDog > WATCH_THRESHOLD)
{
print("Server connection timed out\n");
break;
}
for (size_t index = 0; index < count; index ++)
{
#ifdef __linux__
@ -440,6 +448,8 @@ int main(int argc, const char* argv[])
uint16_t type = le16toh(incomingBuffer->type);
size_t length = le16toh(incomingBuffer->length);
watchDog = 0;
if ((type <= REWIND_TYPE_PEER_DATA) &&
(type >= REWIND_TYPE_MEDIA_DATA))
{
@ -477,6 +487,8 @@ int main(int argc, const char* argv[])
struct msghdr message;
struct iovec vectors[2];
watchDog ++;
outgoingBuffer->type = htole16(REWIND_TYPE_BINDING_NOTICE);
outgoingBuffer->length = htole16(sizeof(proxyPorts));