From 1813250a9e336fff421eba74d4a8906500489b65 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 22 Feb 2026 21:54:26 -0500 Subject: [PATCH] chore: add .worktrees/ to .gitignore for isolated development --- .gitignore | 3 +++ src/NATS.Server/NatsClient.cs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ce6fb8c..2365a4d 100644 --- a/.gitignore +++ b/.gitignore @@ -161,6 +161,9 @@ FodyWeavers.xsd ## Go reference implementation golang/ +## Git worktrees +.worktrees/ + ## OS .DS_Store Thumbs.db diff --git a/src/NATS.Server/NatsClient.cs b/src/NATS.Server/NatsClient.cs index df04363..149a399 100644 --- a/src/NATS.Server/NatsClient.cs +++ b/src/NATS.Server/NatsClient.cs @@ -356,14 +356,14 @@ public sealed class NatsClient : IDisposable continue; } - var currentPingsOut = Interlocked.Increment(ref _pingsOut); - if (currentPingsOut > _options.MaxPingsOut) + if (Volatile.Read(ref _pingsOut) + 1 > _options.MaxPingsOut) { _logger.LogDebug("Client {ClientId} stale connection — closing", Id); await SendErrAndCloseAsync(NatsProtocol.ErrStaleConnection); return; } + var currentPingsOut = Interlocked.Increment(ref _pingsOut); _logger.LogDebug("Client {ClientId} sending PING ({PingsOut}/{MaxPingsOut})", Id, currentPingsOut, _options.MaxPingsOut); try