aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-10-10 18:47:00 -0500
committerGitHub <noreply@github.com>2025-10-10 18:47:00 -0500
commitbaafe5f4b4454b985ee33d5ff2e9df6213667bc4 (patch)
treeb7574508f134f6580feddf795810af4d72274698 /src/slskd/Application.cs
parentde5103fb7db29a9fff95604de883fd4886e47c88 (diff)
parent515b0910ab63100c7421c30211ff1c932c70c6f5 (diff)
downloadslskd-baafe5f4b4454b985ee33d5ff2e9df6213667bc4.tar.gz
Merge pull request #1472 from slskd/prime-transfers
Implement a number of improvements and bug fixes with download logic
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 48b8fb22..7754c4ef 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -374,14 +374,16 @@ namespace slskd
var connectionOptions = new ConnectionOptions(
readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Read,
writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Write,
- writeQueueSize: OptionsAtStartup.Soulseek.Connection.Buffer.WriteQueue,
+ writeQueueSize: int.MaxValue, // no write queue for peer, server or transfer connections
connectTimeout: OptionsAtStartup.Soulseek.Connection.Timeout.Connect,
inactivityTimeout: OptionsAtStartup.Soulseek.Connection.Timeout.Inactivity,
proxyOptions: proxyOptions);
// os-specific keepalive is configured for long-lived connections for the server and distributed parent/children
- var serverOptions = connectionOptions.With(configureSocketAction: socket => ConfigureSocketKeepAlive(socket, OptionsAtStartup.Soulseek.Connection));
- var distributedOptions = connectionOptions.With(configureSocketAction: socket => ConfigureSocketKeepAlive(socket, OptionsAtStartup.Soulseek.Connection));
+ var serverOptions = connectionOptions.With(configureSocketAction: socket => ConfigureSocketOptions(socket, OptionsAtStartup.Soulseek.Connection));
+ var distributedOptions = connectionOptions.With(
+ writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.WriteQueue, // write queue set to keep distributed children from impacting performance
+ configureSocketAction: socket => ConfigureSocketOptions(socket, OptionsAtStartup.Soulseek.Connection));
var transferOptions = connectionOptions.With(
readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer,
@@ -495,7 +497,7 @@ namespace slskd
return Task.CompletedTask;
}
- private void ConfigureSocketKeepAlive(Socket socket, Options.SoulseekOptions.ConnectionOptions options)
+ private void ConfigureSocketOptions(Socket socket, Options.SoulseekOptions.ConnectionOptions options)
{
/*
os-specific keepalive is configured for long-lived connections for the server and distributed parent/children
@@ -507,6 +509,11 @@ namespace slskd
*/
try
{
+ // these are set in Soulseek.NET too, but to be super, super sure, do it again; these options can cause
+ // I/O loops to hang indefinitely and are suspected to be a cause of 'stuck' transfers
+ socket.SendTimeout = options.Timeout.Inactivity;
+ socket.ReceiveTimeout = options.Timeout.Inactivity;
+
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
if (OperatingSystem.IsWindows() && OptionsAtStartup.Flags.LegacyWindowsTcpKeepalive)
@@ -1391,8 +1398,8 @@ namespace slskd
inactivityTimeout: connection.Timeout.Inactivity,
proxyOptions: proxyPatch);
- serverPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketKeepAlive(socket, options: connection));
- distributedPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketKeepAlive(socket, options: connection));
+ serverPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketOptions(socket, options: connection));
+ distributedPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketOptions(socket, options: connection));
transferPatch = connectionPatch.With(
readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer,