WIP: a bit of cleanup fixes a few mistakes

This commit is contained in:
Gregory Burd 2013-06-04 17:21:50 -04:00
parent f1b7d8322d
commit 778ba20352
4 changed files with 14 additions and 10 deletions

View file

@ -24,7 +24,6 @@
extern "C" {
#endif
#define DEBUG 1
#if !(__STDC_VERSION__ >= 199901L || defined(__GNUC__))
# undef DEBUG
# define DEBUG 0

View file

@ -189,6 +189,7 @@ __ctx_cache_evict(WterlConnHandle *conn_handle)
* Evict anything older than the mean time in queue by removing those
* items from the lists stored in the tree.
*/
num_evicted = 0;
for (itr = kh_begin(h); itr != kh_end(h); ++itr) {
if (kh_exist(h, itr)) {
e = kh_val(h, itr);
@ -277,6 +278,7 @@ __ctx_cache_add(WterlConnHandle *conn_handle, struct wterl_ctx *c)
itr = kh_get(cache_entries, h, c->sig);
if (itr == kh_end(h)) {
e = enif_alloc(sizeof(struct cache_entry)); // TODO: enomem
memset(e, 0, sizeof(struct cache_entry));
SLIST_INIT(&e->contexts);
itr = kh_put(cache_entries, h, c->sig, &itr_status);
kh_value(h, itr) = e;
@ -468,9 +470,11 @@ __close_all_sessions(WterlConnHandle *conn_handle)
for (i = 0; i < ASYNC_NIF_MAX_WORKERS; i++) {
c = conn_handle->last_ctx_used[i];
c->session->close(c->session, NULL);
enif_free(c);
conn_handle->last_ctx_used[i] = NULL;
if (c) {
c->session->close(c->session, NULL);
enif_free(c);
conn_handle->last_ctx_used[i] = NULL;
}
}
khiter_t itr;
for (itr = kh_begin(h); itr != kh_end(h); ++itr) {
@ -688,10 +692,11 @@ ASYNC_NIF_DECL(
int rc = wiredtiger_open(args->homedir,
(WT_EVENT_HANDLER*)&args->priv->eh.handlers,
config.data[0] != 0 ? (const char*)config.data : NULL,
&conn);
(config.size > 1) ? (const char *)config.data : NULL,
&conn);
if (rc == 0) {
WterlConnHandle *conn_handle = enif_alloc_resource(wterl_conn_RESOURCE, sizeof(WterlConnHandle));
memset(conn_handle, 0, sizeof(WterlConnHandle));
if (!conn_handle) {
ASYNC_NIF_REPLY(__strerror_term(env, ENOMEM));
return;
@ -1134,7 +1139,6 @@ ASYNC_NIF_DECL(
}
args->config = enif_make_copy(ASYNC_NIF_WORK_ENV, argv[4]);
enif_keep_resource((void*)args->conn_handle);
affinity = __str_hash(args->uri);
},
{ // work
@ -1603,7 +1607,6 @@ ASYNC_NIF_DECL(
}
args->config = enif_make_copy(ASYNC_NIF_WORK_ENV, argv[2]);
enif_keep_resource((void*)args->conn_handle);
affinity = __str_hash(args->uri);
},
{ // work
@ -1637,6 +1640,7 @@ ASYNC_NIF_DECL(
ASYNC_NIF_REPLY(__strerror_term(env, ENOMEM));
return;
}
memset(cursor_handle, 0, sizeof(WterlCursorHandle));
cursor_handle->session = session;
cursor_handle->cursor = cursor;
ERL_NIF_TERM result = enif_make_resource(env, cursor_handle);

View file

@ -96,7 +96,8 @@ nif_stub_error(Line) ->
-spec init() -> ok | {error, any()}.
init() ->
erlang:load_nif(filename:join([priv_dir(), atom_to_list(?MODULE)]),
[{wterl_vsn, "a1459ce"}, {wiredtiger_vsn, "1.5.2-2-g8f2685b"}]).
[{wterl_vsn, "f1b7d8322da904a3385b97456819afd63ff41afe"},
{wiredtiger_vsn, "1.6.1-a06b59e47db7b120575049bd7d6314df53e78e54"}]).
-spec connection_open(string(), config_list()) -> {ok, connection()} | {error, term()}.
-spec connection_open(string(), config_list(), config_list()) -> {ok, connection()} | {error, term()}.

View file

@ -3,7 +3,7 @@
# Note: also, remember to update version numbers in rpath specs so that shared libs can be found at runtime!!!
wterl=`git log -n 1 --pretty=format:"%H"`
wiredtiger0=`(cd c_src/wiredtiger && git log -n 1 --pretty=format:"%H")`
wiredtiger0=`(cd c_src/wiredtiger-develop && git log -n 1 --pretty=format:"%H")`
wiredtiger=`echo $wiredtiger0 | awk '{print $2}'`
echo $wterl