Skip to content

Commit

Permalink
htable: added parameter event_callback_mode
Browse files Browse the repository at this point in the history
- control when event_route[htable:init] is executed: 0 - after all
modules were initialized; 1 - in first worker process; (default 0)
- fixes use with kemi framework by using value 1, because after module
initialization the kemi framework is not ready, being set up per child
process
- reported by GH #1519
  • Loading branch information
miconda committed May 3, 2018
1 parent 6285b5e commit 1b8ab84
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/modules/htable/htable.c
Expand Up @@ -53,6 +53,7 @@ int ht_timer_interval = 20;
int ht_db_expires_flag = 0;
int ht_enable_dmq = 0;
int ht_timer_procs = 0;
static int ht_event_callback_mode = 0;

str ht_event_callback = STR_NULL;

Expand Down Expand Up @@ -131,20 +132,21 @@ static cmd_export_t cmds[]={
};

static param_export_t params[]={
{"htable", PARAM_STRING|USE_FUNC_PARAM, (void*)ht_param},
{"db_url", PARAM_STR, &ht_db_url},
{"key_name_column", PARAM_STR, &ht_db_name_column},
{"key_type_column", PARAM_STR, &ht_db_ktype_column},
{"value_type_column", PARAM_STR, &ht_db_vtype_column},
{"key_value_column", PARAM_STR, &ht_db_value_column},
{"expires_column", PARAM_STR, &ht_db_expires_column},
{"array_size_suffix", PARAM_STR, &ht_array_size_suffix},
{"fetch_rows", INT_PARAM, &ht_fetch_rows},
{"timer_interval", INT_PARAM, &ht_timer_interval},
{"db_expires", INT_PARAM, &ht_db_expires_flag},
{"enable_dmq", INT_PARAM, &ht_enable_dmq},
{"timer_procs", PARAM_INT, &ht_timer_procs},
{"event_callback", PARAM_STR, &ht_event_callback},
{"htable", PARAM_STRING|USE_FUNC_PARAM, (void*)ht_param},
{"db_url", PARAM_STR, &ht_db_url},
{"key_name_column", PARAM_STR, &ht_db_name_column},
{"key_type_column", PARAM_STR, &ht_db_ktype_column},
{"value_type_column", PARAM_STR, &ht_db_vtype_column},
{"key_value_column", PARAM_STR, &ht_db_value_column},
{"expires_column", PARAM_STR, &ht_db_expires_column},
{"array_size_suffix", PARAM_STR, &ht_array_size_suffix},
{"fetch_rows", INT_PARAM, &ht_fetch_rows},
{"timer_interval", INT_PARAM, &ht_timer_interval},
{"db_expires", INT_PARAM, &ht_db_expires_flag},
{"enable_dmq", INT_PARAM, &ht_enable_dmq},
{"timer_procs", PARAM_INT, &ht_timer_procs},
{"event_callback", PARAM_STR, &ht_event_callback},
{"event_callback_mode", PARAM_STR, &ht_event_callback_mode},
{0,0,0}
};

Expand Down Expand Up @@ -219,7 +221,9 @@ static int mod_init(void)
return 0;
}


/**
*
*/
static int child_init(int rank)
{
struct sip_msg *fmsg;
Expand All @@ -243,9 +247,11 @@ static int child_init(int rank)
}
}

if (rank!=PROC_INIT)
if (ht_event_callback_mode==0 && rank!=PROC_INIT)
return 0;

if (ht_event_callback_mode==1 && rank!=PROC_SIPINIT)
return 0;

rt = -1;
if(ht_event_callback.s==NULL || ht_event_callback.len<=0) {
Expand Down

0 comments on commit 1b8ab84

Please sign in to comment.