[OpenSER-Devel] timed out dialogs in database

Stanisław Pitucha stanis at zimbra-1.gradwell.net
Wed Mar 12 18:35:36 CET 2008


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openser-timers.patch
Type: text/x-patch
Size: 1447 bytes
Desc: not available
Url : http://lists.openser.org/pipermail/devel/attachments/20080312/91bb8451/attachment.bin 


More information about the Devel mailing list