Skip to content

Commit

Permalink
don't unset slaveOkay unless rs is set
Browse files Browse the repository at this point in the history
  • Loading branch information
kchodorow committed Dec 27, 2010
1 parent 35ccd2c commit 2298fb6
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions db.c
Expand Up @@ -459,8 +459,9 @@ static char *get_cmd_ns(char *db, int db_len) {
}

PHP_METHOD(MongoDB, command) {
zval limit, slave_okay, *temp, *cmd, *cursor, *ns;
zval limit, *temp, *cmd, *cursor, *ns;
mongo_db *db;
mongo_link *link;
char *cmd_ns;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &cmd) == FAILURE) {
Expand Down Expand Up @@ -494,16 +495,20 @@ PHP_METHOD(MongoDB, command) {
MONGO_METHOD1(MongoCursor, limit, temp, cursor, &limit);

zval_ptr_dtor(&temp);
MAKE_STD_ZVAL(temp);
ZVAL_NULL(temp);

// make sure commands aren't be sent to slaves
Z_TYPE(slave_okay) = IS_BOOL;
Z_LVAL(slave_okay) = 0;
MONGO_METHOD1(MongoCursor, slaveOkay, temp, cursor, &slave_okay);

zval_ptr_dtor(&temp);

PHP_MONGO_GET_LINK(db->link);
if (link->rs) {
zval slave_okay;
Z_TYPE(slave_okay) = IS_BOOL;
Z_LVAL(slave_okay) = 0;

MAKE_STD_ZVAL(temp);
ZVAL_NULL(temp);
MONGO_METHOD1(MongoCursor, slaveOkay, temp, cursor, &slave_okay);
zval_ptr_dtor(&temp);
}

// query
MONGO_METHOD(MongoCursor, getNext, return_value, cursor);

Expand Down

0 comments on commit 2298fb6

Please sign in to comment.