Skip to content

Commit

Permalink
presence: pass db_func through pointer, rather than value
Browse files Browse the repository at this point in the history
This prevents from passing big structures on the stack

Fixes coverity CID 150488
  • Loading branch information
razvancrainea committed Oct 24, 2016
1 parent d4a2d8a commit beea93f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions modules/presence/subscribe.c
Expand Up @@ -1312,12 +1312,12 @@ void timer_db_update(unsigned int ticks,void *param)
return;
}

update_db_subs(pa_db, pa_dbf, subs_htable,
update_db_subs(pa_db, &pa_dbf, subs_htable,
shtable_size, no_lock, handle_expired_subs);

}

void update_db_subs(db_con_t *db,db_func_t dbf, shtable_t hash_table,
void update_db_subs(db_con_t *db,db_func_t *dbf, shtable_t hash_table,
int htable_size, int no_lock, handle_expired_func_t handle_expired_func)
{
static db_ps_t my_ps_delete = NULL;
Expand Down Expand Up @@ -1539,7 +1539,7 @@ void update_db_subs(db_con_t *db,db_func_t dbf, shtable_t hash_table,
update_vals[u_contact_col].val.str_val= s->contact;

CON_PS_REFERENCE(db) = &my_ps_update;
if(dbf.update(db, query_cols, 0, query_vals, update_cols,
if(dbf->update(db, query_cols, 0, query_vals, update_cols,
update_vals, n_query_update, n_update_cols)< 0)
{
LM_ERR("updating in database\n");
Expand Down Expand Up @@ -1581,7 +1581,7 @@ void update_db_subs(db_con_t *db,db_func_t dbf, shtable_t hash_table,
}

CON_PS_REFERENCE(db) = &my_ps_insert;
if(dbf.insert(db,query_cols,query_vals,n_query_cols )<0)
if(dbf->insert(db,query_cols,query_vals,n_query_cols )<0)
{
LM_ERR("unsuccessful sql insert\n");
if(!no_lock)
Expand All @@ -1606,10 +1606,10 @@ void update_db_subs(db_con_t *db,db_func_t dbf, shtable_t hash_table,
update_vals[0].val.int_val = (int)time(NULL);
update_ops[0] = OP_LT;
CON_PS_REFERENCE(db) = &my_ps_delete;
if (dbf.use_table(db, &active_watchers_table) < 0) {
if (dbf->use_table(db, &active_watchers_table) < 0) {
LM_ERR("deleting expired information from database\n");
} else {
if (dbf.delete(db, update_cols, update_ops, update_vals, 1) < 0)
if (dbf->delete(db, update_cols, update_ops, update_vals, 1) < 0)
LM_ERR("deleting expired information from database\n");
}

Expand Down
4 changes: 2 additions & 2 deletions modules/presence/subscribe.h
Expand Up @@ -92,10 +92,10 @@ int restore_db_subs(void);

typedef int (*handle_expired_func_t)(subs_t* );

void update_db_subs(db_con_t *db,db_func_t dbf, shtable_t hash_table,
void update_db_subs(db_con_t *db,db_func_t *dbf, shtable_t hash_table,
int htable_size, int no_lock, handle_expired_func_t handle_expired_func);

typedef void (*update_db_subs_t)(db_con_t * ,db_func_t ,shtable_t ,int ,int ,
typedef void (*update_db_subs_t)(db_con_t * ,db_func_t *,shtable_t ,int ,int ,
handle_expired_func_t);

int extract_sdialog_info(subs_t* subs,struct sip_msg* msg, int max_expire,
Expand Down
2 changes: 1 addition & 1 deletion modules/rls/rls.c
Expand Up @@ -600,7 +600,7 @@ void rlsubs_table_update(unsigned int ticks,void *param)
LM_ERR("sql use table failed\n");
return;
}
pres_update_db_subs(rls_db, rls_dbf, rls_table, hash_size,
pres_update_db_subs(rls_db, &rls_dbf, rls_table, hash_size,
no_lock, handle_expired_record);

}
Expand Down

0 comments on commit beea93f

Please sign in to comment.