Call init when creating first client pool

pull/2/head
Thijs Cadier 9 years ago
parent f9e4280836
commit 9cbe2b03c3

@ -19,6 +19,7 @@ impl ClientPool {
/// Create a new ClientPool
/// See: http://api.mongodb.org/c/current/mongoc_client_pool_t.html
pub fn new(uri: Uri) -> ClientPool {
super::init();
let pool = unsafe {
let pool_ptr = bindings::mongoc_client_pool_new(uri.inner());
assert!(!pool_ptr.is_null());
@ -134,8 +135,6 @@ mod tests {
#[test]
fn test_new_pool_and_pop_client() {
super::super::init();
let uri = Uri::new("mongodb://localhost:27017/");
let pool = ClientPool::new(uri);
@ -152,8 +151,6 @@ mod tests {
#[test]
fn test_new_pool_and_pop_client_in_threads() {
super::super::init();
let uri = Uri::new("mongodb://localhost:27017/");
let pool = ClientPool::new(uri);

@ -26,7 +26,7 @@ static MONGOC_INIT: Once = ONCE_INIT;
/// Init mongo driver, needs to be called once before doing
/// anything else.
pub fn init() {
fn init() {
MONGOC_INIT.call_once(|| {
unsafe { bindings::mongoc_init(); }
});

Loading…
Cancel
Save