stream debugging

This commit is contained in:
Olof hagsand 2018-11-01 21:34:27 +01:00
parent e0e2e355d7
commit 911e6e6ed3
7 changed files with 83 additions and 32 deletions

View file

@ -88,7 +88,7 @@ ce_find_bypid(struct client_entry *ce_list,
* @param[in] arg Extra argument provided in stream_ss_add
* @see stream_ss_add
*/
static int
int
ce_event_cb(clicon_handle h,
int op,
cxobj *event,
@ -111,6 +111,7 @@ ce_event_cb(clicon_handle h,
break;
}
}
clicon_debug(1, "%s retval:0", __FUNCTION__);
return 0;
}
@ -130,6 +131,8 @@ backend_client_rm(clicon_handle h,
struct client_entry **ce_prev;
clicon_debug(1, "%s", __FUNCTION__);
/* for all streams: XXX better to do it top-level? */
stream_ss_delete_all(h, ce_event_cb, (void*)ce);
c0 = backend_client_list(h);
ce_prev = &c0; /* this points to stack and is not real backpointer */
for (c = *ce_prev; c; c = c->ce_next){
@ -139,12 +142,11 @@ backend_client_rm(clicon_handle h,
close(ce->ce_s);
ce->ce_s = 0;
}
/* for all streams */
stream_ss_delete_all(h, ce_event_cb, (void*)ce);
break;
}
ce_prev = &c->ce_next;
}
return backend_client_delete(h, ce); /* actually purge it */
}
@ -878,6 +880,7 @@ from_client_create_subscription(clicon_handle h,
goto done;
goto ok;
}
/* Add subscriber to stream - to make notifications for this client */
if (stream_ss_add(h, stream, selector,
starttime?&start:NULL, stoptime?&stop:NULL,
ce_event_cb, (void*)ce) < 0)

View file

@ -102,7 +102,7 @@ backend_terminate(clicon_handle h)
if (sockpath)
unlink(sockpath);
xmldb_plugin_unload(h); /* unload storage plugin */
backend_handle_exit(h); /* Cannot use h after this */
backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */
event_exit();
clicon_debug(1, "%s done", __FUNCTION__);
clicon_log_exit();

View file

@ -104,6 +104,7 @@ backend_handle_init(void)
/*! Deallocates a backend handle, including all client structs
* @Note: handle 'h' cannot be used in calls after this
* @see backend_client_rm
*/
int
backend_handle_exit(clicon_handle h)
@ -111,12 +112,17 @@ backend_handle_exit(clicon_handle h)
struct backend_handle *bh = handle(h);
struct client_entry *ce;
/* only delete client structs, not close sockets, etc, see backend_client_rm */
while ((ce = backend_client_list(h)) != NULL)
/* only delete client structs, not close sockets, etc, see backend_client_rm WHY NOT? */
while ((ce = backend_client_list(h)) != NULL){
if (ce->ce_s){
close(ce->ce_s);
ce->ce_s = 0;
}
backend_client_delete(h, ce);
}
if (bh->bh_nacm)
xml_free(bh->bh_nacm);
clicon_handle_exit(h); /* frees h and options */
clicon_handle_exit(h); /* frees h and options (and streams) */
return 0;
}