From 9134fe08581f5cf3d1abfc6e84300ba4c0add245 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 26 Apr 2010 13:18:49 -0400 Subject: [PATCH] tailable cursors have different cursor id semantics --- client/dbclient.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/dbclient.cpp b/client/dbclient.cpp index 6f3a28230df..4a2d7ed3638 100644 --- a/client/dbclient.cpp +++ b/client/dbclient.cpp @@ -818,19 +818,21 @@ namespace mongo { void DBClientCursor::dataReceived() { QueryResult *qr = (QueryResult *) m->data; resultFlags = qr->resultFlags(); - + if ( qr->resultFlags() & QueryResult::ResultFlag_CursorNotFound ) { // cursor id no longer valid at the server. assert( qr->cursorId == 0 ); cursorId = 0; // 0 indicates no longer valid (dead) - throw UserException( 13127 , "getMore: cursor didn't exist on server, possible restart or timeout?" ); + if ( ! ( opts & QueryOption_CursorTailable ) ) + throw UserException( 13127 , "getMore: cursor didn't exist on server, possible restart or timeout?" ); } - + if ( cursorId == 0 || ! ( opts & QueryOption_CursorTailable ) ) { // only set initially: we don't want to kill it on end of data // if it's a tailable cursor cursorId = qr->cursorId; } + nReturned = qr->nReturned; pos = 0; data = qr->data();