[Vortex] How to correctly close a connection?
Francis Brosnan Blazquez
francis at aspl.es
Mon Oct 6 18:52:11 CEST 2008
Hi Robert,
> The client. But the script on the client is asynchronous as well. So
> the
> client script needs either to poll via a call if a transfer is still
> ongoing before calling the close-connection function.
If so, you can use vortex_channel_is_ready to check every channel on the
connection (with capabilities to transfer). If all of them are ready (no
pending message to be replied) you can safely use
vortex_connection_close without blocking.
Of course this assumes the listener won't bother with new messages
during the call to vortex_connection_close.
> The other option (I
> prefer) is to make close-connection blocking until all transfers
> ended.
Ok.
> > This is right. If you receive this notification, then the connection
> was
> > notified to be closed. However, the connection is still accesible
> until
> > all vortex subsystem drop its references to the connection (and
> those
> > ones created by your code).
>
> Ok. The client uses a shutdown call for this. On the receiver side, I
> do
> it by hand because the receiver switches back to listening state to
> serve
> other possible client connections.
What you mean "by hand"? In any case, if the client side is controlling
connection close, do nothing at the listener.
> > But, it crashes when the connection that was notified to be closed
> is
> > used again? or...?
>
> No, on the server at the moment the client closes the connection.
Ok.
> > If so, the connection must not be used once the handler finishes.
>
> Yes, this is ensured and I don't use it anylonger.
>
>
> The strange thing is, I only get the crash on Linux. On Windows it
> works.
> Here is the GDB backtrace:
>
> #0 0xb7ebc71c in free () from /lib/tls/i686/cmov/libc.so.6
> #1 0xb7d3060d in axl_hash_free (hash=0x3e8bb) at axl_hash.c:1216
> #2 0xb7d028f8 in vortex_hash_destroy (hash_table=0x821a908)
> at vortex_hash.c:357
> #3 0xb7cebdf1 in vortex_connection_free (connection=0x821a598)
> at vortex_connection.c:2494
> #4 0xb7d00d61 in __vortex_reader_build_set_to_watch_aux (
> on_reading=0x814f118, cursor=0x814f840, current_max=10)
> at vortex_reader.c:971
> #5 0xb7d0200d in __vortex_reader_run (ctx=0x814e108) at
> vortex_reader.c:1228
> #6 0xb7cc5240 in start_thread ()
> from /lib/tls/i686/cmov/libpthread.so.0
> #7 0xb7f2249e in clone () from /lib/tls/i686/cmov/libc.so.6
>
> Any idea?
It really looks like the connection is being closed or deallocated
twice. Do you call to close or unref or shutdown at the listener side
when the client side closes? That is, what you mean with "by hand"? ;-)
Cheers!
--
Francis Brosnan Blazquez <francis at aspl.es>
Advanced Software Production Line, S.L.
More information about the Vortex
mailing list