Skip to content

Commit afd7d11

Browse files
committed
encrypt retry fix
1 parent 46213b6 commit afd7d11

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/mongocrypt-ctx-rewrap-many-datakey.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ static mongocrypt_kms_ctx_t *_next_kms_ctx_encrypt(mongocrypt_ctx_t *ctx) {
136136
mongocrypt_ctx_t *dkctx = NULL;
137137

138138
BSON_ASSERT_PARAM(ctx);
139+
_mongocrypt_ctx_rmd_datakey_t *it = rmdctx->datakeys;
140+
141+
/* Check if any need retry */
142+
{
143+
_mongocrypt_ctx_rmd_datakey_t *it = rmdctx->datakeys;
144+
while (it != NULL) {
145+
_mongocrypt_ctx_datakey_t *dkctx = (_mongocrypt_ctx_datakey_t *)it->dkctx;
146+
if (dkctx->kms.should_retry) {
147+
return &dkctx->kms;
148+
}
149+
it = it->next;
150+
}
151+
}
139152

140153
/* No more datakey contexts requiring KMS. */
141154
if (!rmdctx->datakeys_iter) {
@@ -166,6 +179,7 @@ static bool _add_new_datakey(mongocrypt_ctx_t *ctx, key_returned_t *key) {
166179
datakey->dkctx = mongocrypt_ctx_new(ctx->crypt);
167180
datakey->next = rmdctx->datakeys;
168181
datakey->doc = key->doc;
182+
// add KMS
169183
rmdctx->datakeys = datakey; /* Ownership transfer. */
170184

171185
/* Set new provider and master key (rewrapManyDataKeyOpts). */

0 commit comments

Comments
 (0)