Arran Cudbard-Bell wrote:
See this is why I wasn't quite sure why you did this on a per module basis.
It's simple, it works, and it's a step ahead. Only weird people (cough STEFAN) have multiple modules logging to the same file.
My suggestion would be to use a global hash of filenames -> FDs, which is shared between all things that write to log files on the server.
The existing code works. It's easy to make a global log context, just make a global variable, and have the modules use it.
My other suggestion to use multiple FDs would also work alleviate some of the contention.
I don't see how that helps... you still have contention when multiple modules are writing to the same file. You've just moved it from one place to another.
You can just use one mutex, but two would probably be better. You really want to limit the critical region for the one global mutex, and locking another mutex is probably quicker than doing a bunch of system calls.
Yes. The log file code tries hard to minimize contention. Alan DeKok.