Fix: increment UST channel refcount at stream creation
authorDavid Goulet <dgoulet@efficios.com>
Fri, 17 May 2013 18:08:14 +0000 (14:08 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 17 May 2013 18:08:14 +0000 (14:08 -0400)
commitb31398bb2b3fa91a53dea3b36fd693da4b50e0d3
tree91dac21c09fe79e7e52efb5e38c0278ead92f2f8
parentc5db699c91964a0f2c73f75677504c531f9f376f
Fix: increment UST channel refcount at stream creation

Having the channel refcount incremented only when the stream is sent to a
thread could triggered a segfault with a race between a channel destroyed by
the channel thread and the stream pointers being inflight in the thread pipe.

Once read from the pipe, the streams are added to the data thread poll set and
immediately destroyed since the channel has hung up previously but the flush
buffer segfaulted on the channel that was already deleted by the channel thread
with a refcount set to 0.

This is fixed by incrementing the channel refcount once the stream is created
and the channel reference is set to it. This is done *before* the channel
object is visible in the channel thread. Now the channel thread detects the
hang up but will not destroy the channel because of the refcount > 0. The
channel cleanup will be done by the last stream hanging up.

Fixes #530

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/consumer.c
src/common/ust-consumer/ust-consumer.c
This page took 0.025193 seconds and 4 git commands to generate.