Skip to content

Commit

Permalink
[Dispatcher] Fixed three memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-datcu committed Jul 3, 2014
1 parent c5c97af commit 45353a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions modules/dispatcher/dispatch.c
Expand Up @@ -76,6 +76,7 @@ extern ds_partition_t *partitions;

extern struct socket_info *probing_sock;
extern event_id_t dispatch_evi_id;
extern ds_partition_t *default_partition;

extern int ds_force_dst;

Expand Down Expand Up @@ -607,7 +608,7 @@ void ds_flusher_routine(unsigned int ticks, void* param)
&partition->table_name) < 0) {
LM_ERR("cannot select table \"%.*s\"\n",
partition->table_name.len, partition->table_name.s);
return;
continue;
}
key_cmp = &ds_dest_uri_col;
key_set = &ds_dest_state_col;
Expand Down Expand Up @@ -784,6 +785,7 @@ static ds_data_t* ds_load_data(ds_partition_t *partition)

error:
ds_destroy_data_set( d_data );
return NULL;
error2:
partition->dbf.free_result(*partition->db_handle, res);
return NULL;
Expand Down Expand Up @@ -1738,7 +1740,8 @@ int ds_set_state(int group, str *address, int state, int type,
lock_stop_read( partition->lock );
return 0;
}
if (evi_param_add_str(list, &partition_str, &partition->name)){
if (partition != default_partition
&& evi_param_add_str(list, &partition_str, &partition->name)){
LM_ERR("unable to add partition parameter\n");
evi_free_params(list);
lock_stop_read( partition->lock );
Expand Down
8 changes: 5 additions & 3 deletions modules/dispatcher/dispatcher.c
Expand Up @@ -321,7 +321,7 @@ static int split_partition_argument(str *arg, str *partition_name)
return 0;
} else if (delim_pos - arg->s + 1 == arg->len){

LM_WARN("possibly empty parameter %.*s", arg->len, arg->s);
LM_WARN("possibly empty parameter %.*s\n", arg->len, arg->s);
return 0;
} else {

Expand Down Expand Up @@ -747,7 +747,8 @@ static int mod_init(void)
default_partition = partition;

head_it = head_it->next;
pkg_free(aux);
if (aux != &default_db_head)
pkg_free(aux);
}

/* Only, if the Probing-Timer is enabled the TM-API needs to be loaded: */
Expand Down Expand Up @@ -875,6 +876,7 @@ static void destroy(void)
aux = part_it;
part_it = part_it->next;

ds_disconnect_db(aux);
pkg_free(aux->db_handle);
shm_free(aux);
}
Expand Down Expand Up @@ -1497,7 +1499,7 @@ static int w_ds_count(struct sip_msg* msg, char *set, const char *cmp, char *res
str s_set;

if (partition_arg_from_gparam(msg, (gparam_p)set, &partition, &s_set) != 0
|| str2int(&s_set, &s) != 0) {
|| str2int(&s_set, &s) != 0 || s_set.len == 0) {
LM_ERR("wrong format for set argument\n");
return -1;
}
Expand Down
9 changes: 4 additions & 5 deletions modules/dispatcher/ds_bl.c
Expand Up @@ -131,11 +131,6 @@ int init_ds_bls(void)
dsbl->no_sets++;
} while(p != NULL);

pkg_free(bs_it->text);
aux = bs_it;
bs_it = bs_it->next;
pkg_free(aux);

/* create backlist for it */
dsbl->bl = create_bl_head( 313131, 0/*flags*/, NULL, NULL, &name);
if (dsbl->bl == NULL) {
Expand All @@ -144,6 +139,10 @@ int init_ds_bls(void)
return -1;
}

aux = bs_it;
bs_it = bs_it->next;
pkg_free(aux);

/* link it */
dsbl->next = dsbl_lists;
dsbl_lists = dsbl;
Expand Down

0 comments on commit 45353a5

Please sign in to comment.