One way to make this work correctly would be to remove the logmask as a global variable and, instead, put the logic mask in the group structure or in the TCB structure. That would make logmask thread safe (in the second case).  This would be the preferred solution. This solution would work.  The other suggestions will not work and just implement more complex version of the broken code.
Actually, putting the logmask in TLS (with the errno) would be better solution.  In some configurations, at least, that would avoid a system call.

I could implement that in about an hour if you agree.  I think a per-thread log mask is better than a broken shared logmask.  The logmask cannot be shared between threads.  It is impossible to make that work correctly.

The only options are:

- Remove the critical section and don't worry about it,  It is broken in the multi-threaded concurrent access (but your proposals do not fix that).

- Implement a thread-specific, or group-specific logmask.

Let me know.



Reply via email to