Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/libmongoc/doc/mongoc_client_reset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Calling :symbol:`mongoc_client_reset()` prevents resource cleanup in the child p

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.

.. warning::

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.

Parameters
----------

Expand Down
5 changes: 5 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2617,6 +2617,11 @@ mongoc_client_reset(mongoc_client_t *client)
{
BSON_ASSERT_PARAM(client);

if (!client->topology->single_threaded) {
MONGOC_WARNING("mongoc_client_reset called on a pooled client, this is a no-op.");
return;
}

client->generation++;

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