From f33556bc15b8de6d7701eb6960ca1fa782bc8818 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 14 Sep 2006 18:20:52 +0300 Subject: [PATCH] Add proper handling of unknown NUA events to nua_glib. darcs-hash:20060914152052-7659e-e768ba7ec78e1d1d00a1193fcbc62c7181622151.gz --- libsofia-sip-ua-glib/nua-glib/nua_glib.c | 6 ++++++ libsofia-sip-ua-glib/nua-glib/nua_glib_op.c | 15 +++++++++++++++ libsofia-sip-ua-glib/nua-glib/nua_glib_op.h | 1 + 3 files changed, 22 insertions(+) diff --git a/libsofia-sip-ua-glib/nua-glib/nua_glib.c b/libsofia-sip-ua-glib/nua-glib/nua_glib.c index 9b179712..e255ec8d 100644 --- a/libsofia-sip-ua-glib/nua-glib/nua_glib.c +++ b/libsofia-sip-ua-glib/nua-glib/nua_glib.c @@ -1217,6 +1217,12 @@ sof_callback(nua_event_t event, g_warning("%s: unknown event %d\n", self->priv->name, event); tl_print(stderr, "", tags); + + if (nua_glib_op_find_by_handle(self, nh) == NULL) { + /* note: unknown handle, not associated to any existing call, + * message, registration, etc, so it can be safely destroyed */ + nua_handle_destroy(nh); + } } /* ====================================================================== */ diff --git a/libsofia-sip-ua-glib/nua-glib/nua_glib_op.c b/libsofia-sip-ua-glib/nua-glib/nua_glib_op.c index a721873c..0a260f1f 100644 --- a/libsofia-sip-ua-glib/nua-glib/nua_glib_op.c +++ b/libsofia-sip-ua-glib/nua-glib/nua_glib_op.c @@ -195,6 +195,20 @@ void nua_glib_op_destroy(NuaGlib *self, NuaGlibOp *op) su_free(self->priv->home, op); } +/** + * Finds an operation by nua handle. + */ +NuaGlibOp *nua_glib_op_find_by_handle(NuaGlib *self, nua_handle_t *handle) +{ + NuaGlibOp *op; + + for (op = self->priv->operations; op; op = op->op_next) + if (op->op_handle == handle) + break; + + return op; +} + /** * Finds a call/session operation (an operation that has non-zero * op_callstate). @@ -210,6 +224,7 @@ NuaGlibOp *nua_glib_op_find_session(NuaGlib *self) return op; } + /** * Checks whether 'op' is a valid handle or not. * diff --git a/libsofia-sip-ua-glib/nua-glib/nua_glib_op.h b/libsofia-sip-ua-glib/nua-glib/nua_glib_op.h index ebc3b75b..af4dc70b 100644 --- a/libsofia-sip-ua-glib/nua-glib/nua_glib_op.h +++ b/libsofia-sip-ua-glib/nua-glib/nua_glib_op.h @@ -39,6 +39,7 @@ NuaGlibOp *nua_glib_op_create_with_handle(NuaGlib *self, nua_handle_t *nh, sip_from_t const *from); void nua_glib_op_destroy(NuaGlib *self, NuaGlibOp *op); +NuaGlibOp *nua_glib_op_find_by_handle(NuaGlib *self, nua_handle_t *handle); NuaGlibOp *nua_glib_op_find_session(NuaGlib *self); NuaGlibOp *nua_glib_op_check(NuaGlib *self, NuaGlibOp *op); -- 2.21.0