diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs index 4abf6ff75c812..343c9c9126b4e 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs @@ -844,7 +844,7 @@ public bool StartAsyncOperation(SocketAsyncContext context, TOperation operation } } - public AsyncOperation? ProcessSyncEventOrGetAsyncEvent(SocketAsyncContext context, bool skipAsyncEvents = false, bool processAsyncEvents = true) + public AsyncOperation? ProcessSyncEventOrGetAsyncEvent(SocketAsyncContext context, bool skipAsyncEvents = false) { AsyncOperation op; using (Lock()) @@ -865,7 +865,6 @@ public bool StartAsyncOperation(SocketAsyncContext context, TOperation operation Debug.Assert(_isNextOperationSynchronous == (op.Event != null)); if (skipAsyncEvents && !_isNextOperationSynchronous) { - Debug.Assert(!processAsyncEvents); // Return the operation to indicate that the async operation was not processed, without making // any state changes because async operations are being skipped return op; @@ -903,11 +902,6 @@ public bool StartAsyncOperation(SocketAsyncContext context, TOperation operation { // Async operation. The caller will figure out how to process the IO. Debug.Assert(!skipAsyncEvents); - if (processAsyncEvents) - { - op.Process(); - return null; - } return op; } } @@ -2079,12 +2073,14 @@ public void HandleEventsInline(Interop.Sys.SocketEvents events) if ((events & Interop.Sys.SocketEvents.Read) != 0) { - _receiveQueue.ProcessSyncEventOrGetAsyncEvent(this, processAsyncEvents: true); + AsyncOperation? receiveOperation = _receiveQueue.ProcessSyncEventOrGetAsyncEvent(this); + receiveOperation?.Process(); } if ((events & Interop.Sys.SocketEvents.Write) != 0) { - _sendQueue.ProcessSyncEventOrGetAsyncEvent(this, processAsyncEvents: true); + AsyncOperation? sendOperation = _sendQueue.ProcessSyncEventOrGetAsyncEvent(this); + sendOperation?.Process(); } }