[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[help-serveez] Thread safety
From: |
Andreas Rottmann |
Subject: |
[help-serveez] Thread safety |
Date: |
06 Dec 2002 10:45:56 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Hi!
I'm using threads in my serveez-based application and now wonder about
the thread-safety of svz_log() (since it would be nice to be able to
use it from the additional threads, too). AFAICT, There are the
following issues:
a) Thread safety of the C stdio functions (FILE *). I'm not really
sure about this, but I guess they are not really thread-safe when used
on the same FILE *.
b) svz_log uses localtime, which is not thread-safe. However,
according to the libc info, there is localtime_r, defined by
POSIX.1c.
c) svz_log accesses svz_config (see a)) and svz_logfile, so they would
need to be locked.
Solutions would be IMO:
a) Simply lock access to svz_logfile. This can be done quite easily,
because svz_logfile is static.
b) Use localtime_r, if available.
c) This is a bit hairy. svz_config is *not* static. IMO, It would be
wise to make it static and use accessor functions. Then it could be
locked.
I'd be glad to provide a patch that makes svz_log thread-safe (or
mostly so ;-)), but before I want to hear comments on c), since making
svz_config static would result in API breakage.
Regards, Andy
--
Andreas Rottmann | address@hidden | address@hidden |
address@hidden
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62
- [help-serveez] Thread safety,
Andreas Rottmann <=
- Re: [help-serveez] Thread safety, stefan, 2002/12/06
- Re: [help-serveez] Thread safety, Andreas Rottmann, 2002/12/06
- Re: [help-serveez] Thread safety, stefan, 2002/12/08
- Re: [help-serveez] Thread safety, Andreas Rottmann, 2002/12/08
- Re: [help-serveez] Thread safety, stefan, 2002/12/10
- Re: [help-serveez] Thread safety, Andreas Rottmann, 2002/12/10
- Re: [help-serveez] Thread safety, stefan, 2002/12/10
- Re: [help-serveez] Thread safety, Andreas Rottmann, 2002/12/10
- Re: [help-serveez] Thread safety, stefan, 2002/12/11
- Re: [help-serveez] Thread safety, Raimund 'Raimi' Jacob, 2002/12/10