Commit 18186deb authored by Artem Prilutskiy's avatar Artem Prilutskiy

Fixes

parent 7e3491f6
......@@ -24,7 +24,7 @@
#define COUNT(array) sizeof(array) / sizeof(array[0])
#define BUFFER_SIZE 128
#define BUFFER_SIZE 64
#define CLIENT_NAME "DigestPlay " STRING(VERSION) " " BUILD
int main(int argc, char* argv[])
......
......@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/utsname.h>
......@@ -287,10 +288,14 @@ int WaitForRewindSessionEnd(struct RewindContext* context, struct RewindSessionP
struct RewindSessionPollData* response = (struct RewindSessionPollData*)buffer->data;
ssize_t length;
uint32_t control = 0;
uint32_t state = 0b00;
struct timeval now;
struct timeval threshold;
interval += time(NULL);
while (interval > time(NULL))
gettimeofday(&threshold, NULL);
threshold.tv_sec += interval;
do
{
TransmitRewindData(context, REWIND_TYPE_KEEP_ALIVE, REWIND_FLAG_NONE, context->data, context->length);
TransmitRewindData(context, REWIND_TYPE_SESSION_POLL, REWIND_FLAG_NONE, request, sizeof(struct RewindSessionPollData));
......@@ -309,7 +314,7 @@ int WaitForRewindSessionEnd(struct RewindContext* context, struct RewindSessionP
switch (le16toh(buffer->type))
{
case REWIND_TYPE_KEEP_ALIVE:
control |= 0b01;
state |= 0b01;
break;
case REWIND_TYPE_SESSION_POLL:
......@@ -318,18 +323,21 @@ int WaitForRewindSessionEnd(struct RewindContext* context, struct RewindSessionP
// No active sessions
return CLIENT_ERROR_SUCCESS;
}
control |= 0b10;
state |= 0b10;
break;
}
if (control == 0b11)
if (state == 0b11)
{
// Got REWIND_TYPE_KEEP_ALIVE and REWIND_TYPE_SESSION_POLL
// Wait for 2 seconds before the next attempt
sleep(RECEIVE_TIMEOUT);
control = 0b00;
state = 0b00;
}
gettimeofday(&now, NULL);
}
while (timercmp(&now, &threshold, <));
return CLIENT_ERROR_RESPONSE_TIMEOUT;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment