Skip to content

Commit

Permalink
Merge pull request #2910 from matt335672/fix_lfn_performance
Browse files Browse the repository at this point in the history
Improve performance on long fat networks (LFNs)
  • Loading branch information
matt335672 authored Mar 22, 2024
2 parents 45df240 + b23d6f8 commit fb34d74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 43 deletions.
17 changes: 0 additions & 17 deletions common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,23 +434,6 @@ g_tcp_socket(void)
}
}

option_len = sizeof(option_value);

if (getsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value,
&option_len) == 0)
{
if (option_value < (1024 * 32))
{
option_value = 1024 * 32;
option_len = sizeof(option_value);
if (setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value,
option_len) < 0)
{
LOG(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}

return rv;
}

Expand Down
4 changes: 3 additions & 1 deletion docs/man/xrdp.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ If set to \fB1\fP, \fBtrue\fP or \fByes\fP, no buffering will be performed in th
\fBtcp_send_buffer_bytes\fP=\fIbuffer_size\fP
.TP
\fBtcp_recv_buffer_bytes\fP=\fIbuffer_size\fP
Specify send/recv buffer sizes in bytes. The default value depends on operating system.
Specify send/recv buffer sizes in bytes. The default value depends on
the operating system. It is recommended not to set these on systems with
dynamic TCP buffer sizing

.TP
\fBtls_ciphers\fP=\fIcipher_suite\fP
Expand Down
5 changes: 4 additions & 1 deletion xrdp/xrdp.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ tcp_nodelay=true
; if the network connection disappear without close messages the connection will be closed
tcp_keepalive=true

; set tcp send/recv buffer (for experts)
; set tcp send/recv buffer
; These parameters are largely historic. On systems with dynamic TCP
; buffer sizes, setting them manually will either impact performance or
; waste memory
#tcp_send_buffer_bytes=32768
#tcp_recv_buffer_bytes=32768

Expand Down
46 changes: 22 additions & 24 deletions xrdp/xrdp_listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,47 +716,45 @@ xrdp_listen_process_startup_params(struct xrdp_listen *self)
if (startup_params->tcp_send_buffer_bytes > 0)
{
bytes = startup_params->tcp_send_buffer_bytes;
LOG(LOG_LEVEL_INFO, "setting send buffer to %d bytes",
bytes);
if (g_sck_set_send_buffer_bytes(ltrans->sck, bytes) != 0)
{
LOG(LOG_LEVEL_WARNING, "error setting send buffer");
}
else if (g_sck_get_send_buffer_bytes(ltrans->sck, &bytes) != 0)
{
LOG(LOG_LEVEL_WARNING, "error getting send buffer");
}
else if (bytes != startup_params->tcp_send_buffer_bytes)
{
LOG(LOG_LEVEL_WARNING, "send buffer set to %d "
"bytes but %d bytes requested", bytes,
startup_params->tcp_send_buffer_bytes);
}
else
{
if (g_sck_get_send_buffer_bytes(ltrans->sck, &bytes) != 0)
{
LOG(LOG_LEVEL_WARNING, "error getting send "
"buffer");
}
else
{
LOG(LOG_LEVEL_INFO, "send buffer set to %d "
"bytes", bytes);
}
LOG(LOG_LEVEL_INFO, "send buffer set to %d bytes", bytes);
}
}
if (startup_params->tcp_recv_buffer_bytes > 0)
{
bytes = startup_params->tcp_recv_buffer_bytes;
LOG(LOG_LEVEL_INFO, "setting recv buffer to %d bytes",
bytes);
if (g_sck_set_recv_buffer_bytes(ltrans->sck, bytes) != 0)
{
LOG(LOG_LEVEL_WARNING, "error setting recv buffer");
}
else if (g_sck_get_recv_buffer_bytes(ltrans->sck, &bytes) != 0)
{
LOG(LOG_LEVEL_WARNING, "error getting recv buffer");
}
else if (bytes != startup_params->tcp_recv_buffer_bytes)
{
LOG(LOG_LEVEL_WARNING, "recv buffer set to %d "
"bytes but %d bytes requested", bytes,
startup_params->tcp_recv_buffer_bytes);
}
else
{
if (g_sck_get_recv_buffer_bytes(ltrans->sck, &bytes) != 0)
{
LOG(LOG_LEVEL_WARNING, "error getting recv "
"buffer");
}
else
{
LOG(LOG_LEVEL_INFO, "recv buffer set to %d "
"bytes", bytes);
}
LOG(LOG_LEVEL_INFO, "recv buffer set to %d bytes", bytes);
}
}
}
Expand Down

0 comments on commit fb34d74

Please sign in to comment.