From: dgoulet@efficios.com (David Goulet)
Subject: [lttng-dev] [PATCH lttng-tools 2/3] Add hash table argument to helper functions
Date: Wed, 3 Oct 2012 11:48:36 -0400 [thread overview]
Message-ID: <1349279317-28056-2-git-send-email-dgoulet@efficios.com> (raw)
In-Reply-To: <1349279317-28056-1-git-send-email-dgoulet@efficios.com>
This allows these helper functions to be used more broadly across the
code base and not for a specific hash table.
Signed-off-by: David Goulet <dgoulet at efficios.com>
---
src/common/consumer.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/common/consumer.c b/src/common/consumer.c
index 7c3762e..6ee366f 100644
--- a/src/common/consumer.c
+++ b/src/common/consumer.c
@@ -62,12 +62,15 @@ volatile int consumer_quit = 0;
* Find a stream. The consumer_data.lock must be locked during this
* call.
*/
-static struct lttng_consumer_stream *consumer_find_stream(int key)
+static struct lttng_consumer_stream *consumer_find_stream(int key,
+ struct lttng_ht *ht)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_ulong *node;
struct lttng_consumer_stream *stream = NULL;
+ assert(ht);
+
/* Negative keys are lookup failures */
if (key < 0) {
return NULL;
@@ -75,8 +78,7 @@ static struct lttng_consumer_stream *consumer_find_stream(int key)
rcu_read_lock();
- lttng_ht_lookup(consumer_data.stream_ht, (void *)((unsigned long) key),
- &iter);
+ lttng_ht_lookup(ht, (void *)((unsigned long) key), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node != NULL) {
stream = caa_container_of(node, struct lttng_consumer_stream, node);
@@ -87,12 +89,12 @@ static struct lttng_consumer_stream *consumer_find_stream(int key)
return stream;
}
-static void consumer_steal_stream_key(int key)
+static void consumer_steal_stream_key(int key, struct lttng_ht *ht)
{
struct lttng_consumer_stream *stream;
rcu_read_lock();
- stream = consumer_find_stream(key);
+ stream = consumer_find_stream(key, ht);
if (stream) {
stream->key = -1;
/*
@@ -443,7 +445,7 @@ int consumer_add_stream(struct lttng_consumer_stream *stream)
pthread_mutex_lock(&consumer_data.lock);
/* Steal stream identifier, for UST */
- consumer_steal_stream_key(stream->key);
+ consumer_steal_stream_key(stream->key, consumer_data.stream_ht);
rcu_read_lock();
lttng_ht_lookup(consumer_data.stream_ht,
@@ -620,7 +622,7 @@ void consumer_change_stream_state(int stream_key,
struct lttng_consumer_stream *stream;
pthread_mutex_lock(&consumer_data.lock);
- stream = consumer_find_stream(stream_key);
+ stream = consumer_find_stream(stream_key, consumer_data.stream_ht);
if (stream) {
stream->state = state;
}
--
1.7.10.4
next prev parent reply other threads:[~2012-10-03 15:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-03 15:48 [lttng-dev] [PATCH lttng-tools 1/3] Fix: Add missing call rcu and read side lock David Goulet
2012-10-03 15:48 ` David Goulet [this message]
2012-10-03 16:29 ` [lttng-dev] [PATCH lttng-tools 2/3] Add hash table argument to helper functions Mathieu Desnoyers
2012-10-03 15:48 ` [lttng-dev] [PATCH lttng-tools 3/3] Fix: Stream allocation and insertion consistency David Goulet
2012-10-03 16:38 ` Mathieu Desnoyers
2012-10-03 16:42 ` David Goulet
2012-10-03 16:48 ` David Goulet
2012-10-03 17:06 ` Mathieu Desnoyers
2012-10-03 16:28 ` [lttng-dev] [PATCH lttng-tools 1/3] Fix: Add missing call rcu and read side lock Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349279317-28056-2-git-send-email-dgoulet@efficios.com \
--to=dgoulet@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox