Commit 25178977 authored by Anmol Vatsa's avatar Anmol Vatsa

rp_send over remote rp.

handling fulfill in the third cloud pending. circular and local handled.
parent 06a99027
......@@ -1174,6 +1174,38 @@ int cn_dispatch_util_fill_rp_recv_result(cn_dispatch_result_t *result,
return 0;
}
int cn_dispatch_rp_send(struct cnode* rp_cnode, void* args, cn_dispatch_result_t* result) {
int res = 0;
cn_dispatch_invoke_rp_send_args_t * send_arg = args;
c_log_debug("got args: %p", args);
assert((send_arg->has_cap || send_arg->has_msg) &&
"cptr, msg, or both args must be set");
if (send_arg->has_cap) {
if (cn_rp_send(rp_cnode, send_arg->cap,
send_arg->has_msg ? &send_arg->msg : NULL) != 0) {
res = cn_dispatch_result_fail(result, "object of type '%s' does not support method",
cn_objtype_name(cn_cnode_type(rp_cnode)));
return res;
}
} else if (send_arg->has_msg && ! send_arg->has_cap) {
struct cn_rp_elem *e = NULL;
if (cn_rp_elem_message(&send_arg->msg, &e) != 0) {
res = cn_dispatch_result_fail(result, "couldn't allocate rp element");
return res;
}
if (cn_rp_send_rp_elem(rp_cnode, e) != 0) {
cn_rp_elem_free(e);
res = cn_dispatch_result_fail(result, "object of type '%s' does not support method",
cn_objtype_name(cn_cnode_type(rp_cnode)));
return res;
}
} else {
cn_abort("unreachable");
}
return res;
}
int cn_dispatch_invoke(cn_principal_t *as, cn_dispatch_result_t *result,
cptr_t obj_cptr, cn_method_t method, void * args) {
int res = -1;
......@@ -1245,31 +1277,8 @@ int cn_dispatch_invoke(cn_principal_t *as, cn_dispatch_result_t *result,
switch (method) {
case CN_RP_SEND: {
cn_dispatch_invoke_rp_send_args_t * send_arg = args;
c_log_debug("got args: %p", args);
assert((send_arg->has_cap || send_arg->has_msg) &&
"cptr, msg, or both args must be set");
if (send_arg->has_cap) {
if (cn_rp_send(obj_cnode, send_arg->cap,
send_arg->has_msg ? &send_arg->msg : NULL) != 0) {
res = fail_invoke(result, "object of type '%s' does not support method",
cn_objtype_name(obj->type));
goto fail1;
}
} else if (send_arg->has_msg && ! send_arg->has_cap) {
struct cn_rp_elem *e = NULL;
if (cn_rp_elem_message(&send_arg->msg, &e) != 0) {
res = fail_invoke(result, "couldn't allocate rp element");
goto fail1;
}
if (cn_rp_send_rp_elem(obj_cnode, e) != 0) {
cn_rp_elem_free(e);
res = fail_invoke(result, "object of type '%s' does not support method",
cn_objtype_name(obj->type));
goto fail1;
}
} else {
cn_abort("unreachable");
if( (res = cn_dispatch_rp_send(obj_cnode, args, result)) ) {
goto fail1;
}
}
break;
......
......@@ -255,6 +255,9 @@ typedef struct {
int cn_dispatch_invoke(cn_principal_t * as, cn_dispatch_result_t *result,
cptr_t obj, cn_method_t method, void * args);
/* Call this with locks held on the cnode and the RP object. It acquires no locks */
int cn_dispatch_rp_send(struct cnode* rp_cnode, void* args, cn_dispatch_result_t* result);
/* This is a utility function to help fill in a cn_dispatch_result_t structure
* given the output of cn_rp_recv (given that it can now be non-trival).
* Returns 0 on success, -1 on failure. */
......
This diff is collapsed.
......@@ -51,6 +51,7 @@ void fill_shadow_flow_struct_from_shadow_flow_msg(
fill_node_info_struct_from_node_info_message(msg->node_info, from_ctlr_id,
&(shadow->shadow_flow.dst_node_info));
}
int fill_capability_message(ControllerRPC__Capability *to_seal_cap, cn_principal_t *as, cptr_t cptr) {
struct cnode* cnode;
if ( cn_principal_get(as, cptr, &cnode) < 0) {
......
......@@ -4,7 +4,7 @@ message RPCMessage {
required fixed64 uuid = 1;
required string from_ctlr_id = 2;
//return_code and return_msg are ignored when sending rpc req
required fixed64 return_code = 3;
required int32 return_code = 3;
optional string return_msg = 4;
oneof type {
CreateObjectRequest create_object_request = 5;
......@@ -128,11 +128,10 @@ message Capability {
message MethodInvokeRequest {
message RPSend {
required fixed64 requester_id = 1;
required string requester_host = 2;
required fixed64 rp_cap = 3;
optional fixed64 cptr = 4;
optional string cptr_host = 5;
optional bytes msg = 6;
required fixed64 rp_cptr = 2;
required int32 flags = 3;
optional Capability cap = 4;
optional bytes msg = 5;
}
message RPRecv {
required fixed64 requester_id = 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