Skip to content

Commit 6ca206f

Browse files
committed
CDRIVER-1020 ignore hidden secondaries
1 parent 01e52cf commit 6ca206f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/mongoc/mongoc-server-description.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ mongoc_server_description_handle_ismaster (
302302
bool is_secondary = false;
303303
bool is_arbiter = false;
304304
bool is_replicaset = false;
305+
bool is_hidden = false;
305306
const uint8_t *bytes;
306307
uint32_t len;
307308
int num_keys = 0;
@@ -377,13 +378,17 @@ mongoc_server_description_handle_ismaster (
377378
if (! BSON_ITER_HOLDS_DOCUMENT (&iter)) goto failure;
378379
bson_iter_document (&iter, &len, &bytes);
379380
bson_init_static (&sd->tags, bytes, len);
381+
} else if (strcmp ("hidden", bson_iter_key (&iter)) == 0) {
382+
is_hidden = bson_iter_bool (&iter);
380383
}
381384
}
382385

383386
if (is_shard) {
384387
sd->type = MONGOC_SERVER_MONGOS;
385388
} else if (sd->set_name) {
386-
if (is_master) {
389+
if (is_hidden) {
390+
sd->type = MONGOC_SERVER_RS_OTHER;
391+
} else if (is_master) {
387392
sd->type = MONGOC_SERVER_RS_PRIMARY;
388393
} else if (is_secondary) {
389394
sd->type = MONGOC_SERVER_RS_SECONDARY;

0 commit comments

Comments
 (0)