Mercury109 created an issue (kamailio/kamailio#4169)
### Description
I loop through the active dialogs in a timer functions and based on some conditions, a dialog may be ended by setting a short timeout or using the dlg_bye function. **Sometimes** when a dialog times out or the dlg_bye("all") function is used, the BYE is not being sent in both directions, only towards the caller.
There's a warning:
send_bye(): dlg [25641:71143] with callid XXXXXXXXX already in deleted state, BYE not sent.
I noticed this check was added in the commit below:
https://github.com/kamailio/kamailio/commit/d411c6ea4358e6d9dd367349e877ed5f...
Is there a race condition between marking the dialog as terminated and sending the BYE?
Not sending a BYE towards the callee when it should is much worse than sending an unnecessary BYE as it causes billing issues. If this can't be resolved to be 100% reliable, it's safer to remove this check all together.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.7.6 (x86_64/linux)) ```
* **Operating System**:
Debian GNU/Linux 12 (bookworm)