And here's the attachments :-)

-- 
Ben Smithurst
http://www.bensmithurst.com/
Index: modules/dialog/dlg_db_handler.c
===================================================================
--- modules/dialog/dlg_db_handler.c     (revision 2709)
+++ modules/dialog/dlg_db_handler.c     (working copy)
@@ -405,6 +405,12 @@
                        from_cseq_column,       to_cseq_column,         
from_route_column,
                        to_route_column,        from_contact_column, 
to_contact_column};
 
+       db_key_t update_keys[DIALOG_TABLE_COL_NO] = {           h_entry_column,
+                       h_id_column,            to_sock_column,
+                       state_column,           timeout_column,
+                       to_contact_column,      from_cseq_column,
+                       to_cseq_column,         start_time_column};
+
        if(use_dialog_table()!=0)
                return -1;
        
@@ -441,10 +447,14 @@
 
                DBG("DBG:dialog:update_dialog_dbinfo: sock_info is %.*s\n", 
                        cell->bind_addr[DLG_CALLER_LEG]->sock_str.len,
-                       cell->bind_addr[DLG_CALLEE_LEG]->sock_str.s);
+                       cell->bind_addr[DLG_CALLER_LEG]->sock_str.s);
 
                SET_STR_VALUE(values+7, 
cell->bind_addr[DLG_CALLER_LEG]->sock_str);
-               SET_STR_VALUE(values+8, 
cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
+               if (cell->bind_addr[DLG_CALLEE_LEG]) {
+                       SET_STR_VALUE(values+8, 
cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
+               } else {
+                       VAL_NULL(values+8) = 1;
+               }
 
                SET_STR_VALUE(values+12, cell->cseq[DLG_CALLER_LEG]);
                SET_STR_VALUE(values+13, cell->cseq[DLG_CALLEE_LEG]);
@@ -470,29 +480,43 @@
        } else if((cell->flags & DLG_FLAG_CHANGED) != 0) {
                /* save only dialog's state and timeout */
                VAL_TYPE(values) = VAL_TYPE(values+1) = 
-               VAL_TYPE(values+10) = VAL_TYPE(values+11) = DB_INT;
+               VAL_TYPE(values+3) = VAL_TYPE(values+4) =
+               VAL_TYPE(values+8) = DB_INT;
 
-               VAL_TYPE(values+12) = VAL_TYPE(values+13) =DB_STR;
+               VAL_TYPE(values+2) = VAL_TYPE(values+5) =
+               VAL_TYPE(values+6) = VAL_TYPE(values+7) =DB_STR;
 
+               VAL_NULL(values) = VAL_NULL(values+1) = 
+               VAL_NULL(values+2) = VAL_NULL(values+3) = 
+               VAL_NULL(values+4) = VAL_NULL(values+5) =
+               VAL_NULL(values+6) = VAL_NULL(values+7) =
+               VAL_NULL(values+8) = 0;
+
                /* lock the entry */
                entry = (d_table->entries)[cell->h_entry];
                dlg_lock( d_table, &entry);
 
                VAL_INT(values)                 = cell->h_entry;
                VAL_INT(values+1)               = cell->h_id;
-               VAL_INT(values+10)              = cell->state;
-               VAL_INT(values+11)              = cell->tl.timeout - 
get_ticks() + 
+               VAL_INT(values+3)               = cell->state;
+               VAL_INT(values+4)               = cell->tl.timeout - 
get_ticks() + 
                                                        (unsigned 
int)clock_time;
-               SET_STR_VALUE(values+12, cell->cseq[DLG_CALLER_LEG]);
-               SET_STR_VALUE(values+13, cell->cseq[DLG_CALLEE_LEG]);
+               VAL_INT(values+8)               = cell->start_ts;
+               if (cell->bind_addr[DLG_CALLEE_LEG]) {
+                       SET_STR_VALUE(values+2, 
cell->bind_addr[DLG_CALLEE_LEG]->sock_str);
+               } else {
+                       VAL_NULL(values+2) = 1;
+               }
 
+               SET_STR_VALUE(values+5, cell->contact[DLG_CALLEE_LEG]);
+               SET_PROPER_NULL_FLAG(cell->contact[DLG_CALLEE_LEG], values, 5);
 
-               VAL_NULL(values) = VAL_NULL(values+1) = 
-               VAL_NULL(values+10) = VAL_NULL(values+11) = 
-               VAL_NULL(values+12) = VAL_NULL(values+13) = 0;
+               LOG(L_ERR, "DIALOG: cseq %s/%s\n", 
cell->cseq[DLG_CALLER_LEG].s, cell->cseq[DLG_CALLEE_LEG].s);
+               SET_STR_VALUE(values+6, cell->cseq[DLG_CALLER_LEG]);
+               SET_STR_VALUE(values+7, cell->cseq[DLG_CALLEE_LEG]);
 
-               if((dialog_dbf.update(dialog_db_handle, (insert_keys), 0, 
-                                               (values), (insert_keys+10), 
(values+10), 2, 4)) !=0){
+               if((dialog_dbf.update(dialog_db_handle, (update_keys), 0, 
+                                               (values), (update_keys+2), 
(values+2), 2, 7)) !=0){
                        LOG(L_ERR, 
"ERROR:dialog:update_single_dialog_dbinfo:could not "
                                "update database info\n");
                        goto error;
Index: modules/dialog/dlg_hash.c
===================================================================
--- modules/dialog/dlg_hash.c   (revision 2709)
+++ modules/dialog/dlg_hash.c   (working copy)
@@ -179,6 +179,7 @@
 
        memset( dlg, 0, len);
        dlg->state = DLG_STATE_UNCONFIRMED;
+       dlg->flags = DLG_FLAG_NEW;
 
        dlg->h_entry = core_hash( callid, from_tag->len?from_tag:0, 
d_table->size);
        DBG("DEBUG:dialog:build_new_dlg: new dialog on hash %u\n",dlg->h_entry);
Index: modules/dialog/dlg_handlers.c
===================================================================
--- modules/dialog/dlg_handlers.c       (revision 2709)
+++ modules/dialog/dlg_handlers.c       (working copy)
@@ -275,6 +275,9 @@
 
        if (new_state==DLG_STATE_EARLY) {
                run_dlg_callbacks(DLGCB_EARLY, dlg, rpl);
+               dlg->flags |= DLG_FLAG_CHANGED;
+               if ( dlg_db_mode==DB_MODE_REALTIME )
+                       update_dialog_dbinfo(dlg);
                if (old_state!=DLG_STATE_EARLY)
                        if_update_stat(dlg_enable_stats, early_dlgs, 1);
                return;
@@ -311,7 +314,7 @@
                /* save the settings to the database, 
                 * if realtime saving mode configured- save dialog now
                 * else: the next time the timer will fire the update*/
-               dlg->flags |= DLG_FLAG_NEW;
+               dlg->flags |= DLG_FLAG_CHANGED;
                if ( dlg_db_mode==DB_MODE_REALTIME )
                        update_dialog_dbinfo(dlg);
 
@@ -601,6 +604,11 @@
        if (event==DLG_EVENT_REQBYE && new_state==DLG_STATE_DELETED &&
        old_state!=DLG_STATE_DELETED) {
                DBG("DEBUG:dialog:dlg_onroute: BYE successfully processed\n");
+
+               dlg->flags |= DLG_FLAG_CHANGED;
+               if ( dlg_db_mode==DB_MODE_REALTIME )
+                       update_dialog_dbinfo(dlg);
+
                /* remove from timer */
                remove_dlg_timer(&dlg->tl);
                /* dialog terminated (BYE) */
@@ -634,7 +642,7 @@
                }
        }
 
-       if(new_state == DLG_STATE_CONFIRMED     && old_state == 
DLG_STATE_CONFIRMED_NA){
+       if (new_state != old_state) {
 
                dlg->flags |= DLG_FLAG_CHANGED;
                if(dlg_db_mode == DB_MODE_REALTIME)
Index: db/schema/dialog.xml
===================================================================
--- db/schema/dialog.xml        (revision 2709)
+++ db/schema/dialog.xml        (working copy)
@@ -9,7 +9,7 @@
 
 <table id="dialog" xmlns:db="http://docbook.org/ns/docbook";>
        <name>dialog</name>
-       <version>1</version>
+       <version>2</version>
        <type db="mysql">&MYSQL_TABLE_TYPE;</type>
        <description>
                <db:para>Persistent dialog information for the dialog module. 
More 
@@ -77,6 +77,7 @@
                <name>to_tag</name>
                <type>string</type>
                <size>&user_len;</size>
+               <null/>
                <description>The tag parameter serves as a general mechanism to 
                identify a dialog, which is the combination of the Call-ID 
along 
                with two tags, one from participant in the dialog.</description>
@@ -123,6 +124,7 @@
                <name>callee_contact</name>
                <type>string</type>
                <size>&uri_len;</size>
+               <null/>
                <description>Callee's contact uri.</description>
        </column>
 
@@ -137,6 +139,7 @@
                <name>callee_sock</name>
                <type>string</type>
                <size>64</size>
+               <null/>
                <description>Local socket used to communicate with 
callee</description>
        </column>
 
_______________________________________________
Devel mailing list
Devel@openser.org
http://openser.org/cgi-bin/mailman/listinfo/devel

Reply via email to