From: David Goulet Date: Wed, 26 Feb 2014 20:07:12 +0000 (-0500) Subject: Fix: keep metadata channel attr in UST session X-Git-Tag: v2.5.0-rc1~145 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=84ad93e8f5907bff18feac3e174746815b21c6c1;p=lttng-tools.git Fix: keep metadata channel attr in UST session This is so that if we have NO application we can use the metadata channel attributes once one appears. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index fc343f591..1d04b1fcf 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -369,6 +369,14 @@ int channel_ust_create(struct ltt_ust_session *usess, if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name))) { lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node); + } else { + /* + * Copy channel attribute to session if this is metadata so if NO + * application exists we can access that data in the shadow copy during + * the global update of newly registered application. + */ + memcpy(&usess->metadata_attr, &uchan->attr, + sizeof(usess->metadata_attr)); } rcu_read_unlock(); diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index c08246a25..996916558 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -220,6 +220,14 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) lus->id = session_id; lus->start_trace = 0; + /* Set default metadata channel attribute. */ + lus->metadata_attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; + lus->metadata_attr.subbuf_size = default_get_metadata_subbuf_size(); + lus->metadata_attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; + lus->metadata_attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; + lus->metadata_attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; + lus->metadata_attr.output = LTTNG_UST_MMAP; + /* * Default buffer type. This can be changed through an enable channel * requesting a different type. Note that this can only be changed once diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 07af0f1ee..6c6c6c454 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -107,6 +107,9 @@ struct ltt_ust_session { unsigned int snapshot_mode; unsigned int has_non_default_channel; unsigned int live_timer_interval; /* usec */ + + /* Metadata channel attributes. */ + struct lttng_ust_channel_attr metadata_attr; }; /* diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 5aad28bbc..00c6d9622 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -825,16 +825,8 @@ struct ust_app_session *alloc_ust_app_session(struct ust_app *app) ua_sess->handle = -1; ua_sess->channels = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); - pthread_mutex_init(&ua_sess->lock, NULL); - - /* Set default metadata channel attribute. */ - ua_sess->metadata_attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; - ua_sess->metadata_attr.subbuf_size = default_get_metadata_subbuf_size(); - ua_sess->metadata_attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; - ua_sess->metadata_attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; - ua_sess->metadata_attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; - ua_sess->metadata_attr.output = LTTNG_UST_MMAP; ua_sess->metadata_attr.type = LTTNG_UST_CHAN_METADATA; + pthread_mutex_init(&ua_sess->lock, NULL); return ua_sess; @@ -1617,6 +1609,8 @@ static void shadow_copy_session(struct ust_app_session *ua_sess, ua_sess->consumer = usess->consumer; ua_sess->output_traces = usess->output_traces; ua_sess->live_timer_interval = usess->live_timer_interval; + copy_channel_attr_to_ustctl(&ua_sess->metadata_attr, + &usess->metadata_attr); switch (ua_sess->buffer_type) { case LTTNG_BUFFER_PER_PID: