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) { ...@@ -48,11 +48,19 @@ int cn_default_delete_cb(struct cnode *cnode, void * payload) {
int cn_default_insert_cb(struct cnode *ca, 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_t *obj = (cn_obj_t *) cap_cnode_object(ca);
cn_obj_lock(obj); 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 assert(cn_cnode_type(ca) == obj->type
&& "type of cnode does not match type of object"); && "type of cnode does not match type of object");
int ret = cn_dispatch_caller_unop(ca, payload); 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); RHOLD(obj, ca);
cn_obj_unlock(obj); cn_obj_unlock(obj);
return 0; return 0;
...@@ -65,7 +73,7 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) { ...@@ -65,7 +73,7 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) {
#ifndef NDEBUG #ifndef NDEBUG
char * _send_cap_str = cn_cnode_string(ca); char * _send_cap_str = cn_cnode_string(ca);
char * _recv_cap_str = cn_cnode_string(cb); 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); _send_cap_str, _recv_cap_str);
free(_send_cap_str); free(_send_cap_str);
free(_recv_cap_str); free(_recv_cap_str);
...@@ -79,6 +87,7 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) { ...@@ -79,6 +87,7 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) {
if (ca_meta != NULL) { if (ca_meta != NULL) {
cn_cnode_meta_t * cb_meta = NULL; cn_cnode_meta_t * cb_meta = NULL;
if (cn_cnode_meta_copy(ca_meta, &cb_meta) != 0) { if (cn_cnode_meta_copy(ca_meta, &cb_meta) != 0) {
ret = -1;
goto finish; goto finish;
} }
cap_cnode_set_metadata(cb, cb_meta); cap_cnode_set_metadata(cb, cb_meta);
...@@ -87,7 +96,10 @@ int cn_default_grant_cb(struct cnode *ca, struct cnode *cb, void * payload) { ...@@ -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); 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); ret = cn_default_insert_cb(cb, NULL);
finish: finish:
...@@ -98,7 +110,7 @@ finish: ...@@ -98,7 +110,7 @@ finish:
if (cap_cnode_metadata(cb)) { if (cap_cnode_metadata(cb)) {
dest_meta = cn_cnode_meta_string((cn_cnode_meta_t *) 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); } if (dest_meta) { free(dest_meta); }
#endif #endif
...@@ -160,7 +172,7 @@ static bool __entry_decref(GHashTable * table, gpointer key) { ...@@ -160,7 +172,7 @@ static bool __entry_decref(GHashTable * table, gpointer key) {
if (! found) { if (! found) {
cn_abort("Tried to decref a flow entry not in the table"); 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; value -= 1;
if (value == 0) { if (value == 0) {
if (g_hash_table_remove(table, key) != TRUE) { 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) { ...@@ -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); bool found = __entry_incref(receiver->flow_table, flow);
/* We've already provisioned this 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); cn_obj_lock(flow->node);
/* Otherwise, go and install the flow between receiver and dst_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); cnc_install_flow(receiver, flow);
cn_obj_unlock(flow->node); cn_obj_unlock(flow->node);
...@@ -220,18 +234,20 @@ int cn_delete_flow_cb(struct cnode *flow_cnode, void * payload) { ...@@ -220,18 +234,20 @@ int cn_delete_flow_cb(struct cnode *flow_cnode, void * payload) {
(void) __entry_decref(owner->node_table, flow->node); (void) __entry_decref(owner->node_table, flow->node);
bool do_delete = __entry_decref(owner->flow_table, flow); 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); cnc_remove_flow(owner, flow);
end1: end1:
cn_obj_unlock(flow); cn_obj_unlock(flow);
cn_obj_unlock(owner); cn_obj_unlock(owner);
end: 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); ret = cn_default_delete_cb(flow_cnode, payload);
cn_obj_unlock(principal); cn_obj_unlock(principal);
return ret; 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