[Vortex] How to correctly close a connection?

Robert M. Münch robert.muench at robertmuench.de
Wed Oct 15 09:16:43 CEST 2008

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

>> So vortex tries to free all user stored data if a connection is
>> closed?
> That's the point. vortex_connection_data_set_full is provided to
> associate user defined data that has some meaning to the particular
> session.
> Because Vortex is highly threaded, the API also allows to configure the
> handler to be called to terminate that reference so you don't have to
> worry about who or when closes the connection...

Hi, more precisely the _full variant allows to provide deallocation-handlers for the key and value parts of the hash. I see this is a way to provide custom resource management functions.

However, closing a connection not only frees all data within the hash associated with the connection but although closes all channels, which than free all data within the channel specific hashes.

I think this should be reflected much better in the docs. And, the order of ressource deallocation should be listed as well. I think this is a very critical point when using vortex and can lead to a lot of problems if something goes wrong.

>> And it assume that only pointers that can be deallocated are stored?
> ..vortex only deallocs those pointers that have a dealloc function
> associated.

So, how are things deallocated that are added by vortex_connection_set_data which doesn't provide any deallocation handler?

>> I'd check all calls done to store user defined data via
>> vortex_connection_set_data or vortex_connection_set_data_full. The
>> application is setting a pointer to nothing (with an associated
>> dealloc function built on top of free).

The strange thing is, that I don't use the *_full variants of the functions. I'm storing data into the hashes of channels and connection. And it looks something goes wrong there. I think I have tracked down one point (now closing one more channel) but there is still one problem with the last channel.

Couldn't this be implemented more gracefully? I mean vortex shouldn't crash when deallocating the hashes at all. A memory leak is much "better" than a crash.

Robert M. Münch
Mobile: +49 (177) 245 2802

More information about the Vortex mailing list