From: Mathieu Desnoyers Date: Wed, 18 May 2011 15:22:05 +0000 (-0400) Subject: unregister event when FD is closed X-Git-Tag: v2.0-pre1~149 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=be066e6c5981a3d8dfda0e2884920c44f983e75e;p=lttng-modules.git unregister event when FD is closed Signed-off-by: Mathieu Desnoyers --- diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index 7c9f88ab..403657e6 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -520,8 +520,10 @@ int lttng_event_release(struct inode *inode, struct file *file) { struct ltt_event *event = file->private_data; - if (event) + if (event) { + ltt_event_unregister(event); fput(event->chan->file); + } return 0; } diff --git a/ltt-events.c b/ltt-events.c index 1aadd9f3..73ea08ea 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -22,6 +22,8 @@ static LIST_HEAD(ltt_transport_list); static DEFINE_MUTEX(sessions_mutex); static struct kmem_cache *event_cache; +static void _ltt_event_destroy(struct ltt_event *event); +static int _ltt_event_unregister(struct ltt_event *event); static int _ltt_event_metadata_statedump(struct ltt_session *session, struct ltt_channel *chan, @@ -277,9 +279,23 @@ int _ltt_event_unregister(struct ltt_event *event) return ret; } +/* + * Used when an event FD is released. + */ +int ltt_event_unregister(struct ltt_event *event) +{ + int ret; + + mutex_lock(&sessions_mutex); + ret = ltt_event_unregister(event); + mutex_unlock(&sessions_mutex); + return ret; +} + /* * Only used internally at session destruction. */ +static void _ltt_event_destroy(struct ltt_event *event) { ltt_event_put(event->desc); diff --git a/ltt-events.h b/ltt-events.h index a5eab5b8..0911a5ef 100644 --- a/ltt-events.h +++ b/ltt-events.h @@ -212,8 +212,7 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, enum instrum_type itype, const struct lttng_event_desc *event_desc, void *filter); -int _ltt_event_unregister(struct ltt_event *event); -void _ltt_event_destroy(struct ltt_event *event); +int ltt_event_unregister(struct ltt_event *event); void ltt_transport_register(struct ltt_transport *transport); void ltt_transport_unregister(struct ltt_transport *transport);