Skip to content

Commit

Permalink
fix unlimited connection limit
Browse files Browse the repository at this point in the history
  • Loading branch information
vazois committed Nov 26, 2024
1 parent 85c88ae commit 101f19b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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 NetworkConnectionLimit = 0;
public int NetworkConnectionLimit = -1;

/// <summary>
/// Creator of device factories
Expand Down
8 changes: 4 additions & 4 deletions libs/server/Servers/GarnetServerTcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class GarnetServerTcp : GarnetServerBase, IServerHook
readonly int networkSendThrottleMax;
readonly NetworkBufferSettings networkBufferSettings;
readonly LimitedFixedBufferPool networkPool;
readonly int connectionLimit;
readonly int networkConnectionLimit;

public IPEndPoint GetEndPoint
{
Expand Down Expand Up @@ -70,10 +70,10 @@ public IEnumerable<IClusterSession> ActiveClusterSessions()
/// <param name="tlsOptions"></param>
/// <param name="networkSendThrottleMax"></param>
/// <param name="logger"></param>
public GarnetServerTcp(string address, int port, int networkBufferSize = default, IGarnetTlsOptions tlsOptions = null, int networkSendThrottleMax = 8, int connectionLimit = -1, ILogger logger = null)
public GarnetServerTcp(string address, int port, int networkBufferSize = default, IGarnetTlsOptions tlsOptions = null, int networkSendThrottleMax = 8, int networkConnectionLimit = -1, ILogger logger = null)
: base(address, port, networkBufferSize, logger)
{
this.connectionLimit = connectionLimit;
this.networkConnectionLimit = networkConnectionLimit;
this.tlsOptions = tlsOptions;
this.networkSendThrottleMax = networkSendThrottleMax;
var serverBufferSize = BufferSizeUtils.ServerBufferSize(new MaxSizeSettings());
Expand Down Expand Up @@ -140,7 +140,7 @@ private unsafe bool HandleNewConnection(SocketAsyncEventArgs e)
if (activeHandlerCount >= 0)
{
var currentActiveHandlerCount = Interlocked.Increment(ref activeHandlerCount);
if (currentActiveHandlerCount > 0 && (connectionLimit == -1 || currentActiveHandlerCount <= connectionLimit))
if (currentActiveHandlerCount > 0 && (networkConnectionLimit == -1 || currentActiveHandlerCount <= networkConnectionLimit))
{
try
{
Expand Down

0 comments on commit 101f19b

Please sign in to comment.