368
• Lines 134-136: If a message from the remote memory pool was read
correctly, it is translated locally.
• Line 140: The newly initialized or translated message is written to the
remote memory pool.
• Line 145: Close the remote memory pool.
• Line 149: Release remote memory pool.
The last missing piece of the whole process is how the remote replication is set up. It
is all done in the remote_open() routine presented in Listing 18-4.
Listing 18-4. A remote_open routine from the Hello World program with
replication
74
/*
75
* remote_open -- setup the librpmem replication
76
*/
77
static inline RPMEMpool*
78
remote_open(const char *target, const char *poolset, void *pool,
79
size_t pool_size, int *created)
80
{
81
/* fill pool_attributes */
82
struct rpmem_pool_attr pool_attr;
83
memset(&pool_attr, 0, sizeof(pool_attr));
84
strncpy(pool_attr.signature, "HELLO", RPMEM_POOL_HDR_SIG_LEN);
85
86
/* create a remote pool */
87
unsigned nlanes = 1;
88
RPMEMpool *rpp = rpmem_create(target, poolset, pool, pool_
size, &nlanes,
89
&pool_attr);
90
if (rpp) {
91
*created = 1;
92
return rpp;
93
}
94
Chapter 18 remote persistent memory
• Lines 134-136: If a message from the remote memory pool was read
correctly, it is translated locally.
• Line 140: The newly initialized or translated message is written to the
remote memory pool.
• Line 145: Close the remote memory pool.
• Line 149: Release remote memory pool.
The last missing piece of the whole process is how the remote replication is set up. It
is all done in the remote_open() routine presented in Listing 18-4.
Listing 18-4. A remote_open routine from the Hello World program with
replication
74
/*
75
* remote_open -- setup the librpmem replication
76
*/
77
static inline RPMEMpool*
78
remote_open(const char *target, const char *poolset, void *pool,
79
size_t pool_size, int *created)
80
{
81
/* fill pool_attributes */
82
struct rpmem_pool_attr pool_attr;
83
memset(&pool_attr, 0, sizeof(pool_attr));
84
strncpy(pool_attr.signature, "HELLO", RPMEM_POOL_HDR_SIG_LEN);
85
86
/* create a remote pool */
87
unsigned nlanes = 1;
88
RPMEMpool *rpp = rpmem_create(target, poolset, pool, pool_
size, &nlanes,
89
&pool_attr);
90
if (rpp) {
91
*created = 1;
92
return rpp;
93
}
94
Chapter 18 remote persistent memory
