libfreerdp-core: fix transport crash, reduce rdpTcp usage

This commit is contained in:
Marc-André Moreau 2015-02-13 09:27:54 -05:00
parent 3e414f1840
commit 69b93c322d
4 changed files with 13 additions and 25 deletions

View File

@ -771,7 +771,7 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
if (!freerdp_tcp_connect(tcp, settings->GatewayHostname, settings->GatewayPort, timeout))
return -1;
if (!freerdp_tcp_set_blocking_mode(tcp, FALSE))
if (!BIO_set_nonblock(tcp->socketBio, TRUE))
return -1;
tls = channel->tls = tls_new(settings);

View File

@ -1091,11 +1091,6 @@ BOOL freerdp_tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeou
return TRUE;
}
BOOL freerdp_tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking)
{
return BIO_set_nonblock(tcp->socketBio, blocking ? 0 : 1) ? TRUE : FALSE;
}
BOOL freerdp_tcp_set_keep_alive_mode(rdpTcp* tcp)
{
#ifndef _WIN32
@ -1190,14 +1185,6 @@ int freerdp_tcp_attach(rdpTcp* tcp, int sockfd)
return 1;
}
HANDLE freerdp_tcp_get_event_handle(rdpTcp* tcp)
{
if (!tcp)
return NULL;
return tcp->event;
}
int freerdp_tcp_wait_read(rdpTcp* tcp, DWORD dwMilliSeconds)
{
int status;

View File

@ -70,14 +70,10 @@ struct rdp_tcp
};
BOOL freerdp_tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout);
int freerdp_tcp_read(rdpTcp* tcp, BYTE* data, int length);
int freerdp_tcp_write(rdpTcp* tcp, BYTE* data, int length);
int freerdp_tcp_wait_read(rdpTcp* tcp, DWORD dwMilliSeconds);
int freerdp_tcp_wait_write(rdpTcp* tcp, DWORD dwMilliSeconds);
BOOL freerdp_tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking);
BOOL freerdp_tcp_set_keep_alive_mode(rdpTcp* tcp);
int freerdp_tcp_attach(rdpTcp* tcp, int sockfd);
HANDLE freerdp_tcp_get_event_handle(rdpTcp* tcp);
rdpTcp* freerdp_tcp_new(rdpSettings* settings);
void freerdp_tcp_free(rdpTcp* tcp);

View File

@ -94,13 +94,13 @@ BOOL transport_connect_tls(rdpTransport* transport)
if (transport->GatewayEnabled)
{
tls = transport->tls = tls_new(transport->settings);
tls = transport->tls = tls_new(settings);
transport->layer = TRANSPORT_LAYER_TSG_TLS;
bio = transport->frontBio;
}
else
{
transport->tls = tls_new(settings);
tls = transport->tls = tls_new(settings);
transport->layer = TRANSPORT_LAYER_TLS;
bio = transport->TcpIn->bufferedBio;
}
@ -709,7 +709,7 @@ DWORD transport_get_event_handles(rdpTransport* transport, HANDLE* events)
DWORD nCount = 0;
if (events)
events[nCount] = freerdp_tcp_get_event_handle(transport->TcpIn);
events[nCount] = transport->TcpIn->event;
nCount++;
if (transport->ReceiveEvent)
@ -823,16 +823,15 @@ int transport_check_fds(rdpTransport* transport)
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
{
BOOL status = TRUE;
transport->blocking = blocking;
if (!transport->SplitInputOutput)
{
status &= freerdp_tcp_set_blocking_mode(transport->TcpIn, blocking);
if (!BIO_set_nonblock(transport->TcpIn->socketBio, blocking ? FALSE : TRUE))
return FALSE;
}
return status;
return TRUE;
}
void transport_set_gateway_enabled(rdpTransport* transport, BOOL GatewayEnabled)
@ -884,10 +883,16 @@ BOOL transport_disconnect(rdpTransport* transport)
else
{
if (transport->tls)
{
tls_free(transport->tls);
transport->tls = NULL;
}
if (transport->TcpIn)
{
freerdp_tcp_free(transport->TcpIn);
transport->TcpIn = NULL;
}
}
transport->TcpIn = NULL;