mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
revert patch from sofia-sip darcs causing memory leak:
Mon Oct 8 07:54:24 EDT 2007 Pekka.Pessi@nokia.com * nua.c: nua event callback does not use nua_t object after nua_destroy() call. sf.net bug #1803686 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6020 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
27268166d7
commit
f7cfd7810e
@ -195,13 +195,6 @@ void nua_shutdown(nua_t *nua)
|
||||
nua_signal(nua, NULL, NULL, 1, nua_r_shutdown, 0, NULL, TAG_END());
|
||||
}
|
||||
|
||||
/** @internal Linked stack frames from nua event callback */
|
||||
struct nua_event_frame_s {
|
||||
nua_event_frame_t *nf_next;
|
||||
nua_t *nf_nua;
|
||||
nua_saved_event_t nf_saved[1];
|
||||
};
|
||||
|
||||
/** Destroy the @nua stack.
|
||||
*
|
||||
* Before calling nua_destroy() the application
|
||||
@ -227,8 +220,6 @@ void nua_destroy(nua_t *nua)
|
||||
enter;
|
||||
|
||||
if (nua) {
|
||||
nua_event_frame_t *nf;
|
||||
|
||||
if (!nua->nua_shutdown_final) {
|
||||
SU_DEBUG_0(("nua_destroy(%p): FATAL: nua_shutdown not completed\n",
|
||||
(void *)nua));
|
||||
@ -236,13 +227,6 @@ void nua_destroy(nua_t *nua)
|
||||
return;
|
||||
}
|
||||
|
||||
nua->nua_callback = NULL;
|
||||
|
||||
for (nf = nua->nua_current; nf; nf = nf->nf_next) {
|
||||
nf->nf_nua = NULL;
|
||||
}
|
||||
nua->nua_current = NULL;
|
||||
|
||||
su_task_deinit(nua->nua_server);
|
||||
su_task_deinit(nua->nua_client);
|
||||
|
||||
@ -1000,9 +984,8 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
|
||||
{
|
||||
nua_t *nua;
|
||||
nua_handle_t *nh = e->e_nh;
|
||||
enter;
|
||||
|
||||
e->e_nh = NULL;
|
||||
enter;
|
||||
|
||||
if (nh) {
|
||||
if (!nh->nh_ref_by_user && nh->nh_valid) {
|
||||
@ -1030,40 +1013,40 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
|
||||
|
||||
nua = nh->nh_nua; assert(nua);
|
||||
|
||||
if (NH_IS_DEFAULT(nh))
|
||||
nh = NULL;
|
||||
|
||||
if (e->e_event == nua_r_shutdown && e->e_status >= 200)
|
||||
nua->nua_shutdown_final = 1;
|
||||
|
||||
if (nua->nua_callback) {
|
||||
nua_event_frame_t frame[1];
|
||||
|
||||
su_msg_remove_refs(sumsg); /* Remove references to tasks */
|
||||
su_msg_save(frame->nf_saved, sumsg);
|
||||
frame->nf_nua = nua;
|
||||
frame->nf_next = nua->nua_current, nua->nua_current = frame;
|
||||
if (!nua->nua_callback)
|
||||
return;
|
||||
|
||||
nua->nua_callback(e->e_event, e->e_status, e->e_phrase,
|
||||
nua, nua->nua_magic,
|
||||
nh, nh ? nh->nh_magic : NULL,
|
||||
e->e_msg ? sip_object(e->e_msg) : NULL,
|
||||
e->e_tags);
|
||||
if (NH_IS_DEFAULT(nh))
|
||||
nh = NULL;
|
||||
|
||||
su_msg_destroy(frame->nf_saved);
|
||||
su_msg_save(nua->nua_current, sumsg);
|
||||
|
||||
if (frame->nf_nua == NULL)
|
||||
return;
|
||||
nua->nua_current = frame->nf_next;
|
||||
}
|
||||
e->e_nh = NULL;
|
||||
|
||||
if (nh && nua_handle_unref(nh)) {
|
||||
nua->nua_callback(e->e_event, e->e_status, e->e_phrase,
|
||||
nua, nua->nua_magic,
|
||||
nh, nh ? nh->nh_magic : NULL,
|
||||
e->e_msg ? sip_object(e->e_msg) : NULL,
|
||||
e->e_tags);
|
||||
|
||||
if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
|
||||
#if HAVE_NUA_HANDLE_DEBUG
|
||||
SU_DEBUG_0(("nua(%p): freed by application\n", (void *)nh));
|
||||
#else
|
||||
SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!su_msg_is_non_null(nua->nua_current))
|
||||
return;
|
||||
|
||||
if (e->e_msg)
|
||||
msg_destroy(e->e_msg), e->e_msg = NULL;
|
||||
|
||||
su_msg_destroy(nua->nua_current);
|
||||
}
|
||||
|
||||
/** Get current request message. @NEW_1_12_4.
|
||||
@ -1074,9 +1057,7 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
|
||||
*/
|
||||
msg_t *nua_current_request(nua_t const *nua)
|
||||
{
|
||||
if (nua && nua->nua_current && su_msg_is_non_null(nua->nua_current->nf_saved))
|
||||
return su_msg_data(nua->nua_current->nf_saved)->e_msg;
|
||||
return NULL;
|
||||
return nua && nua->nua_current ? su_msg_data(nua->nua_current)->e_msg : NULL;
|
||||
}
|
||||
|
||||
/** Get request message from saved nua event. @NEW_1_12_4.
|
||||
@ -1094,15 +1075,14 @@ msg_t *nua_saved_event_request(nua_saved_event_t const *saved)
|
||||
*/
|
||||
int nua_save_event(nua_t *nua, nua_saved_event_t return_saved[1])
|
||||
{
|
||||
if (return_saved) {
|
||||
if (nua && nua->nua_current) {
|
||||
su_msg_save(return_saved, nua->nua_current->nf_saved);
|
||||
return su_msg_is_non_null(return_saved);
|
||||
if (nua && return_saved) {
|
||||
su_msg_save(return_saved, nua->nua_current);
|
||||
if (su_msg_is_non_null(return_saved)) {
|
||||
/* Remove references to tasks */
|
||||
su_msg_remove_refs(return_saved);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
*return_saved = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -197,8 +197,6 @@ int nh_is_special(nua_handle_t *nh)
|
||||
return nh == NULL || nh->nh_special;
|
||||
}
|
||||
|
||||
typedef struct nua_event_frame_s nua_event_frame_t;
|
||||
|
||||
extern char const nua_internal_error[];
|
||||
|
||||
#define NUA_INTERNAL_ERROR 900, nua_internal_error
|
||||
@ -216,7 +214,7 @@ struct nua_s {
|
||||
nua_callback_f nua_callback;
|
||||
nua_magic_t *nua_magic;
|
||||
|
||||
nua_event_frame_t *nua_current;
|
||||
nua_saved_event_t nua_current[1];
|
||||
nua_saved_event_t nua_signal[1];
|
||||
|
||||
/* Engine state flags */
|
||||
|
Loading…
x
Reference in New Issue
Block a user