[Vortex] How to correctly close a connection?

Robert M. Münch robert.muench at robertmuench.de
Thu Oct 16 22:06:58 CEST 2008

Am 14.10.2008, 18:59 Uhr, schrieb Francis Brosnan Blazquez  
<francis at aspl.es>:

> ..vortex only deallocs those pointers that have a dealloc function
> associated.

Hi, than I'm wondering even more why it crashes because I only use  
vortext_connection_set_data but not the _full variante.

I'm still stucked.

This is the output of my on_connection_close handler on the receiver  

--> on_connection_closed (server handler)
to_rebol_processor: socket created
to_rebol_processor: data send, message = connection-closed [id 2 host port 2690]
to_rebol_processor: socket closed
<-- on_connection_closed (server handler)

Now comes some vortex log output:

closing connection id=2 to
closing session id=2 and set to be not connected
calling to discard messages pending to be sequenced for connection id=2
decreased connection id=2 reference count to 0 decreased by vortex reader  
freeing connection id=2
calling to discard messages pending to be sequenced for connection id=2
freeing connection channels id=2
channel=0 unref called, ref count status after calling=0
   freeing channel=0, ref count is 0
freeing resources for channel 0
freeing receive_mutex
freeing send_mutex channel=0
freeing close_mutex
freeing pending_mutex
freeing serialize_mutex
freeing ref_mutex
freeing close_cond
freeing pending_cond
freeing messages queue
freeing SEQ frames queue
freeing waiting reply queue
freeing previous frames
freeing channel node
<-- END

This channel stuff output is now repeated for each channel. That's ok.  
Than I see this:

	freeing connection custom data holder id=2

and than it crashes.

The above message is issued from this code inside vortext_connection.c

	vortex_log (LOG_DOMAIN, VORTEX_LEVEL_DEBUG, "freeing connection custom  
data holder id=%d", connection->id);
	/* free connection data hash */
	if (connection->data) {
		vortex_hash_destroy (connection->data);
		connection->data = NULL;

I really don't have a clue why it crashes. To see if this is the root  
cause at all I tried to use the following line in my on_connection_close  

	// ATT: hack to avoid server crash, produces memory leak
	client_connection->data = NULL;

But this won't compile with GCC. I get an "dereferencing to incomplete  
type error". I have no clue why. I get the same error if I want to add:

	// traverse the hash
	vortex_hash_foreach(client_connection->data, hash_debug, NULL);

to take a look at what's stored inside the hash.

Any further idea?

Robert M. Münch
Management and IT freelancer

More information about the Vortex mailing list