Skip to content

Commit

Permalink
release lock before returning buffers
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
  • Loading branch information
Caleb Lloyd committed Feb 8, 2024
1 parent 3f8cb7b commit 3e24a07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/NATS.Client.Core/Commands/CommandWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ public ValueTask PublishAsync<T>(string subject, T? value, NatsHeaders? headers,
}
finally
{
_semLock.Release();

payloadBuffer.Reset();
_pool.Return(payloadBuffer);

Expand All @@ -336,8 +338,6 @@ public ValueTask PublishAsync<T>(string subject, T? value, NatsHeaders? headers,
headersBuffer.Reset();
_pool.Return(headersBuffer);
}

_semLock.Release();
}

return ValueTask.CompletedTask;
Expand Down

0 comments on commit 3e24a07

Please sign in to comment.