#include <stdlib.h>#include <string.h>#include <sys/time.h>#include "../../dprint.h"#include "../../ut.h"#include "../../timer.h"#include "../../db/db.h"#include "../../str.h"#include "../../socket_info.h"#include "dlg_hash.h"#include "dlg_db_handler.h"

Go to the source code of this file.
Defines | |
| #define | GET_STR_VALUE(_res, _values, _index, _not_null, _unref) |
| #define | SET_NULL_FLAG(_vals, _i, _max, _flag) |
| #define | SET_PROPER_NULL_FLAG(_str, _vals, _index) |
| #define | SET_STR_VALUE(_val, _str) |
Functions | |
| struct socket_info * | create_socket_info (db_val_t *vals, int n) |
| void | destroy_dlg_db (void) |
| void | dialog_update_db (unsigned int ticks, void *param) |
| int | dlg_connect_db (const str *db_url) |
| int | init_dlg_db (const str *db_url, int dlg_hash_size, int db_update_period, int fetch_num_rows) |
| static int | load_dialog_info_from_db (int dlg_hash_size, int fetch_num_rows) |
| int | remove_dialog_from_db (struct dlg_cell *cell) |
| static int | select_entire_dialog_table (db_res_t **res, int fetch_num_rows) |
| int | update_dialog_dbinfo (struct dlg_cell *cell) |
| static int | use_dialog_table (void) |
Variables | |
| int | active_dlgs_cnt |
| str | call_id_column = str_init(CALL_ID_COL) |
| static db_con_t * | dialog_db_handle = 0 |
| static db_func_t | dialog_dbf |
| str | dialog_table_name = str_init(DIALOG_TABLE_NAME) |
| int | dlg_db_mode = DB_MODE_NONE |
| int | dlg_enable_stats |
| int | early_dlgs_cnt |
| str | from_contact_column = str_init(FROM_CONTACT_COL) |
| str | from_cseq_column = str_init(FROM_CSEQ_COL) |
| str | from_route_column = str_init(FROM_ROUTE_COL) |
| str | from_sock_column = str_init(FROM_SOCK_COL) |
| str | from_tag_column = str_init(FROM_TAG_COL) |
| str | from_uri_column = str_init(FROM_URI_COL) |
| str | h_entry_column = str_init(HASH_ENTRY_COL) |
| str | h_id_column = str_init(HASH_ID_COL) |
| str | sflags_column = str_init(SFLAGS_COL) |
| str | start_time_column = str_init(START_TIME_COL) |
| str | state_column = str_init(STATE_COL) |
| str | timeout_column = str_init(TIMEOUT_COL) |
| str | to_contact_column = str_init(TO_CONTACT_COL) |
| str | to_cseq_column = str_init(TO_CSEQ_COL) |
| str | to_route_column = str_init(TO_ROUTE_COL) |
| str | to_sock_column = str_init(TO_SOCK_COL) |
| str | to_tag_column = str_init(TO_TAG_COL) |
| str | to_uri_column = str_init(TO_URI_COL) |
| str | toroute_column = str_init(TOROUTE_COL) |
| #define GET_STR_VALUE | ( | _res, | |||
| _values, | |||||
| _index, | |||||
| _not_null, | |||||
| _unref | ) |
Definition at line 93 of file dlg_db_handler.c.
Referenced by build_rule(), and load_dialog_info_from_db().
| #define SET_NULL_FLAG | ( | _vals, | |||
| _i, | |||||
| _max, | |||||
| _flag | ) |
Value:
do{\ for((_i) = 0;(_i)<(_max); (_i)++)\ VAL_NULL((_vals)+(_i)) = (_flag);\ }while(0);
Definition at line 79 of file dlg_db_handler.c.
Referenced by dialog_update_db(), and update_dialog_dbinfo().
| #define SET_PROPER_NULL_FLAG | ( | _str, | |||
| _vals, | |||||
| _index | ) |
Definition at line 85 of file dlg_db_handler.c.
Referenced by dialog_update_db(), and update_dialog_dbinfo().
| #define SET_STR_VALUE | ( | _val, | |||
| _str | ) |
Value:
Definition at line 73 of file dlg_db_handler.c.
Referenced by dialog_update_db(), and update_dialog_dbinfo().
| struct socket_info* create_socket_info | ( | db_val_t * | vals, | |
| int | n | |||
| ) | [read] |
Definition at line 229 of file dlg_db_handler.c.
References grep_sock_info(), _str::len, LM_ERR, LM_WARN, parse_phostport(), port, socket_info::proto, s, _str::s, sock, VAL_NULL, and VAL_STR.
Referenced by load_dialog_info_from_db().
| void destroy_dlg_db | ( | void | ) |
Definition at line 162 of file dlg_db_handler.c.
References db_func::close.
Referenced by mod_destroy().
| void dialog_update_db | ( | unsigned int | ticks, | |
| void * | param | |||
| ) |
Definition at line 567 of file dlg_db_handler.c.
References dlg_cell::bind_addr, dlg_cell::callid, dlg_cell::contact, dlg_cell::cseq, d_table, DB_INT, DB_STR, dlg_cell::dflags, DIALOG_TABLE_COL_NO, DLG_CALLEE_LEG, DLG_CALLER_LEG, DLG_FLAG_CHANGED, DLG_FLAG_NEW, dlg_lock, dlg_unlock, dlg_table::entries, dlg_entry::first, dlg_cell::from_uri, get_ticks(), dlg_cell::h_entry, dlg_cell::h_id, db_func::insert, LM_DBG, LM_ERR, dlg_cell::next, NULL, dlg_cell::route_set, SET_NULL_FLAG, SET_PROPER_NULL_FLAG, SET_STR_VALUE, dlg_cell::sflags, dlg_table::size, socket_info::sock_str, dlg_cell::start_ts, dlg_cell::state, dlg_cell::tag, dlg_tl::timeout, dlg_cell::tl, dlg_cell::to_uri, dlg_cell::toroute, db_func::update, use_dialog_table(), VAL_INT, and VAL_TYPE.
Referenced by init_dlg_db(), and mod_destroy().
| int dlg_connect_db | ( | const str * | db_url | ) |
Definition at line 113 of file dlg_db_handler.c.
References db_func::init, and LM_CRIT.
Referenced by child_init(), and init_dlg_db().
| int init_dlg_db | ( | const str * | db_url, | |
| int | dlg_hash_size, | |||
| int | db_update_period, | |||
| int | fetch_num_rows | |||
| ) |
Definition at line 125 of file dlg_db_handler.c.
References db_func::close, db_bind_mod(), db_check_table_version(), DB_MODE_DELAYED, dialog_update_db(), dlg_connect_db(), dlg_db_mode, DLG_TABLE_VERSION, LM_ERR, load_dialog_info_from_db(), and register_timer().
Referenced by mod_init().
| static int load_dialog_info_from_db | ( | int | dlg_hash_size, | |
| int | fetch_num_rows | |||
| ) | [static] |
Definition at line 258 of file dlg_db_handler.c.
References active_dlgs_cnt, dlg_cell::bind_addr, build_new_dlg(), dlg_cell::callid, create_socket_info(), d_table, DB_CAP_FETCH, DB_CAPABILITY, dlg_cell::dflags, DLG_CALLEE_LEG, DLG_CALLER_LEG, dlg_set_leg_info(), DLG_STATE_CONFIRMED, DLG_STATE_CONFIRMED_NA, DLG_STATE_EARLY, early_dlgs_cnt, dlg_table::entries, db_func::fetch_result, db_func::free_result, from_tag, dlg_cell::from_uri, GET_STR_VALUE, get_ticks(), dlg_cell::h_entry, dlg_cell::h_id, insert_dlg_timer(), _str::len, dlg_cell::lifetime, link_dlg(), LM_CRIT, LM_DBG, LM_ERR, dlg_entry::next_id, ref_dlg(), RES_ROW_N, RES_ROWS, ROW_VALUES, _str::s, select_entire_dialog_table(), shm_free, dlg_cell::start_ts, dlg_cell::state, dlg_cell::tag, dlg_tl::timeout, dlg_cell::tl, dlg_cell::to_uri, unref_dlg(), VAL_INT, and VAL_NULL.
Referenced by init_dlg_db().
| int remove_dialog_from_db | ( | struct dlg_cell * | cell | ) |
Definition at line 412 of file dlg_db_handler.c.
References dlg_cell::callid, DB_INT, db_func::delete, dlg_cell::dflags, DLG_FLAG_NEW, dlg_cell::h_entry, dlg_cell::h_id, _str::len, LM_DBG, LM_ERR, _str::s, use_dialog_table(), VAL_INT, VAL_NULL, and VAL_TYPE.
Referenced by bye_reply_cb(), dlg_onroute(), and dlg_ontimeout().
| static int select_entire_dialog_table | ( | db_res_t ** | res, | |
| int | fetch_num_rows | |||
| ) | [static] |
Definition at line 190 of file dlg_db_handler.c.
References DB_CAP_FETCH, DB_CAPABILITY, DIALOG_TABLE_COL_NO, db_func::fetch_result, LM_ERR, db_func::query, and use_dialog_table().
Referenced by load_dialog_info_from_db().
| int update_dialog_dbinfo | ( | struct dlg_cell * | cell | ) |
Definition at line 443 of file dlg_db_handler.c.
References dlg_cell::bind_addr, dlg_cell::callid, dlg_cell::contact, dlg_cell::cseq, d_table, DB_INT, DB_STR, dlg_cell::dflags, DIALOG_TABLE_COL_NO, DLG_CALLEE_LEG, DLG_CALLER_LEG, DLG_FLAG_CHANGED, DLG_FLAG_NEW, dlg_lock, dlg_unlock, dlg_table::entries, dlg_cell::from_uri, get_ticks(), dlg_cell::h_entry, dlg_cell::h_id, db_func::insert, _str::len, LM_DBG, LM_ERR, dlg_cell::route_set, _str::s, SET_NULL_FLAG, SET_PROPER_NULL_FLAG, SET_STR_VALUE, dlg_cell::sflags, socket_info::sock_str, dlg_cell::start_ts, dlg_cell::state, dlg_cell::tag, dlg_tl::timeout, dlg_cell::tl, dlg_cell::to_uri, dlg_cell::toroute, db_func::update, use_dialog_table(), VAL_INT, VAL_NULL, and VAL_TYPE.
Referenced by dlg_onreply(), and dlg_onroute().
| static int use_dialog_table | ( | void | ) | [static] |
Definition at line 173 of file dlg_db_handler.c.
References LM_ERR, and db_func::use_table.
Referenced by dialog_update_db(), remove_dialog_from_db(), select_entire_dialog_table(), and update_dialog_dbinfo().
| int active_dlgs_cnt |
| str call_id_column = str_init(CALL_ID_COL) |
db_con_t* dialog_db_handle = 0 [static] |
Definition at line 66 of file dlg_db_handler.c.
db_func_t dialog_dbf [static] |
Definition at line 67 of file dlg_db_handler.c.
| str dialog_table_name = str_init(DIALOG_TABLE_NAME) |
| int dlg_db_mode = DB_MODE_NONE |
Definition at line 64 of file dlg_db_handler.c.
Referenced by bye_reply_cb(), child_init(), dlg_onreply(), dlg_onroute(), dlg_ontimeout(), init_dlg_db(), mod_destroy(), and mod_init().
| int dlg_enable_stats |
| int early_dlgs_cnt |
| str from_contact_column = str_init(FROM_CONTACT_COL) |
| str from_cseq_column = str_init(FROM_CSEQ_COL) |
| str from_route_column = str_init(FROM_ROUTE_COL) |
| str from_sock_column = str_init(FROM_SOCK_COL) |
| str from_tag_column = str_init(FROM_TAG_COL) |
| str from_uri_column = str_init(FROM_URI_COL) |
| str h_entry_column = str_init(HASH_ENTRY_COL) |
| str h_id_column = str_init(HASH_ID_COL) |
| str sflags_column = str_init(SFLAGS_COL) |
| str start_time_column = str_init(START_TIME_COL) |
| str state_column = str_init(STATE_COL) |
| str timeout_column = str_init(TIMEOUT_COL) |
| str to_contact_column = str_init(TO_CONTACT_COL) |
| str to_cseq_column = str_init(TO_CSEQ_COL) |
| str to_route_column = str_init(TO_ROUTE_COL) |
| str to_sock_column = str_init(TO_SOCK_COL) |
| str to_tag_column = str_init(TO_TAG_COL) |
| str to_uri_column = str_init(TO_URI_COL) |
| str toroute_column = str_init(TOROUTE_COL) |
1.5.6