From 35a9059d90ff33b4cfd57ad613969e333dba23a1 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 29 Nov 2011 17:42:21 -0500 Subject: [PATCH] Rename ust app function for better semantic Replace _all by _glb meaning global. This family of functions (ending with _glb) apply an action on *all* registered applications. Also fix the setting the enabled flag on disable-event. Signed-off-by: David Goulet --- lttng-sessiond/event.c | 4 +-- lttng-sessiond/main.c | 19 ++++++++++---- lttng-sessiond/ust-app.c | 47 ++++++++++++++++++--------------- lttng-sessiond/ust-app.h | 56 +++++++++++++++++++--------------------- 4 files changed, 68 insertions(+), 58 deletions(-) diff --git a/lttng-sessiond/event.c b/lttng-sessiond/event.c index 407f8441c..c7331956f 100644 --- a/lttng-sessiond/event.c +++ b/lttng-sessiond/event.c @@ -260,10 +260,10 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, { if (to_create) { /* Create event on all UST registered apps for session */ - ret = ust_app_create_event_all(usess, uchan, uevent); + ret = ust_app_create_event_glb(usess, uchan, uevent); } else { /* Enable event on all UST registered apps for session */ - ret = ust_app_enable_event_all(usess, uchan, uevent); + ret = ust_app_enable_event_glb(usess, uchan, uevent); } if (ret < 0) { diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index 63d7f0e2d..7e4000a0f 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -2191,7 +2191,7 @@ static int cmd_disable_channel(struct ltt_session *session, goto error; } - ret = ust_app_disable_channel_all(usess, uchan); + ret = ust_app_disable_channel_glb(usess, uchan); if (ret < 0) { ret = LTTCOMM_UST_DISABLE_FAIL; goto error; @@ -2305,7 +2305,7 @@ static int cmd_enable_channel(struct ltt_session *session, DBG2("UST channel %s added to global domain HT", attr->name); /* Add channel to all registered applications */ - ret = ust_app_create_channel_all(usess, uchan); + ret = ust_app_create_channel_glb(usess, uchan); if (ret != 0) { ret = LTTCOMM_UST_CHAN_FAIL; goto error; @@ -2317,7 +2317,7 @@ static int cmd_enable_channel(struct ltt_session *session, goto error; } - ret = ust_app_enable_channel_all(usess, uchan); + ret = ust_app_enable_channel_glb(usess, uchan); if (ret < 0) { ret = LTTCOMM_UST_ENABLE_FAIL; goto error; @@ -2378,6 +2378,7 @@ static int cmd_disable_event(struct ltt_session *session, int domain, { struct ltt_ust_session *usess; struct ltt_ust_channel *uchan; + struct ltt_ust_event *uevent; usess = session->ust_session; @@ -2388,12 +2389,20 @@ static int cmd_disable_event(struct ltt_session *session, int domain, goto error; } - ret = ust_app_disable_event(usess, uchan, event_name); + uevent = trace_ust_find_event_by_name(uchan->events, event_name); + if (uevent == NULL) { + ret = LTTCOMM_UST_EVENT_NOT_FOUND; + goto error; + } + + ret = ust_app_disable_event_glb(usess, uchan, uevent); if (ret < 0) { ret = LTTCOMM_UST_DISABLE_FAIL; goto error; } + uevent->enabled = 0; + DBG2("Disable UST event %s in channel %s completed", event_name, channel_name); @@ -2457,7 +2466,7 @@ static int cmd_disable_event_all(struct ltt_session *session, int domain, goto error; } - ret = ust_app_disable_event_all(usess, uchan); + ret = ust_app_disable_all_event_glb(usess, uchan); if (ret < 0) { ret = LTTCOMM_UST_DISABLE_FAIL; goto error; diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index 30ac8ceaf..3f4c4c661 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -760,8 +760,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; @@ -1238,7 +1237,7 @@ 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; @@ -1281,7 +1280,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 +1323,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 +1335,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 +1358,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 +1382,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 +1430,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 +1478,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 +1514,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 +1539,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; diff --git a/lttng-sessiond/ust-app.h b/lttng-sessiond/ust-app.h index 87d84ffb9..8a0130f07 100644 --- a/lttng-sessiond/ust-app.h +++ b/lttng-sessiond/ust-app.h @@ -110,10 +110,6 @@ struct ust_app { int ust_app_register(struct ust_register_msg *msg, int sock); void ust_app_unregister(int sock); -int ust_app_create_channel_all(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan); -int ust_app_create_event_all(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); unsigned long ust_app_list_count(void); int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app); int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app); @@ -122,16 +118,22 @@ int ust_app_stop_trace_all(struct ltt_ust_session *usess); int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app); int ust_app_destroy_trace_all(struct ltt_ust_session *usess); int ust_app_list_events(struct lttng_event **events); -int ust_app_disable_channel_all(struct ltt_ust_session *usess, +int ust_app_create_channel_glb(struct ltt_ust_session *usess, + struct ltt_ust_channel *uchan); +int ust_app_create_event_glb(struct ltt_ust_session *usess, + struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); +int ust_app_disable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); -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 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 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 ust_app_enable_all_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); -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); void ust_app_global_update(struct ltt_ust_session *usess, int sock); void ust_app_clean_list(void); @@ -203,18 +205,6 @@ struct ust_app *ust_app_get_by_pid(pid_t pid) return NULL; } static inline -int ust_app_add_channel_all(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan) -{ - return 0; -} -static inline -int ust_app_add_event_all(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) -{ - return 0; -} -static inline struct cds_lfht *ust_app_get_ht(void) { return NULL; @@ -226,43 +216,49 @@ static inline void ust_app_global_update(struct ltt_ust_session *usess, int sock) {} static inline -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) { return 0; } static inline -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) { return 0; } static inline -int ust_app_disable_event_all(struct ltt_ust_session *usess, +int ust_app_create_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { return 0; } static inline -int ust_app_disable_event(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, char *event_name) +int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, + struct ltt_ust_channel *uchan) { return 0; } static inline -int ust_app_create_channel_all(struct ltt_ust_session *usess, +int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { return 0; } static inline -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) +{ + return 0; +} +static inline +int ust_app_disable_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) { return 0; } static inline -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) { return 0; -- 2.34.1