Flush only automatically. Stay in handle_messages as long as data is available.
This commit is contained in:
parent
a52a13584b
commit
ce759ccbe6
@ -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,51 +179,76 @@ int rdp_guac_client_handle_messages(guac_client* client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
do {
|
||||||
|
|
||||||
/* Check the libfreerdp fds */
|
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||||
if (!freerdp_check_fds(rdp_inst)) {
|
|
||||||
guac_error = GUAC_STATUS_BAD_STATE;
|
|
||||||
guac_error_message = "Error handling RDP file descriptors";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check channel fds */
|
/* Check the libfreerdp fds */
|
||||||
if (!freerdp_channels_check_fds(channels, rdp_inst)) {
|
if (!freerdp_check_fds(rdp_inst)) {
|
||||||
guac_error = GUAC_STATUS_BAD_STATE;
|
guac_error = GUAC_STATUS_BAD_STATE;
|
||||||
guac_error_message = "Error handling RDP channel file descriptors";
|
guac_error_message = "Error handling RDP file descriptors";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for channel events */
|
/* Check channel fds */
|
||||||
event = freerdp_channels_pop_event(channels);
|
if (!freerdp_channels_check_fds(channels, rdp_inst)) {
|
||||||
if (event) {
|
guac_error = GUAC_STATUS_BAD_STATE;
|
||||||
|
guac_error_message = "Error handling RDP channel file descriptors";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle clipboard events */
|
/* Check for channel events */
|
||||||
|
event = freerdp_channels_pop_event(channels);
|
||||||
|
if (event) {
|
||||||
|
|
||||||
|
/* Handle clipboard events */
|
||||||
#ifdef LEGACY_EVENT
|
#ifdef LEGACY_EVENT
|
||||||
if (event->event_class == CliprdrChannel_Class)
|
if (event->event_class == CliprdrChannel_Class)
|
||||||
guac_rdp_process_cliprdr_event(client, event);
|
guac_rdp_process_cliprdr_event(client, event);
|
||||||
#else
|
#else
|
||||||
if (GetMessageClass(event->id) == CliprdrChannel_Class)
|
if (GetMessageClass(event->id) == CliprdrChannel_Class)
|
||||||
guac_rdp_process_cliprdr_event(client, event);
|
guac_rdp_process_cliprdr_event(client, event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
freerdp_event_free(event);
|
freerdp_event_free(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle RDP disconnect */
|
/* Handle RDP disconnect */
|
||||||
if (freerdp_shall_disconnect(rdp_inst)) {
|
if (freerdp_shall_disconnect(rdp_inst)) {
|
||||||
guac_error = GUAC_STATUS_NO_INPUT;
|
guac_error = GUAC_STATUS_NO_INPUT;
|
||||||
guac_error_message = "RDP server closed connection";
|
guac_error_message = "RDP server closed connection";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
/* Flush any audio */
|
||||||
|
if (guac_client_data->audio != NULL)
|
||||||
|
guac_socket_flush(guac_client_data->audio->stream->socket);
|
||||||
|
|
||||||
/* Flush any audio */
|
/* Reset timeout to 0 seconds */
|
||||||
if (guac_client_data->audio != NULL)
|
timeout.tv_sec = 0;
|
||||||
guac_socket_flush(guac_client_data->audio->stream->socket);
|
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;
|
||||||
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user