Commit ad8933b7 authored by Josh Kunz's avatar Josh Kunz

Add extra logging on `create` requests.

Specifically, it logs the type of the object the request wants CapNet to
create.
parent 1ad13b5f
Pipeline #1886 passed with stage
in 29 seconds
......@@ -491,9 +491,15 @@ double __cn_timestamp(void) {
return ((double) stamp) / 1000000.0;
}
void __cn_print_profile(const char * opname, uint64_t uuid, const char * event) {
printf("CONTROLLER,TIMESTAMP,%s,%lx,%s,%.6f\n",
opname, uuid, event, __cn_timestamp());
void __cn_print_profile(cn_principal_t *p, const char * opname, uint64_t uuid, const char * event) {
printf("CONTROLLER,TIMESTAMP,%s,%p,%lx,%s,%.6f\n",
opname, p, uuid, event, __cn_timestamp());
}
void __cn_print_profile_create(cn_principal_t *p, cn_objtype_t t, uint64_t uuid, const char * event) {
printf("CONTROLLER,TIMESTAMP,create,%p,%s,%lx,%s,%.6f",
p, cn_objtype_name(t),
uuid, event, __cn_timestamp());
}
void __cn_print_profile_invoke(cn_principal_t *p, cptr_t cptr,
......@@ -508,18 +514,22 @@ static int __cn_handle_create_message(cn_principal_t *as,
cn_dispatch_result_t *result,
Cp__CPCreate * msg) {
cn_objtype_t type = __cn_objtype_for_CPObjType(msg->obj_type);
__cn_print_profile_create(as, type, result->request.uuid, "start");
int res = -1;
switch (msg->args_case) {
case CP__CPCREATE__ARGS_FLOW_ARGS:
assert(type == CN_FLOW && "Passed flow args for non-flow type");
cn_dispatch_create_flow_args_t flow_args;
flow_args.node_grant = ul2cptr(msg->flow_args->node_grant_cptr);
/* TODO: Add flowspec stuff here */
return cn_dispatch_create(as, result, type, &flow_args);
res = cn_dispatch_create(as, result, type, &flow_args);
default:
assert(msg->args_case == CP__CPCREATE__ARGS__NOT_SET
&& "Default case but unknown args set");
return cn_dispatch_create(as, result, type, NULL);
res = cn_dispatch_create(as, result, type, NULL);
}
__cn_print_profile_create(as, type, result->request.uuid, "stop");
return res;
}
static int __cn_handle_mint_message(cn_principal_t *as,
......@@ -773,43 +783,42 @@ int cn_dispatch(cn_principal_t * as, cn_dispatch_result_t **o_result,
switch (msg->type_case) {
case CP__CPMESSAGE__TYPE_CREATE:
__cn_print_profile("create", msg->uuid, "start");
/* logging is done in the message handler */
res = __cn_handle_create_message(as, result, msg->create);
__cn_print_profile("create", msg->uuid, "stop");
break;
case CP__CPMESSAGE__TYPE_MINT:
__cn_print_profile("mint", msg->uuid, "start");
__cn_print_profile(as, "mint", msg->uuid, "start");
res = __cn_handle_mint_message(as, result, msg->mint);
__cn_print_profile("mint", msg->uuid, "stop");
__cn_print_profile(as, "mint", msg->uuid, "stop");
break;
case CP__CPMESSAGE__TYPE_REVOKE:
__cn_print_profile("revoke", msg->uuid, "start");
__cn_print_profile(as, "revoke", msg->uuid, "start");
res = __cn_handle_revoke_message(as, result, msg->revoke);
__cn_print_profile("revoke", msg->uuid, "stop");
__cn_print_profile(as, "revoke", msg->uuid, "stop");
break;
case CP__CPMESSAGE__TYPE_RP0:
__cn_print_profile("rp0", msg->uuid, "start");
__cn_print_profile(as, "rp0", msg->uuid, "start");
res = __cn_handle_rp0_message(as, result, msg->rp0);
__cn_print_profile("rp0", msg->uuid, "stop");
__cn_print_profile(as, "rp0", msg->uuid, "stop");
break;
case CP__CPMESSAGE__TYPE_DELETE:
__cn_print_profile("delete", msg->uuid, "start");
__cn_print_profile(as, "delete", msg->uuid, "start");
res = __cn_handle_delete_message(as, result, msg->delete_);
__cn_print_profile("delete", msg->uuid, "stop");
__cn_print_profile(as, "delete", msg->uuid, "stop");
break;
case CP__CPMESSAGE__TYPE_INVOKE:
/* logging for this one is handled in the invoke_message handler */
res = __cn_handle_invoke_message(as, result, msg->invoke);
break;
case CP__CPMESSAGE__TYPE_DEBUG_GRANT:
__cn_print_profile("debug_grant", msg->uuid, "start");
__cn_print_profile(as, "debug_grant", msg->uuid, "start");
res = __cn_handle_debug_grant_message(as, result, msg->debug_grant);
__cn_print_profile("debug_grant", msg->uuid, "stop");
__cn_print_profile(as, "debug_grant", msg->uuid, "stop");
break;
case CP__CPMESSAGE__TYPE_REPLY:
__cn_print_profile("reply", msg->uuid, "start");
__cn_print_profile(as, "reply", msg->uuid, "start");
res = __cn_handle_reply_message(as, msg);
__cn_print_profile("reply", msg->uuid, "stop");
__cn_print_profile(as, "reply", msg->uuid, "stop");
break;
default:
res = cn_dispatch_result_fail(result, "Unsupported message type: %d", msg->type_case);
......
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