Flush only automatically. Stay in handle_messages as long as data is available.

This commit is contained in:
Michael Jumper 2013-05-13 18:38:13 -07:00
parent a52a13584b
commit ce759ccbe6
2 changed files with 61 additions and 37 deletions

View File

@ -125,14 +125,14 @@ int rdp_guac_client_handle_messages(guac_client* client) {
.tv_usec = 250000 .tv_usec = 250000
}; };
/* get rdp fds */ /* Get RDP fds */
if (!freerdp_get_fds(rdp_inst, read_fds, &read_count, write_fds, &write_count)) { if (!freerdp_get_fds(rdp_inst, read_fds, &read_count, write_fds, &write_count)) {
guac_error = GUAC_STATUS_BAD_STATE; guac_error = GUAC_STATUS_BAD_STATE;
guac_error_message = "Unable to read RDP file descriptors"; guac_error_message = "Unable to read RDP file descriptors";
return 1; return 1;
} }
/* get channel fds */ /* Get channel fds */
if (!freerdp_channels_get_fds(channels, rdp_inst, read_fds, &read_count, write_fds, &write_count)) { if (!freerdp_channels_get_fds(channels, rdp_inst, read_fds, &read_count, write_fds, &write_count)) {
guac_error = GUAC_STATUS_BAD_STATE; guac_error = GUAC_STATUS_BAD_STATE;
guac_error_message = "Unable to read RDP channel file descriptors"; guac_error_message = "Unable to read RDP channel file descriptors";
@ -179,6 +179,8 @@ int rdp_guac_client_handle_messages(guac_client* client) {
} }
} }
do {
pthread_mutex_lock(&(guac_client_data->rdp_lock)); pthread_mutex_lock(&(guac_client_data->rdp_lock));
/* Check the libfreerdp fds */ /* Check the libfreerdp fds */
@ -219,12 +221,35 @@ int rdp_guac_client_handle_messages(guac_client* client) {
return 1; return 1;
} }
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
/* Flush any audio */ /* Flush any audio */
if (guac_client_data->audio != NULL) if (guac_client_data->audio != NULL)
guac_socket_flush(guac_client_data->audio->stream->socket); guac_socket_flush(guac_client_data->audio->stream->socket);
/* Reset timeout to 0 seconds */
timeout.tv_sec = 0;
timeout.tv_usec = 0;
/* Construct read fd_set */
max_fd = 0;
FD_ZERO(&rfds);
for (index = 0; index < read_count; index++) {
fd = (int)(long) (read_fds[index]);
if (fd > max_fd)
max_fd = fd;
FD_SET(fd, &rfds);
}
/* Construct write fd_set */
FD_ZERO(&wfds);
for (index = 0; index < write_count; index++) {
fd = (int)(long) (write_fds[index]);
if (fd > max_fd)
max_fd = fd;
FD_SET(fd, &wfds);
}
} while (select(max_fd + 1, &rfds, &wfds, NULL, &timeout) > 0);
/* Success */ /* Success */
return 0; return 0;

View File

@ -491,7 +491,6 @@ void guac_rdp_gdi_set_bounds(rdpContext* context, rdpBounds* bounds) {
} }
void guac_rdp_gdi_end_paint(rdpContext* context) { void guac_rdp_gdi_end_paint(rdpContext* context) {
guac_client* client = ((rdp_freerdp_context*) context)->client; /* IGNORE */
guac_socket_flush(client->socket);
} }