Skip to content

Commit

Permalink
closes #2
Browse files Browse the repository at this point in the history
Check the rv from lcb_wait when connecting
  • Loading branch information
wcummings authored and William Cummings committed Aug 14, 2013
1 parent c4fa851 commit d605654
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 1 addition & 4 deletions c_src/callbacks.c
Expand Up @@ -9,10 +9,7 @@ void error_callback(lcb_t instance,
const char *errinfo)
{
(void)instance;
if(error != LCB_ETIMEDOUT) {
fprintf(stderr, "Fatal error\r\n");
exit(EXIT_FAILURE);
}
// do nothing
}

void get_callback(lcb_t instance,
Expand Down
13 changes: 9 additions & 4 deletions c_src/cb.c
Expand Up @@ -89,12 +89,17 @@ ERL_NIF_TERM cb_connect(ErlNifEnv* env, handle_t* handle, void* obj)
(void)lcb_set_remove_callback(handle->instance, remove_callback);
(void)lcb_set_http_complete_callback(handle->instance, http_callback);

if (lcb_connect(handle->instance) != LCB_SUCCESS) {
return enif_make_tuple2(env, enif_make_atom(env, "error"),
enif_make_string(env, "Failed to connect libcouchbase instance to server\n", ERL_NIF_LATIN1));
err = lcb_connect(handle->instance);

if (err != LCB_SUCCESS) {
return return_lcb_error(env, err);
}

lcb_wait(handle->instance);
err = lcb_wait(handle->instance);

if(err != LCB_SUCCESS) {
return return_lcb_error(env, err);
}

return enif_make_atom(env, "ok");
}
Expand Down

0 comments on commit d605654

Please sign in to comment.