Commit c61fffda authored by Josh Kunz's avatar Josh Kunz

Add more logging to flow callbacks

parent 6e455d62
Pipeline #1908 passed with stage
in 30 seconds
......@@ -48,11 +48,19 @@ int cn_default_delete_cb(struct cnode *cnode, void * payload) {
int cn_default_insert_cb(struct cnode *ca, void * payload) {
cn_obj_t *obj = (cn_obj_t *) cap_cnode_object(ca);
cn_obj_lock(obj);
c_log_debug("cnode type: %d obj_type: %d, cnt: %d", cn_cnode_type(ca), obj->type, obj->refcnt);
char * cnode_str = cn_cnode_string(ca);
cncinfo("[default insert cb] INSERT %s\n", cnode_str);
free(cnode_str);
assert(cn_cnode_type(ca) == obj->type
&& "type of cnode does not match type of object");
int ret = cn_dispatch_caller_unop(ca, payload);
if (ret < 0) { cn_obj_unlock(obj); return ret; }
if (ret < 0) {
cncinfo("[default insert cb] unop failed with code: %d\n", ret);
cn_obj_unlock(obj);
return ret;
}
RHOLD(obj, ca);
cn_obj_unlock(obj);
return 0;
......@@ -65,7 +73,7 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) {
#ifndef NDEBUG
char * _send_cap_str = cn_cnode_string(ca);
char * _recv_cap_str = cn_cnode_string(cb);
c_log_debug("[grant cb] %s -> %s",
c_log_debug("[default grant cb] %s -> %s",
_send_cap_str, _recv_cap_str);
free(_send_cap_str);
free(_recv_cap_str);
......@@ -79,6 +87,7 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) {
if (ca_meta != NULL) {
cn_cnode_meta_t * cb_meta = NULL;
if (cn_cnode_meta_copy(ca_meta, &cb_meta) != 0) {
ret = -1;
goto finish;
}
cap_cnode_set_metadata(cb, cb_meta);
......@@ -87,7 +96,10 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) {
}
ret = cn_dispatch_caller_binop(ca, cb, payload);
if (ret < 0) { goto finish; }
if (ret < 0) {
cncinfo("[default grant cb] binop payload failed with code: %d\n", ret);
goto finish;
}
ret = cn_default_insert_cb(cb, NULL);
finish:
......@@ -98,7 +110,7 @@ finish:
if (cap_cnode_metadata(cb)) {
dest_meta = cn_cnode_meta_string((cn_cnode_meta_t *) cap_cnode_metadata(cb));
}
c_log_debug("[grant cb] dest meta: %s", dest_meta ? dest_meta : "(nil)");
c_log_debug("[default grant cb] dest meta: %s", dest_meta ? dest_meta : "(nil)");
if (dest_meta) { free(dest_meta); }
#endif
......@@ -160,7 +172,7 @@ static bool __entry_decref(GHashTable * table, gpointer key) {
if (! found) {
cn_abort("Tried to decref a flow entry not in the table");
}
if (value == 0) { cn_abort("Decref flow with zero value"); }
assert(value > 0 && "decref flow with zero value");
value -= 1;
if (value == 0) {
if (g_hash_table_remove(table, key) != TRUE) {
......@@ -184,14 +196,16 @@ static int __handle_flow_grant(cn_node_t * receiver, cn_flow_t *flow) {
bool found = __entry_incref(receiver->flow_table, flow);
/* We've already provisioned this flow. */
if (found) { goto finish; }
if (found) {
cncinfo("[flow grant cb] skipping flow create, already exists\n");
goto finish;
}
cn_obj_lock(flow->node);
/* Otherwise, go and install the flow between receiver and dst_node. */
c_log_debug("Flow Grant CB: creating flow %s -> %s", receiver->id, flow->node->id);
cncinfo("[flow grant cb] creating flow %s -> %s\n", receiver->id, flow->node->id);
c_log_debug("installing flow...");
cnc_install_flow(receiver, flow);
cn_obj_unlock(flow->node);
......@@ -220,18 +234,20 @@ int cn_delete_flow_cb(struct cnode *flow_cnode, void * payload) {
(void) __entry_decref(owner->node_table, flow->node);
bool do_delete = __entry_decref(owner->flow_table, flow);
if (! do_delete) { goto end1; }
if (! do_delete) {
cncinfo("[flow delete cb] skipping flow delete, not our last capability\n");
goto end1;
}
c_log_debug("Flow Delete CB: deleteing flow %s -> %s", owner->id, flow->node->id);
cncinfo("[flow delete cb] deleteing flow %s -> %s\n", owner->id, flow->node->id);
c_log_debug("remove flow...");
cnc_remove_flow(owner, flow);
end1:
cn_obj_unlock(flow);
cn_obj_unlock(owner);
end:
cncinfo("flow doing default delete cb\n");
cncinfo("[flow delete cb] calling default delete cb\n");
ret = cn_default_delete_cb(flow_cnode, payload);
cn_obj_unlock(principal);
return ret;
......
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