From: dgoulet@efficios.com (David Goulet)
Subject: [lttng-dev] [PATCH lttng-tools 1/4] Rename consumer threads and spawn them in daemon
Date: Mon, 15 Oct 2012 13:42:53 -0400 [thread overview]
Message-ID: <507C4B1D.3050602@efficios.com> (raw)
In-Reply-To: <20121015173933.GB9142@Krystal>
Mathieu Desnoyers:
> * David Goulet (dgoulet at efficios.com) wrote:
>>
>>
>> Mathieu Desnoyers:
>>>>>> diff --git a/src/common/consumer.c b/src/common/consumer.c
>>>>>> index 242b05b..055de1b 100644
>>>>>> --- a/src/common/consumer.c
>>>>>> +++ b/src/common/consumer.c
>>>>>> @@ -1131,6 +1131,8 @@ void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx)
>>>>>> PERROR("close");
>>>>>> }
>>>>>> utils_close_pipe(ctx->consumer_splice_metadata_pipe);
>>>>>> + /* This should trigger the metadata thread to exit */
>>>>>> + close(ctx->consumer_metadata_pipe[1]);
>>>>>
>>>>> this is adding a close, but did not remove any other remove that might
>>>>> previously be in place elsewhere.
>>>>
>>>> So we got two possible error path which is either the poll thread fails
>>>> or the consumer could be destroy by hand even though the threads are
>>>> working well.
>>>>
>>>> Actually, this close should check if the value is valid and close it. To
>>>> be honest, this is just a shortcut since close(-1) does not fail and
>>>> ignoring the close error here since we are in the cleanup path anyway so
>>>> we don't necessarily care about the perror message.
>>>>
>>>> Anyhow, we have to handle both error path. An if plus set -1 after close
>>>> can be done so not to confuse.
>>>
>>> if two threads can concurrently perform close on the same fd value, how
>>> can you prove there are no possible races ?
>>
>> Nothing to prove, the race is possible. The point I was trying to
>> explain is that it does not matter actually since we are in a cleanup
>> code path.
>
> what happens if we close FD 0, 1, 2 or another FD, due to this race ?
This does not matter because we are in a "cleanup code path" ... closing
everything is the goal. In other circumstances, I agree that this is
unacceptable.
>
> what happens if our code evolve to restart threads after errors, and we
> leave this race in place, so it becomes hard to reproduce that in some
> occasions we are closing random file descriptors ?
Well... agree but I doubt "lttng_destroy_consumer" will change it's
behavior :P
David
>
>> Anyway, let's remove it since the data thread, when dying, will close
>> the metadata pipe anyway.
>
> my point exactly :)
>
>>
>> This will avoid more discussion for this small detail :).
>
> The devil is in the details, as someone famous said before me.
>
> Thanks,
>
> Mathieu
>
>>
>> David
>>
>>>
>>> Mathieu
>>>
>
prev parent reply other threads:[~2012-10-15 17:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 14:30 David Goulet
2012-10-12 14:30 ` [lttng-dev] [PATCH lttng-tools 2/4] Move add data stream to the data thread David Goulet
2012-10-13 15:53 ` Mathieu Desnoyers
2012-10-15 15:40 ` David Goulet
2012-10-15 17:31 ` Mathieu Desnoyers
2012-10-15 17:40 ` David Goulet
2012-10-15 17:42 ` Mathieu Desnoyers
2012-10-15 17:45 ` David Goulet
2012-10-15 17:56 ` Mathieu Desnoyers
2012-10-12 14:30 ` [lttng-dev] [PATCH lttng-tools 3/4] Make stream hash tables global to the consumer David Goulet
2012-10-13 15:56 ` Mathieu Desnoyers
2012-10-15 15:47 ` David Goulet
2012-10-15 17:57 ` Mathieu Desnoyers
2012-10-12 14:30 ` [lttng-dev] [PATCH lttng-tools 4/4] Change the metadata hash table node David Goulet
2012-10-13 16:00 ` Mathieu Desnoyers
2012-10-15 19:22 ` David Goulet
2012-10-13 15:41 ` [lttng-dev] [PATCH lttng-tools 1/4] Rename consumer threads and spawn them in daemon Mathieu Desnoyers
2012-10-15 15:39 ` David Goulet
2012-10-15 17:28 ` Mathieu Desnoyers
2012-10-15 17:37 ` David Goulet
2012-10-15 17:39 ` Mathieu Desnoyers
2012-10-15 17:42 ` David Goulet [this message]
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=507C4B1D.3050602@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