X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Fust-app.c;h=0472251434dbb8fb1953ceda2777ce7a46412adb;hp=30ac8ceaf923d4d7490589d07eb885c5d0d481c4;hb=55bed2138489dd1bfc43726e0ce71f7d5ee6d62c;hpb=edb6738816b442fb81f12ea0079260c96c3a5759 diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index 30ac8ceaf..047225143 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -83,13 +83,15 @@ static void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan) /* TODO : remove channel context */ //cds_lfht_for_each_entry(ltc->ctx, &iter, ltctx, node) { - // hashtable_del(ltc->ctx, &iter); + // ret = hashtable_del(ltc->ctx, &iter); + // assert(!ret); // delete_ust_app_ctx(sock, ltctx); //} //ret = hashtable_destroy(ltc->ctx); cds_lfht_for_each_entry(ua_chan->events, &iter, ua_event, node) { - hashtable_del(ua_chan->events, &iter); + ret = hashtable_del(ua_chan->events, &iter); + assert(!ret); delete_ust_app_event(sock, ua_event); } @@ -128,7 +130,8 @@ static void delete_ust_app_session(int sock, } cds_lfht_for_each_entry(ua_sess->channels, &iter, ua_chan, node) { - hashtable_del(ua_sess->channels, &iter); + ret = hashtable_del(ua_sess->channels, &iter); + assert(!ret); delete_ust_app_channel(sock, ua_chan); } @@ -181,7 +184,8 @@ static void delete_ust_app(struct ust_app *app) app->key.sock = -1; cds_lfht_for_each_entry(app->sessions, &iter, ua_sess, node) { - hashtable_del(app->sessions, &iter); + ret = hashtable_del(app->sessions, &iter); + assert(!ret); delete_ust_app_session(app->key.sock, ua_sess); } @@ -288,8 +292,6 @@ static int disable_ust_channel(struct ust_app *app, goto error; } - ua_chan->enabled = 0; - DBG2("UST app channel %s disabled successfully for app (pid: %d)", ua_chan->name, app->key.pid); @@ -422,6 +424,14 @@ static int create_ust_channel(struct ust_app *app, DBG2("UST app channel %s created successfully for pid:%d and sock:%d", ua_chan->name, app->key.pid, app->key.sock); + /* If channel is not enabled, disable it on the tracer */ + if (!ua_chan->enabled) { + ret = disable_ust_channel(app, ua_sess, ua_chan); + if (ret < 0) { + goto error; + } + } + error: return ret; } @@ -445,11 +455,18 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess, } ua_event->handle = ua_event->obj->handle; - ua_event->enabled = 1; DBG2("UST app event %s created successfully for pid:%d", ua_event->attr.name, app->key.pid); + /* If event not enabled, disable it on the tracer */ + if (!ua_event->enabled) { + ret = disable_ust_event(app, ua_sess, ua_event); + if (ret < 0) { + goto error; + } + } + error: return ret; } @@ -496,6 +513,7 @@ static struct ust_app_channel *alloc_ust_app_channel(char *name, strncpy(ua_chan->name, name, sizeof(ua_chan->name)); ua_chan->name[sizeof(ua_chan->name) - 1] = '\0'; + ua_chan->enabled = 1; ua_chan->handle = -1; ua_chan->ctx = hashtable_new(0); ua_chan->events = hashtable_new_str(0); @@ -532,6 +550,7 @@ static struct ust_app_event *alloc_ust_app_event(char *name, goto error; } + ua_event->enabled = 1; strncpy(ua_event->name, name, sizeof(ua_event->name)); ua_event->name[sizeof(ua_event->name) - 1] = '\0'; ua_event->ctx = hashtable_new(0); @@ -760,8 +779,7 @@ error: */ static int enable_ust_app_event(struct ust_app_session *ua_sess, - struct ust_app_channel *ua_chan, struct ust_app_event *ua_event, - struct ust_app *app) + struct ust_app_event *ua_event, struct ust_app *app) { int ret; @@ -799,29 +817,19 @@ error: /* * Lookup ust app channel for session and disable it on the tracer side. */ -static int disable_ust_app_channel(struct ust_app_session *ua_sess, - struct ltt_ust_channel *uchan, struct ust_app *app) +static +int disable_ust_app_channel(struct ust_app_session *ua_sess, + struct ust_app_channel *ua_chan, struct ust_app *app) { - int ret = 0; - struct cds_lfht_iter iter; - struct cds_lfht_node *ua_chan_node; - struct ust_app_channel *ua_chan; - - ua_chan_node = hashtable_lookup(ua_sess->channels, - (void *)uchan->name, strlen(uchan->name), &iter); - if (ua_chan_node == NULL) { - DBG2("Unable to find channel %s in ust session uid %u", - uchan->name, ua_sess->uid); - goto error; - } - - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + int ret; ret = disable_ust_channel(app, ua_sess, ua_chan); if (ret < 0) { goto error; } + ua_chan->enabled = 0; + error: return ret; } @@ -934,6 +942,8 @@ int create_ust_app_event(struct ust_app_session *ua_sess, goto error; } + ua_event->enabled = 1; + hashtable_add_unique(ua_chan->events, &ua_event->node); end: @@ -1099,6 +1109,7 @@ void ust_app_unregister(int sock) struct ust_app *lta; struct cds_lfht_node *node; struct cds_lfht_iter iter; + int ret; rcu_read_lock(); lta = find_app_by_sock(sock); @@ -1117,7 +1128,8 @@ void ust_app_unregister(int sock) goto error; } - hashtable_del(ust_app_ht, &iter); + ret = hashtable_del(ust_app_ht, &iter); + assert(!ret); call_rcu(&node->head, delete_ust_app_rcu); error: rcu_read_unlock(); @@ -1205,7 +1217,6 @@ error: void ust_app_clean_list(void) { int ret; - struct cds_lfht_node *node; struct cds_lfht_iter iter; struct ust_app *app; @@ -1215,9 +1226,8 @@ void ust_app_clean_list(void) cds_lfht_for_each_entry(ust_app_ht, &iter, app, node) { ret = hashtable_del(ust_app_ht, &iter); - if (!ret) { - call_rcu(&node->head, delete_ust_app_rcu); - } + assert(!ret); + call_rcu(&iter.node->head, delete_ust_app_rcu); } hashtable_destroy(ust_app_ht); @@ -1238,13 +1248,15 @@ void ust_app_ht_alloc(void) /* * For a specific UST session, disable the channel for all registered apps. */ -int ust_app_disable_channel_all(struct ltt_ust_session *usess, +int ust_app_disable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { int ret = 0; struct cds_lfht_iter iter; + struct cds_lfht_node *ua_chan_node; struct ust_app *app; struct ust_app_session *ua_sess; + struct ust_app_channel *ua_chan; if (usess == NULL || uchan == NULL) { ERR("Disabling UST global channel with NULL values"); @@ -1252,7 +1264,7 @@ int ust_app_disable_channel_all(struct ltt_ust_session *usess, goto error; } - DBG2("UST app disablling channel %s from global domain for session uid %d", + DBG2("UST app disabling channel %s from global domain for session uid %d", uchan->name, usess->uid); rcu_read_lock(); @@ -1264,8 +1276,18 @@ int ust_app_disable_channel_all(struct ltt_ust_session *usess, continue; } - /* Create channel onto application */ - ret = disable_ust_app_channel(ua_sess, uchan, app); + /* Get channel */ + ua_chan_node = hashtable_lookup(ua_sess->channels, + (void *)uchan->name, strlen(uchan->name), &iter); + /* If the session if found for the app, the channel must be there */ + assert(ua_chan_node); + + ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + /* The channel must not be already disabled */ + assert(ua_chan->enabled == 1); + + /* Disable channel onto application */ + ret = disable_ust_app_channel(ua_sess, ua_chan, app); if (ret < 0) { /* XXX: We might want to report this error at some point... */ continue; @@ -1281,7 +1303,7 @@ error: /* * For a specific UST session, enable the channel for all registered apps. */ -int ust_app_enable_channel_all(struct ltt_ust_session *usess, +int ust_app_enable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { int ret = 0; @@ -1324,8 +1346,8 @@ error: /* * Disable an event in a channel and for a specific session. */ -int ust_app_disable_event(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, char *event_name) +int ust_app_disable_event_glb(struct ltt_ust_session *usess, + struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) { int ret = 0; struct cds_lfht_iter iter, uiter; @@ -1336,7 +1358,7 @@ int ust_app_disable_event(struct ltt_ust_session *usess, struct ust_app_event *ua_event; DBG("UST app disabling event %s for all apps in channel " - "%s for session uid %d", event_name, uchan->name, usess->uid); + "%s for session uid %d", uevent->attr.name, uchan->name, usess->uid); rcu_read_lock(); @@ -1359,10 +1381,10 @@ int ust_app_disable_event(struct ltt_ust_session *usess, ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); ua_event_node = hashtable_lookup(ua_chan->events, - (void *) event_name, strlen(event_name), &uiter); + (void *)uevent->attr.name, strlen(uevent->attr.name), &uiter); if (ua_event_node == NULL) { DBG2("Event %s not found in channel %s for app pid %d." - "Skipping", event_name, uchan->name, app->key.pid); + "Skipping", uevent->attr.name, uchan->name, app->key.pid); continue; } ua_event = caa_container_of(ua_event_node, struct ust_app_event, node); @@ -1383,7 +1405,7 @@ int ust_app_disable_event(struct ltt_ust_session *usess, * For a specific UST session and UST channel, the event for all * registered apps. */ -int ust_app_disable_event_all(struct ltt_ust_session *usess, +int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { int ret = 0; @@ -1431,7 +1453,7 @@ int ust_app_disable_event_all(struct ltt_ust_session *usess, /* * For a specific UST session, create the channel for all registered apps. */ -int ust_app_create_channel_all(struct ltt_ust_session *usess, +int ust_app_create_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { int ret = 0; @@ -1479,12 +1501,12 @@ error: /* * Enable event for a specific session and channel on the tracer. */ -int ust_app_enable_event_all(struct ltt_ust_session *usess, +int ust_app_enable_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) { int ret = 0; struct cds_lfht_iter iter, uiter; - struct cds_lfht_node *ua_chan_node; + struct cds_lfht_node *ua_chan_node, *ua_event_node; struct ust_app *app; struct ust_app_session *ua_sess; struct ust_app_channel *ua_chan; @@ -1515,13 +1537,19 @@ int ust_app_enable_event_all(struct ltt_ust_session *usess, ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); - /* Enable each events of channel */ - cds_lfht_for_each_entry(ua_chan->events, &uiter, ua_event, node) { - ret = enable_ust_app_event(ua_sess, ua_chan, ua_event, app); - if (ret < 0) { - /* XXX: Report error someday... */ - continue; - } + ua_event_node = hashtable_lookup(ua_sess->channels, + (void*)uevent->attr.name, strlen(uevent->attr.name), &uiter); + if (ua_event_node == NULL) { + DBG3("UST app enable event %s not found. Skipping app", + uevent->attr.name); + continue; + } + ua_event = caa_container_of(ua_event_node, struct ust_app_event, node); + + ret = enable_ust_app_event(ua_sess, ua_event, app); + if (ret < 0) { + /* XXX: Report error someday... */ + continue; } } @@ -1534,7 +1562,7 @@ int ust_app_enable_event_all(struct ltt_ust_session *usess, * For a specific existing UST session and UST channel, creates the event for * all registered apps. */ -int ust_app_create_event_all(struct ltt_ust_session *usess, +int ust_app_create_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) { int ret = 0; @@ -1745,6 +1773,7 @@ int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app) struct lttng_ust_object_data obj; struct cds_lfht_iter iter; struct cds_lfht_node *node; + int ret; DBG("Destroy tracing for ust app pid %d", app->key.pid); @@ -1757,7 +1786,8 @@ int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app) goto error_rcu_unlock; } ua_sess = caa_container_of(node, struct ust_app_session, node); - hashtable_del(app->sessions, &iter); + ret = hashtable_del(app->sessions, &iter); + assert(!ret); delete_ust_app_session(app->key.sock, ua_sess); obj.handle = ua_sess->handle; obj.shm_fd = -1;