File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed
Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -356,9 +356,7 @@ private void HandleException(Exception ex)
356356 throw new MongoInternalException ( "Invalid HandleExceptionAction" ) ;
357357 }
358358
359- // forces a call to VerifyState before the next message is sent to this server instance
360- // this is a bit drastic but at least it's safe (and perhaps we can optimize a bit in the future)
361- _serverInstance . SetState ( MongoServerState . Unknown ) ;
359+ _serverInstance . RefreshStateAsSoonAsPossible ( ) ;
362360 }
363361
364362 private enum HandleExceptionAction
Original file line number Diff line number Diff line change @@ -349,6 +349,14 @@ public void Ping()
349349 }
350350 }
351351
352+ /// <summary>
353+ /// Refreshes the state as soon as possible.
354+ /// </summary>
355+ public void RefreshStateAsSoonAsPossible ( )
356+ {
357+ _stateVerificationTimer . Change ( TimeSpan . Zero , TimeSpan . FromSeconds ( 10 ) ) ; // verify state as soon as possible
358+ }
359+
352360 /// <summary>
353361 /// Verifies the state of the server instance.
354362 /// </summary>
Original file line number Diff line number Diff line change @@ -37,10 +37,6 @@ public enum MongoServerState
3737 /// </summary>
3838 ConnectedToSubset ,
3939 /// <summary>
40- /// The state is temporarily unknown.
41- /// </summary>
42- Unknown ,
43- /// <summary>
4440 /// Disconnecting from the server (in progress).
4541 /// </summary>
4642 Disconnecting
Original file line number Diff line number Diff line change @@ -115,6 +115,15 @@ public IEnumerator<TDocument> Execute(IConnectionProvider connectionProvider)
115115 }
116116 }
117117 }
118+ catch
119+ {
120+ if ( reply != null && reply . CursorId != 0 )
121+ {
122+ try { KillCursor ( connectionProvider , reply . CursorId ) ; }
123+ catch { } // ignore exceptions and rethrow the original exception
124+ }
125+ throw ;
126+ }
118127 finally
119128 {
120129 if ( reply != null && reply . CursorId != 0 )
You can’t perform that action at this time.
0 commit comments