Skip to content

Commit

Permalink
dialog: fix possible hash id conflict on restart
Browse files Browse the repository at this point in the history
When restarting the proxy, the auto-generated next_id of each
hash entry is not properly incremented if a loaded dialog happens to
have this same next_id as hash id. This will soon lead to duplicate hash ids.

Reported by miko95 on GitHub.
  • Loading branch information
liviuchircu committed Aug 19, 2014
1 parent adddc5f commit b7c3686
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/dialog/dlg_db_handler.c
Expand Up @@ -585,7 +585,7 @@ static int load_dialog_info_from_db(int dlg_hash_size)
next_id = d_table->entries[dlg->h_entry].next_id;

d_table->entries[dlg->h_entry].next_id =
(next_id < dlg->h_id) ? (dlg->h_id+1) : next_id;
(next_id <= dlg->h_id) ? (dlg->h_id+1) : next_id;

GET_STR_VALUE(to_tag, values, 5, 1, 1);

Expand Down Expand Up @@ -1593,7 +1593,7 @@ static int sync_dlg_db_mem(void)
next_id = d_table->entries[dlg->h_entry].next_id;

d_table->entries[dlg->h_entry].next_id =
(next_id < dlg->h_id) ? (dlg->h_id+1) : next_id;
(next_id <= dlg->h_id) ? (dlg->h_id+1) : next_id;

dlg->start_ts = VAL_INT(values+6);

Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dlg_replication.c
Expand Up @@ -138,7 +138,7 @@ int dlg_replicated_create(struct dlg_cell *cell, str *ftag, str *ttag, int safe)
next_id = d_table->entries[dlg->h_entry].next_id;

d_table->entries[dlg->h_entry].next_id =
(next_id < dlg->h_id) ? (dlg->h_id + 1) : next_id;
(next_id <= dlg->h_id) ? (dlg->h_id + 1) : next_id;

if (bin_pop_str(&sock))
goto pre_linking_error;
Expand Down

0 comments on commit b7c3686

Please sign in to comment.