Skip to content

Commit 59840ec

Browse files
IgorMilavecRob-Hague
andauthoredApr 27, 2024··
Fix SocketAsyncEventArgsAwaitable calling continuation multiple times (#918)
* Fix SocketAsyncEventArgsAwaitable calling continuation multiple times * Use Interlocked.Exchange --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com>
1 parent 4e1e243 commit 59840ec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎src/Renci.SshNet/Abstractions/SocketExtensions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ public AwaitableSocketAsyncEventArgs ExecuteAsync(Func<SocketAsyncEventArgs, boo
3333
return this;
3434
}
3535

36-
public void SetCompleted()
36+
private void SetCompleted()
3737
{
3838
IsCompleted = true;
39-
40-
var continuation = _continuationAction ?? Interlocked.CompareExchange(ref _continuationAction, SENTINEL, comparand: null);
39+
var continuation = Interlocked.Exchange(ref _continuationAction, SENTINEL);
4140
if (continuation is not null)
4241
{
4342
continuation();

0 commit comments

Comments
 (0)
Please sign in to comment.