Hi all
There's a problem when running openser 1.3 with realtime db (maybe cached too,
but haven't checked). I'll just explain why we wanted to fix it in case it
should be fixed in some other way:
@modules/dialog/dlg_db_handler.c:
#define GET_STR_VALUE(_res, _values, _index, _not_null, _unref)\
do{\
if (VAL_NULL((_values)+ (_index))) { \
if (_not_null) {\
if (_unref) unref_dlg(dlg,1);\
continue; \
} else { \
(_res).s = 0; \
(_res).len = 0; \
}\
} else { \
(_res).s = VAL_STR((_values)+ (_index)).s;\
(_res).len = strlen(VAL_STR((_values)+ (_index)).s);\
} \
}while(0);
I guess that "continue" is supposed to skip processing of dialog in
load_dialog_info_from_db(), but it won't really work, because continue is only
getting out of do{}while() macro loop - it leaves _res uninitialized and
continues processing. Fixed by removing "do" and "while" - GET_STR_VALUE isn't
used in parent "if" so it's safe currently.
Then there's destroy_dlg() @modules/dialog/dlg_hash.c which doesn't handle
dialog timer (if unref_dlg() was ran in previous case) - fixed by adding
remove_dlg_timer(&dlg->tl);
Another thing: get_expired_dlgs() @modules/dialog/dlg_timer.c:
race condition in:
---
if (d_timer->first.next==&(d_timer->first)
|| d_timer->first.next->timeout > time )
return 0;
lock_get( d_timer->lock);
... (get other dialogs)
---
it should probably be locked before checking.
Patch attached.Index: dlg_timer.c
===================================================================
--- dlg_timer.c (revision 3927)
+++ dlg_timer.c (working copy)
@@ -172,12 +172,14 @@
{
struct dlg_tl *tl , *end, *ret;
+ lock_get( d_timer->lock);
+
if (d_timer->first.next==&(d_timer->first)
- || d_timer->first.next->timeout > time )
+ || d_timer->first.next->timeout > time ) {
+ lock_release( d_timer->lock);
return 0;
+ }
- lock_get( d_timer->lock);
-
end = &d_timer->first;
tl = d_timer->first.next;
LM_DBG("start with %p (%d) at %d\n", tl,tl->timeout,time);
Index: dlg_db_handler.c
===================================================================
--- dlg_db_handler.c (revision 3927)
+++ dlg_db_handler.c (working copy)
@@ -86,7 +86,7 @@
}while(0);
#define GET_STR_VALUE(_res, _values, _index, _not_null, _unref)\
- do{\
+ {\
if (VAL_NULL((_values)+ (_index))) { \
if (_not_null) {\
if (_unref) unref_dlg(dlg,1);\
@@ -99,7 +99,7 @@
(_res).s = VAL_STR((_values)+ (_index)).s;\
(_res).len = strlen(VAL_STR((_values)+ (_index)).s);\
} \
- }while(0);
+ }
static int load_dialog_info_from_db(int dlg_hash_size);
Index: dlg_hash.c
===================================================================
--- dlg_hash.c (revision 3927)
+++ dlg_hash.c (working copy)
@@ -123,6 +123,8 @@
if (dlg->cbs.first)
destroy_dlg_callbacks_list(dlg->cbs.first);
+ remove_dlg_timer(&dlg->tl);
+
shm_free(dlg);
}
_______________________________________________
Devel mailing list
[email protected]
http://lists.openser.org/cgi-bin/mailman/listinfo/devel