Skip to content

Commit eb18fc8

Browse files
committed
protocol update: pass all listCollections results
1 parent 58bc061 commit eb18fc8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/libmongoc/src/mongoc/mongoc-crypt.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,18 @@ _state_need_mongo_collinfo (_state_machine_t *state_machine, bson_error_t *error
340340
goto fail;
341341
}
342342

343-
/* 2. Return the first result (if any) with mongocrypt_ctx_mongo_feed or
343+
/* 2. Return all results (if any) with mongocrypt_ctx_mongo_feed or
344344
* proceed to the next step if nothing was returned. */
345-
if (mongoc_cursor_next (cursor, &collinfo_bson)) {
345+
while (mongoc_cursor_next (cursor, &collinfo_bson)) {
346346
collinfo_bin = mongocrypt_binary_new_from_data ((uint8_t *) bson_get_data (collinfo_bson), collinfo_bson->len);
347347
if (!mongocrypt_ctx_mongo_feed (state_machine->ctx, collinfo_bin)) {
348348
_ctx_check_error (state_machine->ctx, error, true);
349349
goto fail;
350350
}
351-
} else if (mongoc_cursor_error (cursor, error)) {
351+
mongocrypt_binary_destroy (collinfo_bin);
352+
collinfo_bin = NULL;
353+
}
354+
if (mongoc_cursor_error (cursor, error)) {
352355
goto fail;
353356
}
354357

@@ -1395,6 +1398,10 @@ _mongoc_crypt_new (const bson_t *kms_providers,
13951398
crypt->kmsid_to_tlsopts = mcd_mapof_kmsid_to_tlsopts_new ();
13961399
crypt->handle = mongocrypt_new ();
13971400
mongocrypt_setopt_retry_kms (crypt->handle, true);
1401+
if (!mongocrypt_setopt_enable_multiple_collinfo (crypt->handle)) {
1402+
_crypt_check_error (crypt->handle, error, true);
1403+
goto fail;
1404+
}
13981405

13991406
// Stash away a copy of the user's kmsProviders in case we need to lazily
14001407
// load credentials.

0 commit comments

Comments
 (0)