Ticket #654 (closed task: fixed)
Make debug_* functions threadsafe
|Reported by:||Philip||Owned by:|
|Priority:||Should Have||Milestone:||Alpha 3|
The network server code needs to run in a background thread (to minimise latency when forwarding messages between clients), and it involves lots of code that can encounter errors. That code uses debug_assert, debug_warn, DEBUG_WARN_ERR, debug_printf, for error handling.
Avoiding those functions would be difficult and painful. It would be much better if they worked safely when run from a background thread.
Currently they use global variables, create dialog boxes, write files, etc, which is probably all unsafe with multiple threads.
It may be sufficient for them to do something more minimal than on the main thread (e.g. skip the dialog boxes and crashlogs, and just dump the message to stderr or whatever) - we don't use threads much so it doesn't need to be as user-/developer-friendly as for the bulk of the code. It mainly should just avoid potentially triggering crashes and deadlocks that mask the errors we're trying to report.