Beispiel #1
0
int mongo_util_pool_refresh(mongo_server *server, time_t timeout TSRMLS_DC) {
  if (server->connected) {
    return SUCCESS;
  }

  // make sure we're disconnected before reconnecting
  mongo_util_pool_close(server, CHECK_CONNS TSRMLS_CC);

  // pass the reduced timeout variable we had set
  stack_monitor *monitor;
  if ((monitor = mongo_util_pool__get_monitor(server TSRMLS_CC)) == 0) {
      return FAILURE;
  }
  timeout = (monitor->timeout > 0) ? monitor->timeout : MONGO_RS_TIMEOUT;

  if (mongo_util_pool_init(server, timeout TSRMLS_CC) == FAILURE) {
    return FAILURE;
  }

  if (mongo_util_pool_get(server, 0 TSRMLS_CC) == FAILURE) {
    return FAILURE;
  }

  // if we get here, we successfully reconnected
  return SUCCESS;
}
Beispiel #2
0
int mongo_util_pool_refresh(mongo_server *server, time_t timeout TSRMLS_DC) {
  if (server->connected) {
    return SUCCESS;
  }

  // make sure we're disconnected before reconnecting
  mongo_util_pool_close(server, CHECK_CONNS TSRMLS_CC);

  if (mongo_util_pool_init(server, timeout TSRMLS_CC) == FAILURE) {
    return FAILURE;
  }

  if (mongo_util_pool_get(server, 0 TSRMLS_CC) == FAILURE) {
    return FAILURE;
  }

  // if we get here, we successfully reconnected
  return SUCCESS;
}