@@ -872,11 +872,26 @@ protected virtual async Task<IPooledSocketResult> ExecuteOperationAsync(IOperati
872872 var b = op . GetBuffer ( ) ;
873873
874874 _logger . LogDebug ( "pooledSocket.WriteAsync..." ) ;
875- await pooledSocket . WriteAsync ( b ) ;
875+
876+ var writeSocketTask = pooledSocket . WriteAsync ( b ) ;
877+ if ( await Task . WhenAny ( writeSocketTask , Task . Delay ( _config . ConnectionTimeout ) ) != writeSocketTask )
878+ {
879+ result . Fail ( "Timeout to pooledSocket.WriteAsync" ) ;
880+ return result ;
881+ }
882+ await writeSocketTask ;
876883
877884 //if Get, call BinaryResponse
878885 _logger . LogDebug ( $ "{ op } .ReadResponseAsync...") ;
879- var readResult = await op . ReadResponseAsync ( pooledSocket ) ;
886+
887+ var readResponseTask = op . ReadResponseAsync ( pooledSocket ) ;
888+ if ( await Task . WhenAny ( readResponseTask , Task . Delay ( _config . ConnectionTimeout ) ) != readResponseTask )
889+ {
890+ result . Fail ( $ "Timeout to ReadResponseAsync(pooledSocket) for { op } ") ;
891+ return result ;
892+ }
893+
894+ var readResult = await readResponseTask ;
880895 if ( readResult . Success )
881896 {
882897 result . Pass ( ) ;
@@ -974,12 +989,12 @@ bool IMemcachedNode.Ping()
974989
975990 IOperationResult IMemcachedNode . Execute ( IOperation op )
976991 {
977- return this . ExecuteOperation ( op ) ;
992+ return ExecuteOperation ( op ) ;
978993 }
979994
980995 async Task < IOperationResult > IMemcachedNode . ExecuteAsync ( IOperation op )
981996 {
982- return await this . ExecuteOperationAsync ( op ) ;
997+ return await ExecuteOperationAsync ( op ) ;
983998 }
984999
9851000 async Task < bool > IMemcachedNode . ExecuteAsync ( IOperation op , Action < bool > next )
0 commit comments