diff --git a/modules/dialog/dlg_replication.c b/modules/dialog/dlg_replication.c index 919dc8534ad..0438ab377f6 100644 --- a/modules/dialog/dlg_replication.c +++ b/modules/dialog/dlg_replication.c @@ -1114,13 +1114,15 @@ void rcv_cluster_event(enum clusterer_event ev, int node_id) /* successfully removed from timer list */ unref++; - if (dlg_db_mode != DB_MODE_SHUTDOWN) { + if (dlg_db_mode != DB_MODE_SHUTDOWN && + !(dlg->flags&DLG_FLAG_DB_DELETED)) { dlg->flags &= ~DLG_FLAG_NEW; remove_dialog_from_db(dlg); dlg->flags |= DLG_FLAG_DB_DELETED; } - if (dlg_db_mode == DB_MODE_DELAYED) + if (dlg_db_mode == DB_MODE_DELAYED && + !(dlg->flags&DLG_FLAG_DB_DELETED)) unref++; if (old_state != DLG_STATE_DELETED)