[CDRIVER-209] mongo_cursor_get_more should not call mongo_cursor_destroy Created: 19/Apr/13  Updated: 09/Aug/13  Resolved: 09/Aug/13

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 0.7.1
Fix Version/s: 0.8.1

Type: Bug Priority: Major - P3
Reporter: Daniel Brahneborg Assignee: Gary Murakami
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The function mongo_cursor_get_more() should not call mongo_cursor_destroy(),
because then it's impossible to know whether this should be done in the client,
since all paths just result in MONGO_ERROR being returned.

Diff, which includes the incorrect bson_free mentioned in ticket CDRIVER-208:

diff --git a/src/mongo.c b/src/mongo.c
index c8df093..3487488 100644
— a/src/mongo.c
+++ b/src/mongo.c
@@ -1269,16 +1269,13 @@ static int mongo_cursor_get_more( mongo_cursor *cursor ) {
data = mongo_data_append32( data, &limit );
mongo_data_append64( data, &cursor->reply->fields.cursorID );

  • bson_free( cursor->reply );
    res = mongo_message_send( cursor->conn, mm );
    if( res != MONGO_OK ) { - mongo_cursor_destroy( cursor ); return MONGO_ERROR; }

    res = mongo_read_response( cursor->conn, &( cursor->reply ) );
    if( res != MONGO_OK ) {- mongo_cursor_destroy( cursor ); return MONGO_ERROR; }

    cursor->current.data = NULL;



 Comments   
Comment by auto [ 08/Aug/13 ]

Author:

{u'username': u'gjmurakami-10gen', u'name': u'Gary J. Murakami', u'email': u'gary.murakami@10gen.com'}

Message: mongo_cursor_get_more should not call mongo_cursor_destroy

CDRIVER-209
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/a636d6421eb2705055b4b1b72b148653311aa690

Comment by Daniel Brahneborg [ 23/Apr/13 ]

As far as I can see, both calls must be removed.

Comment by ahmed talha khan [ 23/Apr/13 ]

Encountered the same issue with tailable cursor with mongo restarting. So which one is the better approach? Removing the extraneous bson_free() call which causes a double free on reply? or removing the mongo_cursor_destroy() call?

Generated at Wed Feb 07 21:08:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.