@@ -872,11 +872,26 @@ protected virtual async Task<IPooledSocketResult> ExecuteOperationAsync(IOperati
872
872
var b = op . GetBuffer ( ) ;
873
873
874
874
_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 ;
876
883
877
884
//if Get, call BinaryResponse
878
885
_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 ;
880
895
if ( readResult . Success )
881
896
{
882
897
result . Pass ( ) ;
@@ -974,12 +989,12 @@ bool IMemcachedNode.Ping()
974
989
975
990
IOperationResult IMemcachedNode . Execute ( IOperation op )
976
991
{
977
- return this . ExecuteOperation ( op ) ;
992
+ return ExecuteOperation ( op ) ;
978
993
}
979
994
980
995
async Task < IOperationResult > IMemcachedNode . ExecuteAsync ( IOperation op )
981
996
{
982
- return await this . ExecuteOperationAsync ( op ) ;
997
+ return await ExecuteOperationAsync ( op ) ;
983
998
}
984
999
985
1000
async Task < bool > IMemcachedNode . ExecuteAsync ( IOperation op , Action < bool > next )
0 commit comments