@@ -109,10 +109,14 @@ public async ValueTask<bool> ConnectAsync(IPEndPoint endPoint, CancellationToken
109109 }
110110 catch ( OperationCanceledException ex )
111111 {
112- var message = token . IsCancellationRequested
113- ? $ "TCP Socket connect operation was canceled from { LocalEndPoint } to { endPoint } "
114- : $ "TCP Socket connect operation timed out from { LocalEndPoint } to { endPoint } ";
115- Log ( LogLevel . Warning , ex , message ) ;
112+ if ( token . IsCancellationRequested )
113+ {
114+ Log ( LogLevel . Warning , ex , $ "TCP Socket connect operation was canceled from { LocalEndPoint } to { endPoint } ") ;
115+ }
116+ else
117+ {
118+ Log ( LogLevel . Warning , ex , $ "TCP Socket connect operation timed out from { LocalEndPoint } to { endPoint } ") ;
119+ }
116120 }
117121 catch ( Exception ex )
118122 {
@@ -241,9 +245,14 @@ private async ValueTask<int> ReceiveCoreAsync(ISocketClientProvider client, Memo
241245 }
242246 catch ( OperationCanceledException ex )
243247 {
244- Log ( LogLevel . Warning , ex , token . IsCancellationRequested
245- ? $ "TCP Socket receive operation canceled from { _localEndPoint } to { _remoteEndPoint } "
246- : $ "TCP Socket receive operation timed out from { _localEndPoint } to { _remoteEndPoint } ") ;
248+ if ( token . IsCancellationRequested )
249+ {
250+ Log ( LogLevel . Warning , ex , $ "TCP Socket receive operation canceled from { _localEndPoint } to { _remoteEndPoint } ") ;
251+ }
252+ else
253+ {
254+ Log ( LogLevel . Warning , ex , $ "TCP Socket receive operation timed out from { _localEndPoint } to { _remoteEndPoint } ") ;
255+ }
247256 }
248257 catch ( Exception ex )
249258 {
0 commit comments