Commit bb887d86 authored by Philip Carns's avatar Philip Carns

create pmemobj object

parent 4f8196f7
......@@ -5,8 +5,15 @@
*/
#include <assert.h>
#include <libpmemobj.h>
#include "bake-bulk-rpc.h"
/* TODO: this should not be global in the long run; server may provide access
* to multiple targets
*/
extern PMEMobjpool *pmem_pool;
/* service a remote RPC that instructs the server daemon to shut down */
static void bake_bulk_shutdown_ult(hg_handle_t handle)
{
......@@ -39,16 +46,32 @@ DEFINE_MARGO_RPC_HANDLER(bake_bulk_shutdown_ult)
static void bake_bulk_create_ult(hg_handle_t handle)
{
bake_bulk_create_out_t out;
bake_bulk_create_in_t in;
PMEMoid oid;
hg_return_t hret;
printf("Got RPC request to create bulk region.\n");
memset(&out, 0, sizeof(out));
out.ret = -1;
HG_Respond(handle, NULL, NULL, &out);
hret = HG_Get_input(handle, &in);
if(hret != HG_SUCCESS)
{
out.ret = -1;
HG_Respond(handle, NULL, NULL, &out);
HG_Destroy(handle);
return;
}
HG_Destroy(handle);
out.ret = pmemobj_alloc(pmem_pool, &oid, in.region_size, 0, NULL, NULL);
if(out.ret == 0)
{
/* TODO: real translation functions for opaque type */
memcpy(&out.rid, &oid, sizeof(oid));
}
HG_Respond(handle, NULL, NULL, &out);
HG_Destroy(handle);
return;
}
DEFINE_MARGO_RPC_HANDLER(bake_bulk_create_ult)
......
......@@ -14,6 +14,11 @@
#include "bake-bulk-rpc.h"
/* TODO: this should not be global in the long run; server may provide access
* to multiple targets
*/
PMEMobjpool *pmem_pool;
int main(int argc, char **argv)
{
int ret;
......@@ -22,7 +27,6 @@ int main(int argc, char **argv)
ABT_pool handler_pool;
hg_context_t *hg_context;
hg_class_t *hg_class;
PMEMobjpool *pmem_pool;
if(argc != 3)
{
......
......@@ -52,6 +52,7 @@ int main(int argc, char **argv)
/* TODO: create appropriate size region */
ret = bake_bulk_create(bti, 1024, &rid);
if(ret != 0)
{
fprintf(stderr, "Error: bake_bulk_create()\n");
return(-1);
......
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