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

Fixups to handle clean shutdown (clients and server).

parent b6798044
......@@ -26,26 +26,31 @@ kv_context *kv_client_register(char *addr_str) {
}
context->put_id = MARGO_REGISTER(context->mid, "put",
put_in_t, put_out_t, NULL);
put_in_t, put_out_t, NULL);
context->put_id = MARGO_REGISTER(context->mid, "put",
put_in_t, put_out_t, NULL);
put_in_t, put_out_t, NULL);
context->bulk_put_id = MARGO_REGISTER(context->mid, "bulk_put",
bulk_put_in_t, bulk_put_out_t, NULL);
context->get_id = MARGO_REGISTER(context->mid, "get",
get_in_t, get_out_t, NULL);
get_in_t, get_out_t, NULL);
context->bulk_get_id = MARGO_REGISTER(context->mid, "bulk_get",
bulk_get_in_t, bulk_get_out_t, NULL);
context->open_id = MARGO_REGISTER(context->mid, "open",
open_in_t, open_out_t, NULL);
open_in_t, open_out_t, NULL);
context->close_id = MARGO_REGISTER(context->mid, "close",
close_in_t, close_out_t, NULL);
close_in_t, close_out_t, NULL);
context->bench_id= MARGO_REGISTER(context->mid, "bench",
bench_in_t, bench_out_t, NULL);
context->shutdown_id= MARGO_REGISTER(context->mid, "shutdown",
void, void, NULL);
return context;
}
......@@ -188,12 +193,6 @@ int kv_close(kv_context *context)
ret = HG_Get_output(handle, &close_out);
assert(ret == HG_SUCCESS);
HG_Free_output(handle, &close_out);
HG_Destroy(context->put_handle);
HG_Destroy(context->get_handle);
HG_Destroy(context->bulk_put_handle);
HG_Destroy(context->bulk_get_handle);
HG_Destroy(context->bench_handle);
HG_Destroy(handle);
return HG_SUCCESS;
}
......@@ -234,17 +233,25 @@ bench_result *kv_benchmark(kv_context *context, int count) {
int kv_client_deregister(kv_context *context) {
int ret;
ret = kv_close(context);
HG_Destroy(context->put_handle);
HG_Destroy(context->get_handle);
HG_Destroy(context->bulk_put_handle);
HG_Destroy(context->bulk_get_handle);
HG_Destroy(context->bench_handle);
HG_Destroy(context->shutdown_handle);
assert(ret == HG_SUCCESS);
ret = margo_addr_free(context->mid, context->svr_addr);
assert(ret == HG_SUCCESS);
margo_finalize(context->mid);
free(context);
return HG_SUCCESS;
}
int kv_shutdown_server(kv_context *context) {
int kv_client_shutdown_server(kv_context *context) {
int ret;
ret = margo_forward(context->shutdown_handle, NULL);
......
......@@ -132,7 +132,11 @@ DECLARE_MARGO_RPC_HANDLER(shutdown_handler)
int kv_client_deregister(kv_context *context);
int kv_server_deregister(kv_context *context);
/* server-side routine */
int kv_server_wait_for_shutdown(kv_context *context);
/* client-side routines wrapping up all the RPC stuff */
int kv_client_shutdown_server(kv_context *context);
int kv_open(kv_context *context, char *server, char *name,
kv_type keytype, kv_type valtype);
int kv_put(kv_context *context, void *key, void *value);
......
......@@ -117,9 +117,10 @@ int main(int argc, char *argv[])
MPI_Barrier(clientComm);
if (rank==1) {
printf("rank %d: sending server a shutdown request\n", rank);
kv_shutdown_server(context);
kv_client_shutdown_server(context);
}
// now finish cleaning up
kv_client_deregister(context);
printf("rank %d: client deregistered\n", rank);
}
......
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