From 85c88aebe9edd2f3d605639059fe1c7c1510bff4 Mon Sep 17 00:00:00 2001 From: Vasileios Zois Date: Mon, 25 Nov 2024 16:37:48 -0800 Subject: [PATCH] addressing comments --- libs/host/Configuration/Options.cs | 8 ++++---- libs/host/GarnetServer.cs | 2 +- libs/host/defaults.conf | 4 ++-- libs/server/Servers/GarnetServerOptions.cs | 2 +- libs/server/Servers/GarnetServerTcp.cs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/host/Configuration/Options.cs b/libs/host/Configuration/Options.cs index 90153a6071..96fdd62433 100644 --- a/libs/host/Configuration/Options.cs +++ b/libs/host/Configuration/Options.cs @@ -339,9 +339,9 @@ internal sealed class Options [Option("maxthreads", Required = false, HelpText = "Maximum worker and completion threads in thread pool, 0 uses the system default.")] public int ThreadPoolMaxThreads { get; set; } - [IntRangeValidation(0, int.MaxValue)] - [Option("connection-limit", Required = false, Default = 0, HelpText = "Maximum number of client connections")] - public int ConnectionLimit { get; set; } + [IntRangeValidation(-1, int.MaxValue)] + [Option("network-connection-limit", Required = false, Default = -1, HelpText = "Maximum number of simultaneously active network connections.")] + public int NetworkConnectionLimit { get; set; } [OptionValidation] [Option("use-azure-storage", Required = false, HelpText = "Use Azure Page Blobs for storage instead of local storage.")] @@ -680,7 +680,7 @@ public GarnetServerOptions GetServerOptions(ILogger logger = null) QuietMode = QuietMode.GetValueOrDefault(), ThreadPoolMinThreads = ThreadPoolMinThreads, ThreadPoolMaxThreads = ThreadPoolMaxThreads, - ConnectionLimit = ConnectionLimit, + NetworkConnectionLimit = NetworkConnectionLimit, DeviceFactoryCreator = useAzureStorage ? () => new AzureStorageNamedDeviceFactory(AzureStorageConnectionString, logger) : () => new LocalStorageNamedDeviceFactory(useNativeDeviceLinux: UseNativeDeviceLinux.GetValueOrDefault(), logger: logger), diff --git a/libs/host/GarnetServer.cs b/libs/host/GarnetServer.cs index c6aa320326..32389d8aa6 100644 --- a/libs/host/GarnetServer.cs +++ b/libs/host/GarnetServer.cs @@ -216,7 +216,7 @@ private void InitializeServer() } // Create Garnet TCP server if none was provided. - this.server ??= new GarnetServerTcp(opts.Address, opts.Port, 0, opts.TlsOptions, opts.NetworkSendThrottleMax, opts.ConnectionLimit, logger); + this.server ??= new GarnetServerTcp(opts.Address, opts.Port, 0, opts.TlsOptions, opts.NetworkSendThrottleMax, opts.NetworkConnectionLimit, logger); storeWrapper = new StoreWrapper(version, redisProtocolVersion, server, store, objectStore, objectStoreSizeTracker, customCommandManager, appendOnlyFile, opts, clusterFactory: clusterFactory, loggerFactory: loggerFactory); diff --git a/libs/host/defaults.conf b/libs/host/defaults.conf index 6edf2cb0f6..aa18841004 100644 --- a/libs/host/defaults.conf +++ b/libs/host/defaults.conf @@ -251,8 +251,8 @@ /* Maximum worker and completion threads in thread pool, 0 uses the system default. */ "ThreadPoolMaxThreads" : 0, - /* Maximum client connection limit. */ - "ConnectionLimit" : 0, + /* Maximum number of simultaneously active network connections. */ + "NetworkConnectionLimit" : -1, /* Use Azure Page Blobs for storage instead of local storage. */ "UseAzureStorage" : false, diff --git a/libs/server/Servers/GarnetServerOptions.cs b/libs/server/Servers/GarnetServerOptions.cs index 2312d9851b..2c57235969 100644 --- a/libs/server/Servers/GarnetServerOptions.cs +++ b/libs/server/Servers/GarnetServerOptions.cs @@ -249,7 +249,7 @@ public class GarnetServerOptions : ServerOptions /// /// Maximum client connection limit /// - public int ConnectionLimit = 0; + public int NetworkConnectionLimit = 0; /// /// Creator of device factories diff --git a/libs/server/Servers/GarnetServerTcp.cs b/libs/server/Servers/GarnetServerTcp.cs index 70918f0284..30422a06de 100644 --- a/libs/server/Servers/GarnetServerTcp.cs +++ b/libs/server/Servers/GarnetServerTcp.cs @@ -140,7 +140,7 @@ private unsafe bool HandleNewConnection(SocketAsyncEventArgs e) if (activeHandlerCount >= 0) { var currentActiveHandlerCount = Interlocked.Increment(ref activeHandlerCount); - if (currentActiveHandlerCount is > 0 && (connectionLimit == 0 || currentActiveHandlerCount <= connectionLimit)) + if (currentActiveHandlerCount > 0 && (connectionLimit == -1 || currentActiveHandlerCount <= connectionLimit)) { try {