Browse Source

Fixed CSHARP-217. KillCursor checks whether corresponding server is still connected before trying to acquire a connection and send a kill cursor message.

pull/57/merge
rstam 14 years ago
parent
commit
e33b4c1cac
  1. 24
      Driver/Internal/MongoCursorEnumerator.cs

24
Driver/Internal/MongoCursorEnumerator.cs

@ -219,22 +219,16 @@ namespace MongoDB.Driver.Internal {
private void KillCursor() {
if (openCursorId != 0) {
var connection = AcquireConnection();
try {
KillCursor(connection);
} finally {
cursor.Server.ReleaseConnection(connection);
}
}
}
private void KillCursor(
MongoConnection connection
) {
if (openCursorId != 0) {
try {
using (var message = new MongoKillCursorsMessage(connection, openCursorId)) {
connection.SendMessage(message, SafeMode.False); // no need to use SafeMode for KillCursors
if (serverInstance != null && serverInstance.State == MongoServerState.Connected) {
var connection = cursor.Server.AcquireConnection(cursor.Database, serverInstance);
try {
using (var message = new MongoKillCursorsMessage(connection, openCursorId)) {
connection.SendMessage(message, SafeMode.False); // no need to use SafeMode for KillCursors
}
} finally {
cursor.Server.ReleaseConnection(connection);
}
}
} finally {
openCursorId = 0;

Loading…
Cancel
Save