Skip to content

Commit cdeb33d

Browse files
CDRIVER-3492 mongoc_client_reset should do nothing if passed a multi-threaded client
1 parent 1fcfd8d commit cdeb33d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/libmongoc/doc/mongoc_client_reset.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Calling :symbol:`mongoc_client_reset()` prevents resource cleanup in the child p
2020

2121
This method causes the client to clear its session pool without sending endSessions. It also increments an internal generation counter on the given client. After this method is called, cursors from previous generations will not issue a killCursors command when they are destroyed. Client sessions from previous generations cannot be used and should be destroyed.
2222

23+
.. warning::
24+
25+
This method should only be called on single threaded clients. Calling :symbol:`mongoc_client_reset()` on a multi threaded client is a no-op and will result in a warning.
26+
2327
Parameters
2428
----------
2529

src/libmongoc/src/mongoc/mongoc-client.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,11 @@ mongoc_client_reset(mongoc_client_t *client)
26172617
{
26182618
BSON_ASSERT_PARAM(client);
26192619

2620+
if (!client->topology->single_threaded) {
2621+
MONGOC_WARNING("mongoc_client_reset called on a pooled client, this is a no-op.");
2622+
return;
2623+
}
2624+
26202625
client->generation++;
26212626

26222627
/* Client sessions are owned and destroyed by the user, but we keep

0 commit comments

Comments
 (0)