Skip to content

Commit b02c06a

Browse files
author
Christian Hergert
committed
cursor: set slaveok bit when command readPrefs are not PRIMARY.
1 parent 830d849 commit b02c06a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/mongoc/mongoc-cursor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ _mongoc_cursor_new (mongoc_client_t *client,
138138

139139
cursor = bson_malloc0 (sizeof *cursor);
140140

141+
/*
142+
* DRIVERS-63:
143+
*
144+
* If this is a command and we have read_prefs other than PRIMARY, we need to
145+
* set SlaveOK bit in the protocol.
146+
*/
147+
if (is_command &&
148+
read_prefs &&
149+
(mongoc_read_prefs_get_mode (read_prefs) != MONGOC_READ_PRIMARY)) {
150+
flags |= MONGOC_QUERY_SLAVE_OK;
151+
}
152+
141153
/*
142154
* CDRIVER-244:
143155
*

0 commit comments

Comments
 (0)