axl_bool myqtt_conn_ref ( MyQttConn connection,
const char *  who 

Increase internal myqtt connection reference counting.

Because MyQtt Library design, several on going threads shares references to the same connection for several purposes.

Conn reference counting allows to every on going thread to notify the system that connection reference is no longer in use so, if the reference counting reaches zero, connection resources will be collected.

Keep in mind that using this function also implies to use myqtt_conn_unref . For each call to myqtt_conn_ref it should exist a call to myqtt_conn_unref. Failing to do so will cause either memory leak or memory corruption because improper connection collection.

The function return axl_true to signal that the connection reference count was increased in one unit. If the function return axl_false, the connection reference count wasn't increased and a call to myqtt_conn_unref should not be done. Here is an example:

1 // try to ref the connection
2 if (! myqtt_conn_ref (connection, "some known module or file")) {
3  // unable to ref the connection
4  return;
5 }
7 // connection referenced, do work
9 // finally unref the connection
10 myqtt_conn_unref (connection, "some known module or file");
connectionthe connection to operate.
whowho have increased the reference.
axl_true if the connection reference was increased or axl_false if an error was found.

Referenced by myqtt_conn_close(), myqtt_conn_send_connect_reply(), myqtt_listener_shutdown(), myqtt_storage_queued_flush(), myqttd_conn_mgr_conn_list(), and myqttd_conn_mgr_setup_proxy_on_parent().