X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=e1bf1e416b49be23b8ca860d21062249b70a01df;hp=825fa4371cb67b0316fcf9ce8b6e677dd1f0f115;hb=56fff0907d3a752030f384e6037d16ea7978de71;hpb=4bc385dd824ca7c10e3177346926350c86d04754 diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 825fa4371..e1bf1e416 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -50,7 +50,7 @@ #include "kernel-ctl.h" #include "ltt-sessiond.h" #include "shm.h" -#include "traceable-app.h" +#include "ust-app.h" #include "ust-ctl.h" #include "utils.h" #include "ust-ctl.h" @@ -344,7 +344,7 @@ static void cleanup(void) } DBG("Closing all UST sockets"); - clean_traceable_apps_list(); + ust_app_clean_list(); pthread_mutex_destroy(&kconsumerd_pid_mutex); @@ -986,7 +986,7 @@ static void *thread_manage_apps(void *data) } /* Register applicaton to the session daemon */ - ret = register_traceable_app(&ust_cmd.reg_msg, + ret = ust_app_register(&ust_cmd.reg_msg, ust_cmd.sock); if (ret < 0) { /* Only critical ENOMEM error can be returned here */ @@ -999,7 +999,7 @@ static void *thread_manage_apps(void *data) * If the registration is not possible, we simply * unregister the apps and continue */ - unregister_traceable_app(ust_cmd.sock); + ust_app_unregister(ust_cmd.sock); } else { /* * We just need here to monitor the close of the UST @@ -1028,7 +1028,7 @@ static void *thread_manage_apps(void *data) } /* Socket closed */ - unregister_traceable_app(pollfd); + ust_app_unregister(pollfd); break; } } @@ -1566,11 +1566,11 @@ static int create_ust_session(struct ltt_session *session, { int ret; struct ltt_ust_session *lus; - struct ltt_traceable_app *app; + struct ust_app *app; switch (domain->type) { case LTTNG_DOMAIN_UST_PID: - app = traceable_app_get_by_pid(domain->attr.pid); + app = ust_app_get_by_pid(domain->attr.pid); if (app == NULL) { ret = LTTCOMM_APP_NOT_FOUND; goto error; @@ -1775,6 +1775,42 @@ error: return ret; } +/* + * Copy channel from attributes and set it in the application channel list. + */ +static int copy_ust_channel_to_app(struct ltt_ust_session *usess, + struct lttng_channel *attr, struct ust_app *app) +{ + int ret; + struct ltt_ust_channel *uchan, *new_chan; + + uchan = trace_ust_get_channel_by_name(attr->name, usess); + if (uchan == NULL) { + ret = LTTCOMM_FATAL; + goto error; + } + + new_chan = trace_ust_create_channel(attr, usess->path); + if (new_chan == NULL) { + PERROR("malloc ltt_ust_channel"); + ret = LTTCOMM_FATAL; + goto error; + } + + ret = channel_ust_copy(new_chan, uchan); + if (ret < 0) { + ret = LTTCOMM_FATAL; + goto error; + } + + /* Add channel to the ust app channel list */ + cds_list_add(&new_chan->list, &app->channels.head); + app->channels.count++; + +error: + return ret; +} + /* * Command LTTNG_ENABLE_CHANNEL processed by the client thread. */ @@ -1806,10 +1842,10 @@ static int cmd_enable_channel(struct ltt_session *session, } case LTTNG_DOMAIN_UST_PID: { - struct ltt_ust_event *uevent, *new_uevent; + int sock; + struct ltt_ust_channel *uchan; struct ltt_ust_session *usess; - struct ltt_ust_channel *uchan, *app_chan; - struct ltt_traceable_app *app; + struct ust_app *app; usess = trace_ust_get_session_by_pid(&session->ust_session_list, domain->attr.pid); @@ -1818,59 +1854,29 @@ static int cmd_enable_channel(struct ltt_session *session, goto error; } - app = traceable_app_get_by_pid(domain->attr.pid); + app = ust_app_get_by_pid(domain->attr.pid); if (app == NULL) { ret = LTTCOMM_APP_NOT_FOUND; goto error; } + sock = app->sock; uchan = trace_ust_get_channel_by_name(attr->name, usess); if (uchan == NULL) { - ret = channel_ust_create(usess, attr, app->sock); + ret = channel_ust_create(usess, attr, sock); } else { - ret = channel_ust_enable(usess, uchan, app->sock); + ret = channel_ust_enable(usess, uchan, sock); } if (ret != LTTCOMM_OK) { goto error; } - /*TODO: This should be put in an external function */ - - /* Copy UST channel to add to the traceable app */ - uchan = trace_ust_get_channel_by_name(attr->name, usess); - if (uchan == NULL) { - ret = LTTCOMM_FATAL; - goto error; - } - - app_chan = trace_ust_create_channel(attr, session->path); - if (app_chan == NULL) { - PERROR("malloc ltt_ust_channel"); - ret = LTTCOMM_FATAL; + ret = copy_ust_channel_to_app(usess, attr, app); + if (ret != LTTCOMM_OK) { goto error; } - memcpy(app_chan, uchan, sizeof(struct ltt_ust_channel)); - CDS_INIT_LIST_HEAD(&app_chan->events.head); - - cds_list_for_each_entry(uevent, &uchan->events.head, list) { - new_uevent = malloc(sizeof(struct ltt_ust_event)); - if (new_uevent == NULL) { - PERROR("malloc ltt_ust_event"); - ret = LTTCOMM_FATAL; - goto error; - } - - memcpy(new_uevent, uevent, sizeof(struct ltt_ust_event)); - cds_list_add(&new_uevent->list, &app_chan->events.head); - app_chan->events.count++; - } - - /* Add channel to traceable_app */ - cds_list_add(&app_chan->list, &app->channels.head); - app->channels.count++; - DBG("UST channel %s created for app sock %d with pid %d", attr->name, app->sock, domain->attr.pid); break;