From ac59cd69ddb14d3ffc79982a077fcd7bfd9fa9db Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Sun, 21 Apr 2013 11:14:48 -0400 Subject: [PATCH] Check return from kn_init. WiredTiger truncate doesn't require you to position cursors for the range to be truncated. --- c_src/wterl.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/c_src/wterl.c b/c_src/wterl.c index 3eab666..2bcb8b7 100644 --- a/c_src/wterl.c +++ b/c_src/wterl.c @@ -119,7 +119,13 @@ __init_session_and_cursor_cache(WterlConnHandle *conn_handle, WterlCtx *ctx) ctx->session = NULL; return rc; } + ctx->cursors = kh_init(cursors); + if (!ctx->cursors) { + ctx->session->close(ctx->session); + ctx->session = NULL; + return ENOMEM; + } return 0; } @@ -847,14 +853,6 @@ ASYNC_NIF_DECL( item_start.data = start_key.data; item_start.size = start_key.size; start->set_key(start, item_start); - rc = start->search(start); - if (rc != 0) { - start->close(start); - session->close(session, NULL); - enif_mutex_unlock(args->conn_handle->contexts_mutex); - ASYNC_NIF_REPLY(__strerror_term(env, rc)); - return; - } } if (!args->to_last) { @@ -890,15 +888,6 @@ ASYNC_NIF_DECL( item_stop.data = stop_key.data; item_stop.size = stop_key.size; stop->set_key(stop, item_stop); - rc = stop->search(stop); - if (rc != 0) { - start->close(start); - stop->close(stop); - session->close(session, NULL); - enif_mutex_unlock(args->conn_handle->contexts_mutex); - ASYNC_NIF_REPLY(__strerror_term(env, rc)); - return; - } } /* Always pass NULL for URI here because we always specify the range with the