[OpenSER-Devel] Dialog start time issue

Jerome Martin jmartin at longphone.fr
Wed Jan 9 14:21:15 UTC 2008


Hi again list :-)

Just to let you know that I went for option 4/ below, just moving
start_ts from relative time (ticks) to absolute time. As this is used
apparently only for DLG_LIFETIME calculation, this should not have any
side effect. Please someone tell me if this patch can be integrated of
if this should be done an other way (posting patch to sourceforge right
ahead).

diff -Naurd openser_1.3-3442~/modules/dialog/dlg_handlers.c
openser_1.3-3442/modules/dialog/dlg_handlers.c
--- openser_1.3-3442~/modules/dialog/dlg_handlers.c     2007-12-06
13:10:17.000000000 +0100
+++ openser_1.3-3442/modules/dialog/dlg_handlers.c      2008-01-09
15:09:10.000000000 +0100
@@ -302,7 +302,7 @@
                }
 
                /* set start time */
-               dlg->start_ts = get_ticks();
+               dlg->start_ts = (unsigned int)(time(0));
 
                /* save the settings to the database, 
                 * if realtime saving mode configured- save dialog now
@@ -577,7 +577,7 @@
        next_state_dlg( dlg, event, &old_state, &new_state, &unref);
 
        CURR_DLG_ID = req->id;
-       CURR_DLG_LIFETIME = get_ticks()-dlg->start_ts;
+       CURR_DLG_LIFETIME = (unsigned int)(time(0))-dlg->start_ts;
        CURR_DLG_STATUS = new_state;
 
        /* run actions for the transition */


On Wed, 2008-01-09 at 13:02 +0100, Jerome Martin wrote:
> Hello all,
> 
> I'm being confronted to an annoying issue with the dialog module (using
> rev 3442 from 1.3 branch svn) :
> 
> One of the purposes of me using the dialog is to be able to calculate
> call duration. This works fine in basic cases, but fails when openser is
> stopped then restarted (dialog database mode 1 aka realtime). I need
> this to work, as this is the only way I can ensure reliable dialog-state
> awareness in a HA environment (in my setup, if the physical machine
> holding the openser vserver dies, the vserver is restarted somewhere
> else).
> 
> Here is the issue : when saving dialog state in database, the stored
> value is the start_ts of the dialog, which is a relative amount of time
> since openser startup. For the dialog state to be meanfull accross
> restarts, it needs to be an absolute time value (relative to epoch). So
> intuitively, we would need to store time(0)-get_ticks()+start_ts, which
> is exactly what is curretly being done for the dialog expiration time
> (tl.timeout). However, the problem is that one can not restore that
> value simply without completly changing the way the dialog module
> handles those timestamps (relative to openser start), because this is an
> unsigned value and upon restore the start_ts will be negative (dialog
> start time is BEFORE the actual openser start). I was thinking of
> submitting a patch, but before that I'd like to have your advice on the
> best implementation :
> 
> 1/ Use signed int values, allowing start_ts dating back to before the
> actual openser startup. This is easy, but maybe an int will be a bit
> short for that ?
> 
> 2/ Convert all jiffies to absolute time (get_ticks would return jiffies
> + startup time).
> 
> 3/ Keep the start_ts not to break anything but add an absolute_start_ts
> in db, and make DLG_DURATION use that one.
> 
> 4/ Suggest a better way than 1,2 or 3 that I have missed, that would be
> simpler :-)
> 
> What do you think ?
> 
> Regards,
-- 
Jérôme Martin | LongPhone
Responsable Architecture Réseau
122, rue la Boetie | 75008 Paris
Tel :  +33 (0)1 56 26 28 44
Fax : +33 (0)1 56 26 28 45
Mail : jmartin at longphone.fr
Web : www.longphone.com <http://www.longphone.com>




More information about the Devel mailing list