xfreerdp: added select() timeout

This commit is contained in:
Marc-André Moreau 2011-12-11 18:05:32 -05:00
parent 2ef315820f
commit fcd03260d6
5 changed files with 21 additions and 4 deletions

View File

@ -894,15 +894,18 @@ int xfreerdp_run(freerdp* instance)
int max_fds;
int rcount;
int wcount;
int ret = 0;
void* rfds[32];
void* wfds[32];
fd_set rfds_set;
fd_set wfds_set;
int select_status;
rdpChannels* channels;
int ret = 0;
struct timeval timeout;
memset(rfds, 0, sizeof(rfds));
memset(wfds, 0, sizeof(wfds));
memset(&timeout, 0, sizeof(struct timeval));
if (!freerdp_connect(instance))
return XF_EXIT_CONN_FAILED;
@ -951,7 +954,15 @@ int xfreerdp_run(freerdp* instance)
if (max_fds == 0)
break;
if (select(max_fds + 1, &rfds_set, &wfds_set, NULL, NULL) == -1)
timeout.tv_sec = 5;
select_status = select(max_fds + 1, &rfds_set, &wfds_set, NULL, &timeout);
if (select_status == 0)
{
//freerdp_send_keep_alive(instance);
continue;
}
else if (select_status == -1)
{
/* these are not really errors */
if (!((errno == EAGAIN) ||

View File

@ -108,6 +108,7 @@ FREERDP_API boolean freerdp_disconnect(freerdp* instance);
FREERDP_API boolean freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount);
FREERDP_API boolean freerdp_check_fds(freerdp* instance);
FREERDP_API void freerdp_send_keep_alive(freerdp* instance);
FREERDP_API uint32 freerdp_error_info(freerdp* instance);
FREERDP_API freerdp* freerdp_new();

View File

@ -127,6 +127,11 @@ boolean freerdp_check_fds(freerdp* instance)
return true;
}
void freerdp_send_keep_alive(freerdp* instance)
{
input_send_synchronize_event(instance->context->rdp->input, 0);
}
static int freerdp_send_channel_data(freerdp* instance, int channel_id, uint8* data, int size)
{
return rdp_send_channel_data(instance->context->rdp, channel_id, data, size);

View File

@ -222,7 +222,7 @@ boolean tcp_set_blocking_mode(rdpTcp* tcp, boolean blocking)
if (flags == -1)
{
printf("transport_configure_sockfd: fcntl failed.\n");
printf("tcp_set_blocking_mode: fcntl failed.\n");
return false;
}

View File

@ -357,7 +357,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
return -1;
}
}
else if (strcmp("--nsc", argv[index]) == 0)
else if (strcmp("--nsc", argv[index]) == 0)
{
settings->ns_codec = true;
}