Commit 64070223 authored by David Rich's avatar David Rich Committed by Rob Latham
Browse files

Move BwTree instantiation to server register function. Make sure and check return values.

parent 33ec1380
......@@ -74,8 +74,7 @@ hg_return_t kv_open(kv_context *context, char * server, char *name,
assert(ret == HG_SUCCESS);
ret = margo_get_output(handle, &open_out);
assert(ret == HG_SUCCESS);
ret = open_out.ret;
assert(ret == HG_SUCCESS);
assert(open_out.ret == HG_SUCCESS);
/* set up the other calls here: idea is we'll pay the registration cost
* once here but can reuse the handles and identifiers multiple times*/
......@@ -120,6 +119,7 @@ hg_return_t kv_put(kv_context *context, void *key, void *value) {
assert(ret == HG_SUCCESS);
ret = margo_get_output(context->put_handle, &put_out);
assert(ret == HG_SUCCESS);
assert(put_out.ret == HG_SUCCESS);
margo_free_output(context->put_handle, &put_out);
return ret;
}
......@@ -154,8 +154,9 @@ hg_return_t kv_get(kv_context *context, void *key, void *value)
ret = margo_forward(context->get_handle, &get_in);
assert(ret == HG_SUCCESS);
ret = margo_get_output(context->get_handle, &get_out);
*(int*) value = get_out.value;
assert(ret == HG_SUCCESS);
assert(get_out.ret == HG_SUCCESS);
*(int*) value = get_out.value;
margo_free_output(context->get_handle, &get_out);
return ret;
}
......@@ -195,6 +196,8 @@ hg_return_t kv_close(kv_context *context)
assert(ret == HG_SUCCESS);
ret = margo_get_output(handle, &close_out);
assert(ret == HG_SUCCESS);
assert(close_out.ret == HG_SUCCESS);
margo_free_output(handle, &close_out);
margo_destroy(handle);
......
......@@ -171,26 +171,19 @@ static hg_return_t open_handler(hg_handle_t handle)
ret = margo_get_input(handle, &in);
if (strcmp(in.name, my_db) == 0) {
if (!TREE) {
printf("SERVER: initializing BwTree instance to manage %s\n", in.name);
TREE = new BwTree<uint64_t, std::vector<char>,
std::less<uint64_t>,
std::equal_to<uint64_t>,
std::hash<uint64_t>,
my_equal_to,
my_hash>();
if (TREE) {
TREE->SetDebugLogging(1);
TREE->UpdateThreadLocal(1);
TREE->AssignGCID(0);
size_t num_threads = TREE->GetThreadNum();
printf("SERVER: BwTree initialized, using %lu thread(s)\n", num_threads);
out.ret = HG_SUCCESS;
}
else {
printf("SERVER: %s already open and BwTree is initialized\n", in.name);
printf("SERVER: BwTree is uninitialized, open failed for %s\n", in.name);
}
out.ret = HG_SUCCESS;
out.ret = HG_OTHER_ERROR;
}
else {
printf("SERVER: currently managing %s and unable to process OPEN request for %s\n", my_db, in.name);
......@@ -559,8 +552,14 @@ kv_context *kv_server_register(margo_instance_id mid);
char addr_self_string[128];
hg_size_t addr_self_string_sz = 128;
kv_context *context;
context = (kv_context *)malloc(sizeof(*context));
/* sds keyval server init */
printf("SERVER: initializing BwTree instance to manage %s\n", my_db);
TREE = new BwTree<uint64_t, std::vector<char>,
std::less<uint64_t>,
std::equal_to<uint64_t>,
std::hash<uint64_t>,
my_equal_to,
my_hash>();
context->mid = mid;
assert(context->mid);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment