Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
margo
Commits
96deff0b
Commit
96deff0b
authored
May 15, 2017
by
Philip Carns
Browse files
add missing file to repo
parent
abda7fc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/multiplex/svc2-client.c
0 → 100644
View file @
96deff0b
/*
* (C) 2015 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include
<stdio.h>
#include
<assert.h>
#include
<unistd.h>
#include
<abt.h>
#include
"svc2-client.h"
#include
"svc2-proto.h"
/* NOTE: just making these global for test example, would be cleaner if there
* were an instance pointer for the client.
*/
static
hg_id_t
svc2_do_thing_id
=
-
1
;
static
hg_id_t
svc2_do_other_thing_id
=
-
1
;
int
svc2_register_client
(
margo_instance_id
mid
)
{
svc2_do_thing_id
=
MERCURY_REGISTER
(
margo_get_class
(
mid
),
"svc2_do_thing"
,
svc2_do_thing_in_t
,
svc2_do_thing_out_t
,
NULL
);
svc2_do_other_thing_id
=
MERCURY_REGISTER
(
margo_get_class
(
mid
),
"svc2_do_other_thing"
,
svc2_do_other_thing_in_t
,
svc2_do_other_thing_out_t
,
NULL
);
return
(
0
);
}
void
svc2_do_thing
(
margo_instance_id
mid
,
hg_addr_t
svr_addr
,
uint32_t
mplex_id
)
{
hg_handle_t
handle
;
svc2_do_thing_in_t
in
;
svc2_do_thing_out_t
out
;
int
ret
;
hg_size_t
size
;
void
*
buffer
;
const
struct
hg_info
*
hgi
;
/* allocate buffer for bulk transfer */
size
=
512
;
buffer
=
calloc
(
1
,
512
);
assert
(
buffer
);
sprintf
((
char
*
)
buffer
,
"Hello world!
\n
"
);
/* create handle */
ret
=
HG_Create
(
margo_get_context
(
mid
),
svr_addr
,
svc2_do_thing_id
,
&
handle
);
assert
(
ret
==
0
);
/* register buffer for rdma/bulk access by server */
hgi
=
HG_Get_info
(
handle
);
assert
(
hgi
);
ret
=
HG_Bulk_create
(
hgi
->
hg_class
,
1
,
&
buffer
,
&
size
,
HG_BULK_READ_ONLY
,
&
in
.
bulk_handle
);
assert
(
ret
==
0
);
HG_Set_target_id
(
handle
,
mplex_id
);
/* Send rpc. Note that we are also transmitting the bulk handle in the
* input struct. It was set above.
*/
in
.
input_val
=
0
;
margo_forward
(
mid
,
handle
,
&
in
);
/* decode response */
ret
=
HG_Get_output
(
handle
,
&
out
);
assert
(
ret
==
0
);
/* clean up resources consumed by this rpc */
HG_Bulk_free
(
in
.
bulk_handle
);
HG_Free_output
(
handle
,
&
out
);
HG_Destroy
(
handle
);
free
(
buffer
);
return
;
}
void
svc2_do_other_thing
(
margo_instance_id
mid
,
hg_addr_t
svr_addr
,
uint32_t
mplex_id
)
{
hg_handle_t
handle
;
svc2_do_other_thing_in_t
in
;
svc2_do_other_thing_out_t
out
;
int
ret
;
hg_size_t
size
;
void
*
buffer
;
const
struct
hg_info
*
hgi
;
/* allocate buffer for bulk transfer */
size
=
512
;
buffer
=
calloc
(
1
,
512
);
assert
(
buffer
);
sprintf
((
char
*
)
buffer
,
"Hello world!
\n
"
);
/* create handle */
ret
=
HG_Create
(
margo_get_context
(
mid
),
svr_addr
,
svc2_do_other_thing_id
,
&
handle
);
assert
(
ret
==
0
);
/* register buffer for rdma/bulk access by server */
hgi
=
HG_Get_info
(
handle
);
assert
(
hgi
);
ret
=
HG_Bulk_create
(
hgi
->
hg_class
,
1
,
&
buffer
,
&
size
,
HG_BULK_READ_ONLY
,
&
in
.
bulk_handle
);
assert
(
ret
==
0
);
HG_Set_target_id
(
handle
,
mplex_id
);
/* Send rpc. Note that we are also transmitting the bulk handle in the
* input struct. It was set above.
*/
in
.
input_val
=
0
;
margo_forward
(
mid
,
handle
,
&
in
);
/* decode response */
ret
=
HG_Get_output
(
handle
,
&
out
);
assert
(
ret
==
0
);
/* clean up resources consumed by this rpc */
HG_Bulk_free
(
in
.
bulk_handle
);
HG_Free_output
(
handle
,
&
out
);
HG_Destroy
(
handle
);
free
(
buffer
);
return
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment