|
@@ -2,6 +2,7 @@
|
|
|
* $Id$
|
|
|
*
|
|
|
* Copyright (C) 2007 Voice System SRL
|
|
|
+ * Copyright (C) 2011 Carsten Bock, [email protected]
|
|
|
*
|
|
|
* This file is part of Kamailio, a free SIP server.
|
|
|
*
|
|
@@ -37,6 +38,7 @@
|
|
|
#include "../../str.h"
|
|
|
#include "../../socket_info.h"
|
|
|
#include "dlg_hash.h"
|
|
|
+#include "dlg_var.h"
|
|
|
#include "dlg_db_handler.h"
|
|
|
|
|
|
|
|
@@ -64,6 +66,12 @@ str req_uri_column = str_init(REQ_URI_COL);
|
|
|
str dialog_table_name = str_init(DIALOG_TABLE_NAME);
|
|
|
int dlg_db_mode = DB_MODE_NONE;
|
|
|
|
|
|
+str vars_h_id_column = str_init(VARS_HASH_ID_COL);
|
|
|
+str vars_h_entry_column = str_init(VARS_HASH_ENTRY_COL);
|
|
|
+str vars_key_column = str_init(VARS_KEY_COL);
|
|
|
+str vars_value_column = str_init(VARS_VALUE_COL);
|
|
|
+str dialog_vars_table_name = str_init(DIALOG_VARS_TABLE_NAME);
|
|
|
+
|
|
|
static db1_con_t* dialog_db_handle = 0; /* database connection handle */
|
|
|
static db_func_t dialog_dbf;
|
|
|
|
|
@@ -109,15 +117,16 @@ extern int early_dlgs_cnt;
|
|
|
|
|
|
|
|
|
static int load_dialog_info_from_db(int dlg_hash_size, int fetch_num_rows);
|
|
|
-
|
|
|
+static int load_dialog_vars_from_db(int fetch_num_rows);
|
|
|
|
|
|
int dlg_connect_db(const str *db_url)
|
|
|
{
|
|
|
- dialog_db_handle = dialog_dbf.init(db_url);
|
|
|
- if(dialog_db_handle == 0) {
|
|
|
- LM_ERR("unable to connect to database\n");
|
|
|
+ if (dialog_db_handle) {
|
|
|
+ LM_CRIT("BUG - db connection found already open\n");
|
|
|
return -1;
|
|
|
}
|
|
|
+ if ((dialog_db_handle = dialog_dbf.init(db_url)) == 0)
|
|
|
+ return -1;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -136,7 +145,12 @@ int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int
|
|
|
}
|
|
|
|
|
|
if(db_check_table_version(&dialog_dbf, dialog_db_handle, &dialog_table_name, DLG_TABLE_VERSION) < 0) {
|
|
|
- LM_ERR("error during table version check.\n");
|
|
|
+ LM_ERR("error during dialog-table version check.\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(db_check_table_version(&dialog_dbf, dialog_db_handle, &dialog_vars_table_name, DLG_VARS_TABLE_VERSION) < 0) {
|
|
|
+ LM_ERR("error during dialog-vars version check.\n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -150,6 +164,10 @@ int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int
|
|
|
LM_ERR("unable to load the dialog data\n");
|
|
|
return -1;
|
|
|
}
|
|
|
+ if( (load_dialog_vars_from_db(fetch_num_rows) ) !=0 ){
|
|
|
+ LM_ERR("unable to load the dialog data\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
|
|
|
dialog_dbf.close(dialog_db_handle);
|
|
|
dialog_db_handle = 0;
|
|
@@ -185,6 +203,21 @@ static int use_dialog_table(void)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int use_dialog_vars_table(void)
|
|
|
+{
|
|
|
+ if(!dialog_db_handle){
|
|
|
+ LM_ERR("invalid database handle\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dialog_dbf.use_table(dialog_db_handle, &dialog_vars_table_name) < 0) {
|
|
|
+ LM_ERR("Error in use_table\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
static int select_entire_dialog_table(db1_res_t ** res, int fetch_num_rows)
|
|
@@ -414,11 +447,120 @@ error:
|
|
|
|
|
|
|
|
|
|
|
|
+static int select_entire_dialog_vars_table(db1_res_t ** res, int fetch_num_rows)
|
|
|
+{
|
|
|
+ db_key_t query_cols[DIALOG_VARS_TABLE_COL_NO] = { &vars_h_entry_column,
|
|
|
+ &vars_h_id_column, &vars_key_column, &vars_value_column };
|
|
|
+
|
|
|
+ if(use_dialog_vars_table() != 0){
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* select the whole tabel and all the columns */
|
|
|
+ if (DB_CAPABILITY(dialog_dbf, DB_CAP_FETCH) && (fetch_num_rows > 0)) {
|
|
|
+ if(dialog_dbf.query(dialog_db_handle,0,0,0,query_cols, 0,
|
|
|
+ DIALOG_VARS_TABLE_COL_NO, 0, 0) < 0) {
|
|
|
+ LM_ERR("Error while querying (fetch) database\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if(dialog_dbf.fetch_result(dialog_db_handle, res, fetch_num_rows) < 0) {
|
|
|
+ LM_ERR("fetching rows failed\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(dialog_dbf.query(dialog_db_handle,0,0,0,query_cols, 0,
|
|
|
+ DIALOG_VARS_TABLE_COL_NO, 0, res) < 0) {
|
|
|
+ LM_ERR("Error while querying database\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int load_dialog_vars_from_db(int fetch_num_rows)
|
|
|
+{
|
|
|
+ db1_res_t * res;
|
|
|
+ db_val_t * values;
|
|
|
+ db_row_t * rows;
|
|
|
+ struct dlg_cell * dlg;
|
|
|
+ int i, nr_rows;
|
|
|
+
|
|
|
+ res = 0;
|
|
|
+ if((nr_rows = select_entire_dialog_vars_table(&res, fetch_num_rows)) < 0)
|
|
|
+ goto end;
|
|
|
+
|
|
|
+ nr_rows = RES_ROW_N(res);
|
|
|
+
|
|
|
+ LM_DBG("the database has information about %i dialog variables\n", nr_rows);
|
|
|
+
|
|
|
+ rows = RES_ROWS(res);
|
|
|
+
|
|
|
+ do {
|
|
|
+ /* for every row---dialog */
|
|
|
+ for(i=0; i<nr_rows; i++){
|
|
|
+
|
|
|
+ values = ROW_VALUES(rows + i);
|
|
|
+
|
|
|
+ if (VAL_NULL(values) || VAL_NULL(values+1)) {
|
|
|
+ LM_ERR("columns %.*s or/and %.*s cannot be null -> skipping\n",
|
|
|
+ vars_h_entry_column.len, vars_h_entry_column.s,
|
|
|
+ vars_h_id_column.len, vars_h_id_column.s);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (VAL_NULL(values+2) || VAL_NULL(values+3)) {
|
|
|
+ LM_ERR("columns %.*s or/and %.*s cannot be null -> skipping\n",
|
|
|
+ vars_key_column.len, vars_key_column.s,
|
|
|
+ vars_value_column.len, vars_value_column.s);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (VAL_INT(values) < d_table->size) {
|
|
|
+ dlg = (d_table->entries)[VAL_INT(values)].first;
|
|
|
+ while (dlg) {
|
|
|
+ if (dlg->h_id == VAL_INT(values+1)) {
|
|
|
+ set_dlg_variable_unsafe(dlg, &VAL_STR(values+2), &VAL_STR(values+3), 0);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dlg = dlg->next;
|
|
|
+ if (!dlg) {
|
|
|
+ LM_WARN("insonsistent data: the dialog h_entry/h_id does not exist!\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ LM_WARN("insonsistent data: the h_entry in the DB does not exist!\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* any more data to be fetched ?*/
|
|
|
+ if (DB_CAPABILITY(dialog_dbf, DB_CAP_FETCH) && (fetch_num_rows > 0)) {
|
|
|
+ if(dialog_dbf.fetch_result(dialog_db_handle, &res, fetch_num_rows) < 0) {
|
|
|
+ LM_ERR("re-fetching rows failed\n");
|
|
|
+ goto error;
|
|
|
+ }
|
|
|
+ nr_rows = RES_ROW_N(res);
|
|
|
+ rows = RES_ROWS(res);
|
|
|
+ } else {
|
|
|
+ nr_rows = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }while (nr_rows>0);
|
|
|
+
|
|
|
+end:
|
|
|
+ dialog_dbf.free_result(dialog_db_handle, res);
|
|
|
+ return 0;
|
|
|
+error:
|
|
|
+ dialog_dbf.free_result(dialog_db_handle, res);
|
|
|
+ return -1;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
/*this is only called from destroy_dlg, where the cell's entry lock is acquired*/
|
|
|
int remove_dialog_from_db(struct dlg_cell * cell)
|
|
|
{
|
|
|
db_val_t values[2];
|
|
|
db_key_t match_keys[2] = { &h_entry_column, &h_id_column};
|
|
|
+ db_key_t vars_match_keys[2] = { &vars_h_entry_column, &vars_h_id_column};
|
|
|
|
|
|
/*if the dialog hasn 't been yet inserted in the database*/
|
|
|
LM_DBG("trying to remove dialog [%.*s], update_flag is %i\n",
|
|
@@ -441,17 +583,83 @@ int remove_dialog_from_db(struct dlg_cell * cell)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ if (use_dialog_vars_table()!=0)
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ if(dialog_dbf.delete(dialog_db_handle, vars_match_keys, 0, values, 2) < 0) {
|
|
|
+ LM_ERR("failed to delete database information\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
LM_DBG("callid was %.*s\n", cell->callid.len, cell->callid.s );
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
+int update_dialog_vars_dbinfo(struct dlg_cell * cell, struct dlg_var * var)
|
|
|
+{
|
|
|
+ db_val_t values[DIALOG_VARS_TABLE_COL_NO];
|
|
|
|
|
|
-int update_dialog_dbinfo(struct dlg_cell * cell)
|
|
|
+ db_key_t insert_keys[DIALOG_VARS_TABLE_COL_NO] = { &vars_h_entry_column,
|
|
|
+ &vars_h_id_column, &vars_key_column, &vars_value_column };
|
|
|
+
|
|
|
+ if(use_dialog_vars_table()!=0)
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ VAL_TYPE(values) = VAL_TYPE(values+1) = DB1_INT;
|
|
|
+ VAL_TYPE(values+2) = VAL_TYPE(values+3) = DB1_STR;
|
|
|
+ VAL_NULL(values) = VAL_NULL(values+1) = VAL_NULL(values+2) = VAL_NULL(values+3) = 0;
|
|
|
+ SET_STR_VALUE(values+2, var->key);
|
|
|
+
|
|
|
+ VAL_INT(values) = cell->h_entry;
|
|
|
+ VAL_INT(values+1) = cell->h_id;
|
|
|
+
|
|
|
+ if((var->vflags & DLG_FLAG_DEL) != 0) {
|
|
|
+ /* delete the current variable */
|
|
|
+ db_key_t vars_match_keys[3] = { &vars_h_entry_column, &vars_h_id_column, &vars_key_column};
|
|
|
+
|
|
|
+ if (use_dialog_vars_table()!=0)
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ if(dialog_dbf.delete(dialog_db_handle, vars_match_keys, 0, values, 3) < 0) {
|
|
|
+ LM_ERR("failed to delete database information\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ } else if((var->vflags & DLG_FLAG_NEW) != 0) {
|
|
|
+ /* save all the current dialogs information*/
|
|
|
+ SET_STR_VALUE(values+3, var->value);
|
|
|
+
|
|
|
+ if((dialog_dbf.insert(dialog_db_handle, insert_keys, values,
|
|
|
+ DIALOG_VARS_TABLE_COL_NO)) !=0){
|
|
|
+ LM_ERR("could not add another dialog-var to db\n");
|
|
|
+ goto error;
|
|
|
+ }
|
|
|
+ var->vflags &= ~(DLG_FLAG_NEW|DLG_FLAG_CHANGED);
|
|
|
+ } else if((var->vflags & DLG_FLAG_CHANGED) != 0) {
|
|
|
+ /* save only dialog's state and timeout */
|
|
|
+ SET_STR_VALUE(values+3, var->value);
|
|
|
+
|
|
|
+ if((dialog_dbf.update(dialog_db_handle, insert_keys, 0,
|
|
|
+ values, (insert_keys+3), (values+3), 3, 1)) !=0){
|
|
|
+ LM_ERR("could not update database info\n");
|
|
|
+ goto error;
|
|
|
+ }
|
|
|
+ var->vflags &= ~DLG_FLAG_CHANGED;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+error:
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+int update_dialog_dbinfo_unsafe(struct dlg_cell * cell)
|
|
|
{
|
|
|
int i;
|
|
|
- struct dlg_entry entry;
|
|
|
+ struct dlg_var *var;
|
|
|
+
|
|
|
db_val_t values[DIALOG_TABLE_COL_NO];
|
|
|
|
|
|
db_key_t insert_keys[DIALOG_TABLE_COL_NO] = { &h_entry_column,
|
|
@@ -463,6 +671,17 @@ int update_dialog_dbinfo(struct dlg_cell * cell)
|
|
|
&to_route_column, &from_contact_column,&to_contact_column,
|
|
|
&sflags_column, &toroute_name_column, &req_uri_column };
|
|
|
|
|
|
+ if( (cell->dflags & DLG_FLAG_NEW) != 0
|
|
|
+ || (cell->dflags & DLG_FLAG_CHANGED_VARS) != 0) {
|
|
|
+ /* iterate the list */
|
|
|
+ for(var=cell->vars ; var ; var=var->next) {
|
|
|
+ if (update_dialog_vars_dbinfo(cell, var) != 0)
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ /* Remove the flag */
|
|
|
+ cell->dflags &= ~DLG_FLAG_CHANGED_VARS;
|
|
|
+ }
|
|
|
+
|
|
|
if(use_dialog_table()!=0)
|
|
|
return -1;
|
|
|
|
|
@@ -481,10 +700,6 @@ int update_dialog_dbinfo(struct dlg_cell * cell)
|
|
|
VAL_TYPE(values+18) = DB1_INT;
|
|
|
VAL_TYPE(values+19) = DB1_STR;
|
|
|
|
|
|
- /* 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+9) = cell->start_ts;
|
|
@@ -540,10 +755,6 @@ int update_dialog_dbinfo(struct dlg_cell * cell)
|
|
|
|
|
|
VAL_TYPE(values+12) = VAL_TYPE(values+13) =DB1_STR;
|
|
|
|
|
|
- /* 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;
|
|
@@ -568,139 +779,43 @@ int update_dialog_dbinfo(struct dlg_cell * cell)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- dlg_unlock( d_table, &entry);
|
|
|
return 0;
|
|
|
-
|
|
|
error:
|
|
|
- dlg_unlock( d_table, &entry);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+int update_dialog_dbinfo(struct dlg_cell * cell)
|
|
|
+{
|
|
|
+ struct dlg_entry entry;
|
|
|
+ /* lock the entry */
|
|
|
+ entry = (d_table->entries)[cell->h_entry];
|
|
|
+ dlg_lock( d_table, &entry);
|
|
|
+ if (update_dialog_dbinfo_unsafe(cell) != 0) {
|
|
|
+ dlg_unlock( d_table, &entry);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ dlg_unlock( d_table, &entry);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
void dialog_update_db(unsigned int ticks, void * param)
|
|
|
{
|
|
|
- int index, i;
|
|
|
- db_val_t values[DIALOG_TABLE_COL_NO];
|
|
|
+ int index;
|
|
|
struct dlg_entry entry;
|
|
|
struct dlg_cell * cell;
|
|
|
-
|
|
|
- db_key_t insert_keys[DIALOG_TABLE_COL_NO] = { &h_entry_column,
|
|
|
- &h_id_column, &call_id_column, &from_uri_column,
|
|
|
- &from_tag_column, &to_uri_column, &to_tag_column,
|
|
|
- &from_sock_column, &to_sock_column,
|
|
|
- &start_time_column, &state_column, &timeout_column,
|
|
|
- &from_cseq_column, &to_cseq_column, &from_route_column,
|
|
|
- &to_route_column, &from_contact_column, &to_contact_column,
|
|
|
- &sflags_column, &toroute_name_column, &req_uri_column };
|
|
|
-
|
|
|
- if(use_dialog_table()!=0)
|
|
|
- return;
|
|
|
-
|
|
|
- /*save the current dialogs information*/
|
|
|
- VAL_TYPE(values) = VAL_TYPE(values+1) = VAL_TYPE(values+9) =
|
|
|
- VAL_TYPE(values+10) = VAL_TYPE(values+11) = DB1_INT;
|
|
|
-
|
|
|
- VAL_TYPE(values+2) = VAL_TYPE(values+3) = VAL_TYPE(values+4) =
|
|
|
- VAL_TYPE(values+5) = VAL_TYPE(values+6) = VAL_TYPE(values+7) =
|
|
|
- VAL_TYPE(values+8) = VAL_TYPE(values+12) = VAL_TYPE(values+13) =
|
|
|
- VAL_TYPE(values+14) = VAL_TYPE(values+15) = VAL_TYPE(values+16) =
|
|
|
- VAL_TYPE(values+17) = VAL_TYPE(values+20) = DB1_STR;
|
|
|
-
|
|
|
- SET_NULL_FLAG(values, i, DIALOG_TABLE_COL_NO-6, 0);
|
|
|
-
|
|
|
- VAL_TYPE(values+18) = DB1_INT;
|
|
|
- VAL_TYPE(values+19) = DB1_STR;
|
|
|
|
|
|
LM_DBG("saving current_info \n");
|
|
|
|
|
|
for(index = 0; index< d_table->size; index++){
|
|
|
-
|
|
|
/* lock the whole entry */
|
|
|
entry = (d_table->entries)[index];
|
|
|
dlg_lock( d_table, &entry);
|
|
|
|
|
|
for(cell = entry.first; cell != NULL; cell = cell->next){
|
|
|
-
|
|
|
- if( (cell->dflags & DLG_FLAG_NEW) != 0 ) {
|
|
|
-
|
|
|
- VAL_INT(values) = cell->h_entry;
|
|
|
- VAL_INT(values+1) = cell->h_id;
|
|
|
-
|
|
|
- VAL_INT(values+9) = cell->start_ts;
|
|
|
- VAL_INT(values+10) = cell->state;
|
|
|
- VAL_INT(values+11) = (unsigned int)( (unsigned int)time(0) +
|
|
|
- cell->tl.timeout - get_ticks() );
|
|
|
-
|
|
|
- SET_STR_VALUE(values+2, cell->callid);
|
|
|
- SET_STR_VALUE(values+3, cell->from_uri);
|
|
|
- SET_STR_VALUE(values+4, cell->tag[DLG_CALLER_LEG]);
|
|
|
- SET_STR_VALUE(values+5, cell->to_uri);
|
|
|
- SET_STR_VALUE(values+6, cell->tag[DLG_CALLEE_LEG]);
|
|
|
- SET_PROPER_NULL_FLAG(cell->tag[DLG_CALLEE_LEG], values, 6);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- SET_STR_VALUE(values+12, cell->cseq[DLG_CALLER_LEG]);
|
|
|
- SET_STR_VALUE(values+13, cell->cseq[DLG_CALLEE_LEG]);
|
|
|
-
|
|
|
- SET_STR_VALUE(values+14, cell->route_set[DLG_CALLER_LEG]);
|
|
|
- SET_STR_VALUE(values+15, cell->route_set[DLG_CALLEE_LEG]);
|
|
|
- SET_STR_VALUE(values+16, cell->contact[DLG_CALLER_LEG]);
|
|
|
- SET_STR_VALUE(values+17, cell->contact[DLG_CALLEE_LEG]);
|
|
|
-
|
|
|
- SET_PROPER_NULL_FLAG(cell->route_set[DLG_CALLER_LEG],
|
|
|
- values, 14);
|
|
|
- SET_PROPER_NULL_FLAG(cell->route_set[DLG_CALLEE_LEG],
|
|
|
- values, 15);
|
|
|
- SET_PROPER_NULL_FLAG(cell->contact[DLG_CALLER_LEG],
|
|
|
- values, 16);
|
|
|
- SET_PROPER_NULL_FLAG(cell->contact[DLG_CALLEE_LEG],
|
|
|
- values, 17);
|
|
|
-
|
|
|
- VAL_INT(values+18) = cell->sflags;
|
|
|
-
|
|
|
- SET_STR_VALUE(values+19, cell->toroute_name);
|
|
|
- SET_PROPER_NULL_FLAG(cell->toroute_name,
|
|
|
- values, 19);
|
|
|
-
|
|
|
- SET_STR_VALUE(values+20, cell->req_uri);
|
|
|
- SET_PROPER_NULL_FLAG(cell->req_uri,
|
|
|
- values, 20);
|
|
|
-
|
|
|
- if((dialog_dbf.insert(dialog_db_handle, insert_keys,
|
|
|
- values, DIALOG_TABLE_COL_NO)) !=0){
|
|
|
- LM_ERR("could not add another dialog to db\n");
|
|
|
- goto error;
|
|
|
- }
|
|
|
-
|
|
|
- cell->dflags &= ~(DLG_FLAG_NEW |DLG_FLAG_CHANGED);
|
|
|
-
|
|
|
- } else if( (cell->dflags & DLG_FLAG_CHANGED)!=0 ){
|
|
|
-
|
|
|
- VAL_INT(values) = cell->h_entry;
|
|
|
- VAL_INT(values+1) = cell->h_id;
|
|
|
-
|
|
|
- VAL_INT(values+10) = cell->state;
|
|
|
- VAL_INT(values+11) = (unsigned int)( (unsigned int)time(0) +
|
|
|
- cell->tl.timeout - get_ticks() );
|
|
|
- SET_STR_VALUE(values+12, cell->cseq[0]);
|
|
|
- SET_STR_VALUE(values+13, cell->cseq[DLG_CALLEE_LEG]);
|
|
|
-
|
|
|
-
|
|
|
- if((dialog_dbf.update(dialog_db_handle, (insert_keys), 0,
|
|
|
- (values), (insert_keys+10), (values+10), 2, 4)) !=0) {
|
|
|
- LM_ERR("could not update database info\n");
|
|
|
- goto error;
|
|
|
- }
|
|
|
-
|
|
|
- cell->dflags &= ~DLG_FLAG_CHANGED;
|
|
|
-
|
|
|
+ if (update_dialog_dbinfo_unsafe(cell) != 0) {
|
|
|
+ dlg_unlock( d_table, &entry);
|
|
|
+ goto error;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
dlg_unlock( d_table, &entry);
|
|
|
|