On Monday, June 8, 2015, Taylor R Campbell <
address@hidden> wrote:
The log file is specific to the particular web server instance, so the lock
that controls the log file belongs in the web server data structure.
Having two locks opens the possibility of ordering problems. Having just
one eliminates that issue.
Only if your logging routines need to get at the rest of the web
server data structures. If your logging routines are self-contained,
the lock ordering issue is trivial and needn't even be mentioned --
you could factor logging out into another library, like C stdio.
Still, when logging is used in the web server, the lock needs to reside somewhere. It shouldn't have to be passed around separately from the web server, so I just incorporated it into the web server.
(C stdio streams have locks too -- but you don't usually notice, even
if you call printf while you hold some pthread_mutex, because you
~never have to write code that runs with the stdio stream locked.)
Interesting.
I'm not sure what interactions might happen at the Scheme level, though.