transport: Set server socket as keepalive in transport_default_attach()

Set the same keepalive properties to accepted server socket as are set
to client sockets. This prevents the server from keeping sockets open
for tens of minutes in case the client disappears.

Signed-off-by: Marek Vasut <marex@denx.de>
This commit is contained in:
Marek Vasut 2022-05-06 00:05:16 +02:00 committed by akallabeth
parent 97c05cbec5
commit c5bca8bbbb
3 changed files with 10 additions and 2 deletions

View File

@ -978,7 +978,7 @@ static int freerdp_tcp_connect_multi(rdpContext* context, char** hostnames, UINT
return sockfd;
}
static BOOL freerdp_tcp_set_keep_alive_mode(const rdpSettings* settings, int sockfd)
BOOL freerdp_tcp_set_keep_alive_mode(const rdpSettings* settings, int sockfd)
{
const BOOL keepalive = (freerdp_settings_get_bool(settings, FreeRDP_TcpKeepAlive));
UINT32 optval;

View File

@ -63,6 +63,8 @@
FREERDP_LOCAL BIO_METHOD* BIO_s_simple_socket(void);
FREERDP_LOCAL BIO_METHOD* BIO_s_buffered_socket(void);
FREERDP_LOCAL BOOL freerdp_tcp_set_keep_alive_mode(const rdpSettings* settings, int sockfd);
FREERDP_LOCAL int freerdp_tcp_connect(rdpContext* context, const char* hostname, int port,
DWORD timeout);

View File

@ -160,8 +160,14 @@ static BOOL transport_default_attach(rdpTransport* transport, int sockfd)
{
BIO* socketBio = NULL;
BIO* bufferedBio;
const rdpSettings* settings;
rdpContext* context = transport_get_context(transport);
WINPR_ASSERT(transport);
settings = context->settings;
WINPR_ASSERT(settings);
if (!freerdp_tcp_set_keep_alive_mode(settings, sockfd))
goto fail;
socketBio = BIO_new(BIO_s_simple_socket());