diff --git a/libfreerdp-core/connection.c b/libfreerdp-core/connection.c index 86a724ddf..aab4a1bc3 100644 --- a/libfreerdp-core/connection.c +++ b/libfreerdp-core/connection.c @@ -107,11 +107,13 @@ boolean rdp_client_connect(rdpRdp* rdp) return false; } + rdp->transport->process_single_pdu = true; while (rdp->state != CONNECTION_STATE_ACTIVE) { if (rdp_check_fds(rdp) < 0) return false; } + rdp->transport->process_single_pdu = false; return true; } diff --git a/libfreerdp-core/transport.c b/libfreerdp-core/transport.c index 25acef876..309214903 100644 --- a/libfreerdp-core/transport.c +++ b/libfreerdp-core/transport.c @@ -377,10 +377,10 @@ int transport_check_fds(rdpTransport** ptransport) stream_set_pos(received, length); stream_seal(received); stream_set_pos(received, 0); - + if (transport->recv_callback(transport, received, transport->recv_extra) == false) status = -1; - + stream_free(received); if (status < 0) @@ -388,6 +388,16 @@ int transport_check_fds(rdpTransport** ptransport) /* transport might now have been freed by rdp_client_redirect and a new rdp->transport created */ transport = *ptransport; + + if (transport->process_single_pdu) + { + /* one at a time but set event if data buffered + * so the main loop will call freerdp_check_fds asap */ + if (stream_get_pos(transport->recv_buffer) > 0) + wait_obj_set(transport->recv_event); + break; + } + } return 0; diff --git a/libfreerdp-core/transport.h b/libfreerdp-core/transport.h index d2a36680b..97ba4ddaf 100644 --- a/libfreerdp-core/transport.h +++ b/libfreerdp-core/transport.h @@ -56,6 +56,7 @@ struct rdp_transport TransportRecv recv_callback; struct wait_obj* recv_event; boolean blocking; + boolean process_single_pdu; /* process single pdu in transport_check_fds */ }; STREAM* transport_recv_stream_init(rdpTransport* transport, int size);