Opened 14 years ago

Closed 14 years ago

#654 closed task (fixed)

Make debug_* functions threadsafe

Reported by: Philip Taylor Owned by:
Priority: Should Have Milestone: Alpha 3
Component: Core engine Keywords:
Cc: Jan Wassenberg Patch:

Description

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.

Change History (1)

comment:1 by Jan Wassenberg, 14 years ago

Resolution: fixed
Status: newclosed

(In [8543]) thread-safety fixes to debug.cpp - most functions were already reentrant, just CAS-ified the assert suppression flags. (NB: the debug_filter stuff remains non-reentrant because it's usually only called from main() or at least the main thread) closes #654

Note: See TracTickets for help on using tickets.