Skip to content

Commit

Permalink
Merge pull request #304 from jaybinks/JB-db_skip_load3
Browse files Browse the repository at this point in the history
dialog: implement db_skip_load to skip loading dialogs on startup
  • Loading branch information
miconda committed Aug 26, 2015
2 parents 546e624 + 9eb6ab9 commit 94f7683
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
4 changes: 3 additions & 1 deletion modules/dialog/dialog.c
Expand Up @@ -99,6 +99,7 @@ static char* profiles_wv_s = NULL;
static char* profiles_nv_s = NULL;
str dlg_extra_hdrs = {NULL,0};
static int db_fetch_rows = 200;
static int db_skip_load = 0;
int initial_cbs_inscript = 1;
int dlg_wait_ack = 1;
static int dlg_timer_procs = 0;
Expand Down Expand Up @@ -291,6 +292,7 @@ static param_export_t mod_params[]={
{ "timer_procs", PARAM_INT, &dlg_timer_procs },
{ "track_cseq_updates", PARAM_INT, &_dlg_track_cseq_updates },
{ "lreq_callee_headers", PARAM_STR, &dlg_lreq_callee_headers },
{ "db_skip_load", INT_PARAM, &db_skip_load },
{ 0,0,0 }
};

Expand Down Expand Up @@ -687,7 +689,7 @@ static int mod_init(void)
LM_ERR("db_url not configured for db_mode %d\n", dlg_db_mode);
return -1;
}
if (init_dlg_db(&db_url, dlg_hash_size, db_update_period,db_fetch_rows)!=0) {
if (init_dlg_db(&db_url, dlg_hash_size, db_update_period, db_fetch_rows, db_skip_load)!=0) {
LM_ERR("failed to initialize the DB support\n");
return -1;
}
Expand Down
19 changes: 10 additions & 9 deletions modules/dialog/dlg_db_handler.c
Expand Up @@ -135,7 +135,7 @@ 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)
int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int fetch_num_rows, int db_skip_load)
{
/* Find a database module */
if (db_bind_mod(db_url, &dialog_dbf) < 0){
Expand Down Expand Up @@ -164,15 +164,16 @@ int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int
return -1;
}

if( (load_dialog_info_from_db(dlg_hash_size, fetch_num_rows) ) !=0 ){
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;
if ( db_skip_load == 0 ) {
if( (load_dialog_info_from_db(dlg_hash_size, fetch_num_rows) ) !=0 ){
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;

Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dlg_db_handler.h
Expand Up @@ -112,7 +112,7 @@ extern str vars_value_column;
extern str dialog_vars_table_name;


int init_dlg_db(const str *db_url, int dlg_hash_size, int db_update_period, int fetch_num_rows);
int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int fetch_num_rows, int db_skip_load);
int dlg_connect_db(const str *db_url);
void destroy_dlg_db(void);

Expand Down
24 changes: 23 additions & 1 deletion modules/dialog/doc/dialog_admin.xml
Expand Up @@ -472,7 +472,7 @@ modparam("dialog", "db_update_period", 120)
<para>
The number of the rows to be fetched at once from database when loading the dialog records at startup from the database.
This value can be used to tune the load time at startup. For 1MB of private memory (default), it should be below 400.
The database driver must support the fetch_result() capability. A value of 0 means the functionality is disabled.
The database driver must support the fetch_result() capability. A value of 0 means the database fetch is not limited.
</para>
<para>
<emphasis>
Expand All @@ -489,6 +489,28 @@ modparam("dialog", "db_fetch_rows", 500)
</example>
</section>

<section>
<title><varname>db_skip_load</varname> (integer)</title>
<para>
Set db_skip_load to 1, to skip the loading of dialogs from the database alltogether.
</para>
<para>
<emphasis>
Default value is <quote>0</quote> ( not skipped ).
</emphasis>
</para>
<example>
<title>Set <varname>db_skip_load</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("dialog", "db_skip_load", 1)
...
</programlisting>
</example>
</section>



<section>
<title><varname>table_name</varname> (string)</title>
<para>
Expand Down

0 comments on commit 94f7683

Please sign in to comment.