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)
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>

No differences found
This page took 0.027017 seconds and 4 git commands to generate.