[Vortex] closing a channel in the on_channel_created callback

Francis Brosnan Blazquez francis at aspl.es
Mon Mar 31 11:04:45 CEST 2008

> Hi,

Hi Dexter,

> I was wondering if it is allowed to close the channel right in the 
> on_channel_created callback. If it is, then maybe there's a race cond 
> somewhere, because my program sometimes (not always) segfaults, here's 
> the backtrace:
> #0  0xb6dfe550 in pthread_mutex_lock () from 
> /lib/tls/i686/cmov/libpthread.so.0
> #1  0xb6fce9f1 in vortex_mutex_lock (mutex_def=0x7854) at 
> vortex_thread.c:297
> #2  0xb6fbf22c in vortex_hash_lookup (hash_table=0x1, key=0xb6fd4d6d) at 
> vortex_hash.c:248
> #3  0xb6fb5b5f in vortex_channel_get_data (channel=0x80d81e8, 
> key=0xb6fd4d6d) at vortex_channel.c:3200
> #4  0xb6fb5dbb in vortex_channel_have_piggyback (channel=0x80d81e8) at 
> vortex_channel.c:5935
> #5  0xb6fba892 in __vortex_channel_new (data=0x80d84b8) at 
> vortex_channel.c:867
> #6  0xb6fc0eed in __vortex_thread_pool_dispatcher (data=0x80c00b8) at 
> vortex_thread_pool.c:101
> #7  0xb6dfc46b in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
> #8  0xb6bbd6de in clone () from /lib/tls/i686/cmov/libc.so.6
> as we can see the hash_table (channel->data) has already been freed, but 
> it is not NULL so in vortex_hash_lookup checking hash_table against NULL 
> is no use.
> But.. if it is not allowed to close channel in that callback, how can I 
> do that? Because I don't need that channel anymore, I was just using 
> this vortex_channel_new to check if the connection is still alive, so 
> when I got the channel I know that the connection is ok, and I just 
> close it.

I wasn't able to reproduce the bug. In fact channel create notification
is protected by two channel_ref/unref instructions to avoid race
conditions. Which version are you using?

In any case, as points Jens, it is preferred to create a
"keep-alive-check" channel sending data rather than creating a channel. 

This is because creating a channel blocks the session channel 0 which is
not interesting. With the alternative you can run your checks and other
parallel operations at the same time.

Francis Brosnan Blazquez <francis at aspl.es>
Advanced Software Production Line, S.L.

More information about the Vortex mailing list