Message ID | 20181121151356.16901-5-ykaradzhov@vmware.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Small modifications and bug fixes toward KS 1.0 | expand |
On Wed, 21 Nov 2018 15:14:21 +0000 Yordan Karadzhov <ykaradzhov@vmware.com> wrote: > Calling tep_data_event_from_type() is not thread-safe (potential > race condition). This patch protects the access to it by using the > mutex associated with the input file. Tzvetomir sent patches to handle the race condition here. I'll work to apply his. -- Steve > > Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> > --- > kernel-shark-qt/src/libkshark.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c > index fa85171..89ae769 100644 > --- a/kernel-shark-qt/src/libkshark.c > +++ b/kernel-shark-qt/src/libkshark.c > @@ -1147,7 +1147,18 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry) > } > } > > + /* > + * Calling tep_data_event_from_type() is not thread-safe (potential > + * race condition). > + * TODO: See if we can add a thread-safe version of the > + * function. For the time being use a mutex to protect the access. > + */ > + pthread_mutex_lock(&kshark_ctx->input_mutex); > + > event = tep_data_event_from_type(kshark_ctx->pevent, event_id); > + > + pthread_mutex_unlock(&kshark_ctx->input_mutex); > + > if (event) > return event->name; >
diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c index fa85171..89ae769 100644 --- a/kernel-shark-qt/src/libkshark.c +++ b/kernel-shark-qt/src/libkshark.c @@ -1147,7 +1147,18 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry) } } + /* + * Calling tep_data_event_from_type() is not thread-safe (potential + * race condition). + * TODO: See if we can add a thread-safe version of the + * function. For the time being use a mutex to protect the access. + */ + pthread_mutex_lock(&kshark_ctx->input_mutex); + event = tep_data_event_from_type(kshark_ctx->pevent, event_id); + + pthread_mutex_unlock(&kshark_ctx->input_mutex); + if (event) return event->name;
Calling tep_data_event_from_type() is not thread-safe (potential race condition). This patch protects the access to it by using the mutex associated with the input file. Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> --- kernel-shark-qt/src/libkshark.c | 11 +++++++++++ 1 file changed, 11 insertions(+)