axl_bool vortex_connection_close ( VortexConnection connection)

Tries to close properly a connection and all channels inside it.

This function close a connection and unref it using vortex_connection_unref.

Because there can be channels created and still working this function will try to close them by executing vortex_channel_close on them. If vortex_channel_close fails for one of them, the vortex_connection_close will be stopped and the connection will not be closed.

Do not call this function twice because a unref operations is performed over the connection if the function returns axl_true. This means after calling this function the connection reference must not be used until a new connection is created. Otherwise a segfault may happen.

If the function receives a null connection reference, it will just return a axl_true value without doing nothing.

connectionthe connection to close properly.
axl_true if connection was closed and axl_false if not. If there are channels still working, the connection will not be closed.

NOTE: Using full close procedure (the one implemented by this function) may make your connection to suffer BNRA (see In general, is a good practise to close the connection using vortex_connection_shutdown.

References vortex_connection_is_ok(), vortex_connection_ref(), vortex_connection_unref(), vortex_mutex_lock(), vortex_mutex_unlock(), VortexConnectionCloseCalled, VortexError, VortexRoleInitiator, and VortexRoleMasterListener.

Referenced by vortex_connection_is_ok().