libfreerdp-core: fix transport crash, reduce rdpTcp usage
This commit is contained in:
parent
3e414f1840
commit
69b93c322d
@ -771,7 +771,7 @@ int rpc_channel_tls_connect(RpcChannel* channel, int timeout)
|
|||||||
if (!freerdp_tcp_connect(tcp, settings->GatewayHostname, settings->GatewayPort, timeout))
|
if (!freerdp_tcp_connect(tcp, settings->GatewayHostname, settings->GatewayPort, timeout))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!freerdp_tcp_set_blocking_mode(tcp, FALSE))
|
if (!BIO_set_nonblock(tcp->socketBio, TRUE))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
tls = channel->tls = tls_new(settings);
|
tls = channel->tls = tls_new(settings);
|
||||||
|
@ -1091,11 +1091,6 @@ BOOL freerdp_tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeou
|
|||||||
return TRUE;
|
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)
|
BOOL freerdp_tcp_set_keep_alive_mode(rdpTcp* tcp)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -1190,14 +1185,6 @@ int freerdp_tcp_attach(rdpTcp* tcp, int sockfd)
|
|||||||
return 1;
|
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 freerdp_tcp_wait_read(rdpTcp* tcp, DWORD dwMilliSeconds)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
@ -70,14 +70,10 @@ struct rdp_tcp
|
|||||||
};
|
};
|
||||||
|
|
||||||
BOOL freerdp_tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout);
|
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_read(rdpTcp* tcp, DWORD dwMilliSeconds);
|
||||||
int freerdp_tcp_wait_write(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);
|
BOOL freerdp_tcp_set_keep_alive_mode(rdpTcp* tcp);
|
||||||
int freerdp_tcp_attach(rdpTcp* tcp, int sockfd);
|
int freerdp_tcp_attach(rdpTcp* tcp, int sockfd);
|
||||||
HANDLE freerdp_tcp_get_event_handle(rdpTcp* tcp);
|
|
||||||
|
|
||||||
rdpTcp* freerdp_tcp_new(rdpSettings* settings);
|
rdpTcp* freerdp_tcp_new(rdpSettings* settings);
|
||||||
void freerdp_tcp_free(rdpTcp* tcp);
|
void freerdp_tcp_free(rdpTcp* tcp);
|
||||||
|
@ -94,13 +94,13 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
|||||||
|
|
||||||
if (transport->GatewayEnabled)
|
if (transport->GatewayEnabled)
|
||||||
{
|
{
|
||||||
tls = transport->tls = tls_new(transport->settings);
|
tls = transport->tls = tls_new(settings);
|
||||||
transport->layer = TRANSPORT_LAYER_TSG_TLS;
|
transport->layer = TRANSPORT_LAYER_TSG_TLS;
|
||||||
bio = transport->frontBio;
|
bio = transport->frontBio;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transport->tls = tls_new(settings);
|
tls = transport->tls = tls_new(settings);
|
||||||
transport->layer = TRANSPORT_LAYER_TLS;
|
transport->layer = TRANSPORT_LAYER_TLS;
|
||||||
bio = transport->TcpIn->bufferedBio;
|
bio = transport->TcpIn->bufferedBio;
|
||||||
}
|
}
|
||||||
@ -709,7 +709,7 @@ DWORD transport_get_event_handles(rdpTransport* transport, HANDLE* events)
|
|||||||
DWORD nCount = 0;
|
DWORD nCount = 0;
|
||||||
|
|
||||||
if (events)
|
if (events)
|
||||||
events[nCount] = freerdp_tcp_get_event_handle(transport->TcpIn);
|
events[nCount] = transport->TcpIn->event;
|
||||||
nCount++;
|
nCount++;
|
||||||
|
|
||||||
if (transport->ReceiveEvent)
|
if (transport->ReceiveEvent)
|
||||||
@ -823,16 +823,15 @@ int transport_check_fds(rdpTransport* transport)
|
|||||||
|
|
||||||
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
|
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
|
||||||
{
|
{
|
||||||
BOOL status = TRUE;
|
|
||||||
|
|
||||||
transport->blocking = blocking;
|
transport->blocking = blocking;
|
||||||
|
|
||||||
if (!transport->SplitInputOutput)
|
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)
|
void transport_set_gateway_enabled(rdpTransport* transport, BOOL GatewayEnabled)
|
||||||
@ -884,10 +883,16 @@ BOOL transport_disconnect(rdpTransport* transport)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (transport->tls)
|
if (transport->tls)
|
||||||
|
{
|
||||||
tls_free(transport->tls);
|
tls_free(transport->tls);
|
||||||
|
transport->tls = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (transport->TcpIn)
|
if (transport->TcpIn)
|
||||||
|
{
|
||||||
freerdp_tcp_free(transport->TcpIn);
|
freerdp_tcp_free(transport->TcpIn);
|
||||||
|
transport->TcpIn = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transport->TcpIn = NULL;
|
transport->TcpIn = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user