Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vazois committed Nov 26, 2024
1 parent e7df640 commit 85c88ae
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions libs/host/Configuration/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion libs/host/GarnetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libs/host/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libs/server/Servers/GarnetServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public class GarnetServerOptions : ServerOptions
/// <summary>
/// Maximum client connection limit
/// </summary>
public int ConnectionLimit = 0;
public int NetworkConnectionLimit = 0;

/// <summary>
/// Creator of device factories
Expand Down
2 changes: 1 addition & 1 deletion libs/server/Servers/GarnetServerTcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 85c88ae

Please sign in to comment.