Module: sip-router
Branch: master
Commit: 7afb2cf8e4640bbaadfc80fcc052b34d5ae3cfae
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7afb2cf…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Thu Aug 11 17:19:20 2011 +0200
modules_k/dialog: Improve dialog timer list handling.
- Avoid updating a dialog timer item if it is not yet linked into
the timer list.
(Avoids reference counting bugs due to race conditions where the
timer list has not been initialized yet prior to any update
attempts.)
- In case of bogus dialog during timer insertion, postpone release
of dialog timer lock until error log message has been emitted.
---
modules_k/dialog/dlg_timer.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/modules_k/dialog/dlg_timer.c b/modules_k/dialog/dlg_timer.c
index 03cc5b3..7308eee 100644
--- a/modules_k/dialog/dlg_timer.c
+++ b/modules_k/dialog/dlg_timer.c
@@ -133,9 +133,9 @@ int insert_dlg_timer(struct dlg_tl *tl, int interval)
lock_get( d_timer->lock);
if (tl->next!=0 || tl->prev!=0) {
- lock_release( d_timer->lock);
LM_CRIT("Trying to insert a bogus dlg tl=%p tl->next=%p
tl->prev=%p\n",
tl, tl->next, tl->prev);
+ lock_release( d_timer->lock);
return -1;
}
tl->timeout = get_ticks()+interval;
@@ -202,14 +202,13 @@ int update_dlg_timer(struct dlg_tl *tl, int timeout)
{
lock_get( d_timer->lock);
- if ( tl->next ) {
- if (tl->prev==0) {
- lock_release( d_timer->lock);
- return -1;
- }
- remove_dialog_timer_unsafe(tl);
+ if (tl->next==0 || tl->prev==0) {
+ LM_CRIT("Trying to update a bogus dlg tl=%p tl->next=%p
tl->prev=%p\n",
+ tl, tl->next, tl->prev);
+ lock_release( d_timer->lock);
+ return -1;
}
-
+ remove_dialog_timer_unsafe( tl );
tl->timeout = get_ticks()+timeout;
insert_dialog_timer_unsafe( tl );