aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application.cs31
-rw-r--r--src/slskd/Core/Extensions.cs6
-rw-r--r--src/slskd/Core/Options.cs9
-rw-r--r--src/slskd/slskd.csproj2
4 files changed, 31 insertions, 17 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 7754c4ef..98226d4f 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -380,14 +380,18 @@ namespace slskd
proxyOptions: proxyOptions);
// os-specific keepalive is configured for long-lived connections for the server and distributed parent/children
- var serverOptions = connectionOptions.With(configureSocketAction: socket => ConfigureSocketOptions(socket, OptionsAtStartup.Soulseek.Connection));
+ var serverOptions = connectionOptions.With(
+ inactivityTimeout: -1, // don't disconnect due to inactivity
+ configureSocket: socket => ConfigureSocketKeepaliveOptions(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));
+ writeQueueSize: OptionsAtStartup.Soulseek.Connection.Buffer.WriteQueue, // write queue set to keep distributed children from impacting performance
+ configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, OptionsAtStartup.Soulseek.Connection));
var transferOptions = connectionOptions.With(
readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer,
- writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer);
+ writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer,
+ inactivityTimeout: OptionsAtStartup.Soulseek.Connection.Timeout.Transfer);
var patch = new SoulseekClientOptionsPatch(
listenIPAddress: IPAddress.Parse(OptionsAtStartup.Soulseek.ListenIpAddress),
@@ -497,7 +501,7 @@ namespace slskd
return Task.CompletedTask;
}
- private void ConfigureSocketOptions(Socket socket, Options.SoulseekOptions.ConnectionOptions options)
+ private void ConfigureSocketKeepaliveOptions(Socket socket, Options.SoulseekOptions.ConnectionOptions options)
{
/*
os-specific keepalive is configured for long-lived connections for the server and distributed parent/children
@@ -509,11 +513,6 @@ 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)
@@ -1398,12 +1397,18 @@ namespace slskd
inactivityTimeout: connection.Timeout.Inactivity,
proxyOptions: proxyPatch);
- serverPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketOptions(socket, options: connection));
- distributedPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketOptions(socket, options: connection));
+ serverPatch = connectionPatch.With(
+ inactivityTimeout: -1, // don't disconnect due to inactivity
+ configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, options: connection));
+
+ distributedPatch = connectionPatch.With(
+ writeQueueSize: connection.Buffer.WriteQueue, // write queue set to keep distributed children from impacting performance
+ configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, options: connection));
transferPatch = connectionPatch.With(
readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer,
- writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer);
+ writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer,
+ inactivityTimeout: connection.Timeout.Transfer);
}
var patch = new SoulseekClientOptionsPatch(
diff --git a/src/slskd/Core/Extensions.cs b/src/slskd/Core/Extensions.cs
index 65942180..db75cc9c 100644
--- a/src/slskd/Core/Extensions.cs
+++ b/src/slskd/Core/Extensions.cs
@@ -51,7 +51,7 @@ namespace slskd
/// <param name="connectTimeout">The connection timeout, in milliseconds, for client and peer TCP connections.</param>
/// <param name="inactivityTimeout">The inactivity timeout, in milliseconds, for peer TCP connections.</param>
/// <param name="proxyOptions">Optional SOCKS 5 proxy configuration options.</param>
- /// <param name="configureSocketAction">
+ /// <param name="configureSocket">
/// The delegate invoked during instantiation to configure the server Socket instance.
/// </param>
/// <returns>The new instance.</returns>
@@ -63,14 +63,14 @@ namespace slskd
int? connectTimeout = null,
int? inactivityTimeout = null,
ProxyOptions proxyOptions = null,
- Action<Socket> configureSocketAction = null) => new ConnectionOptions(
+ Action<Socket> configureSocket = null) => new ConnectionOptions(
readBufferSize: readBufferSize ?? o.ReadBufferSize,
writeBufferSize: writeBufferSize ?? o.WriteBufferSize,
writeQueueSize: writeQueueSize ?? o.WriteQueueSize,
connectTimeout: connectTimeout ?? o.ConnectTimeout,
inactivityTimeout: inactivityTimeout ?? o.InactivityTimeout,
proxyOptions: proxyOptions ?? o.ProxyOptions,
- configureSocket: configureSocketAction ?? o.ConfigureSocket);
+ configureSocket: configureSocket ?? o.ConfigureSocket);
/// <summary>
/// Creates a new instance of <see cref="UserStatisticsState"/> from this instance of <see cref="UserStatistics"/>.
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 352d23e9..38416ca2 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1675,6 +1675,15 @@ namespace slskd
[Description("connection inactivity timeout, in milliseconds")]
[Range(1000, int.MaxValue)]
public int Inactivity { get; init; } = 15000;
+
+ /// <summary>
+ /// Gets the transfer connection timeout, in milliseconds.
+ /// </summary>
+ [Argument(default, "slsk-transfer-timeout")]
+ [EnvironmentVariable("SLSK_TRANSFER_TIMEOUT")]
+ [Description("transfer connection timeout, in milliseconds")]
+ [Range(30_000, int.MaxValue)]
+ public int Transfer { get; init; } = 60000;
}
/// <summary>
diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj
index 7f5c1004..29d362ef 100644
--- a/src/slskd/slskd.csproj
+++ b/src/slskd/slskd.csproj
@@ -68,7 +68,7 @@
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="7.1.1" />
<PackageReference Include="Serilog.Sinks.Http" Version="8.0.0" />
- <PackageReference Include="Soulseek" Version="8.3.0" />
+ <PackageReference Include="Soulseek" Version="8.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>