Commit c031a4d4 authored by Pekka Pessi's avatar Pekka Pessi

Added tport_ref() and tport_unref() to tport module.

darcs-hash:20060426163628-65a35-7cd07bb0cf6d2ece5dec6bcc4073f95e8354f510.gz
parent 14acceee
......@@ -188,10 +188,16 @@ TPORT_DLL void tport_destroy(tport_t *tport);
/** Shutdown a transport connection. */
TPORT_DLL int tport_shutdown(tport_t *tport, int how);
/** Create a new transport reference. */
/** Create a new reference to a transport object. */
TPORT_DLL tport_t *tport_ref(tport_t *tp);
/** Destroy reference to a transport object. */
TPORT_DLL void tport_unref(tport_t *tp);
/** Create a new transport reference. @deprecated Use tport_ref(). */
TPORT_DLL tport_t *tport_incref(tport_t *tp);
/** Destroy a transport reference. */
/** Destroy a transport reference. @deprecated Use tport_unref(). */
TPORT_DLL void tport_decref(tport_t **tp);
/** Send a message using transport. */
......
......@@ -985,8 +985,8 @@ void tport_zap_secondary(tport_t *self)
su_home_zap(self->tp_home);
}
/** Create a new transport reference. */
tport_t *tport_incref(tport_t *tp)
/** Create a new reference to a transport object. */
tport_t *tport_ref(tport_t *tp)
{
if (tp) {
if (tp->tp_refs >= 0)
......@@ -997,16 +997,28 @@ tport_t *tport_incref(tport_t *tp)
return tp;
}
/** Destroy reference to a transport object. */
void tport_unref(tport_t *tp)
{
if (tp && tp->tp_refs > 0)
if (--tp->tp_refs == 0 && tp->tp_params->tpp_idle == 0)
if (!tport_is_closed(tp))
tport_close(tp);
}
/** Create a new reference to transport object. */
tport_t *tport_incref(tport_t *tp)
{
return tport_ref(tp);
}
/** Destroy a transport reference. */
void tport_decref(tport_t **ttp)
{
assert(ttp);
if (*ttp) {
if ((*ttp)->tp_refs > 0)
if (--(*ttp)->tp_refs == 0 && (*ttp)->tp_params->tpp_idle == 0)
if (!tport_is_closed(*ttp))
tport_close(*ttp);
tport_unref(*ttp);
*ttp = NULL;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment