*/
static void del_traceable_app(struct ltt_traceable_app *lta)
{
+ struct ltt_ust_channel *chan;
+
cds_list_del(<a->list);
/* Sanity check */
if (ltt_traceable_app_list.count > 0) {
ltt_traceable_app_list.count--;
}
+
+ cds_list_for_each_entry(chan, <a->channels.head, list) {
+ trace_ust_destroy_channel(chan);
+ }
}
/*
return NULL;
}
+/*
+ * Iterate over the traceable apps list and return a pointer or NULL if not
+ * found.
+ */
+struct ltt_traceable_app *traceable_app_get_by_pid(pid_t pid)
+{
+ struct ltt_traceable_app *iter;
+
+ cds_list_for_each_entry(iter, <t_traceable_app_list.head, list) {
+ if (iter->pid == pid) {
+ /* Found */
+ DBG2("Found traceable app by pid %d", pid);
+ return iter;
+ }
+ }
+
+ DBG2("Traceable app with pid %d not found", pid);
+
+ return NULL;
+}
+
/*
* Using pid and uid (of the app), allocate a new ltt_traceable_app struct and
* add it to the global traceable app list.
lta->sock = sock;
strncpy(lta->name, msg->name, sizeof(lta->name));
lta->name[16] = '\0';
+ CDS_INIT_LIST_HEAD(<a->channels.head);
lock_apps_list();
add_traceable_app(lta);
lta = find_app_by_sock(sock);
if (lta) {
DBG("PID %d unregistered with sock %d", lta->pid, sock);
- close(lta->sock);
del_traceable_app(lta);
- unlock_apps_list();
+ close(lta->sock);
free(lta);
}
unlock_apps_list();
* cleanup() functions meaning that the program will exit.
*/
cds_list_for_each_entry_safe(iter, tmp, <t_traceable_app_list.head, list) {
+ del_traceable_app(iter);
close(iter->sock);
free(iter);
}