Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Submitted By: Vasil Kolev (krokodilerian)
Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
Summary: Bug with timers and using get_ticks from a timer thread
There's a nasty issue with the timer code and for example tcp-related functions...
My case was that the timer thread was processing expired registrations and sending notifies for those. Turns out that for some of the registrations which were over TLS the connection was dropped and OpenSIPS tried to establish a new connection to the user, by calling tcpconn_connect_blocking(). That function relies on get_ticks() (e.g. jiffies) to see when it's timed out, but because those ticks are increased in the same thread that called it, it in fact had to wait the default system timeout for connect() (which is about 4 minutes, instead of the 10 seconds OpenSIPS is configured with).
The fix is a bit invasive, but seems like the right way to do it - the jiffies increase is moved in a separate thread and everyone uses that.