There is already a mutex. f_localtime does not release the interpreter lock. Of course, it could still interfere with other threads running non-pike code, but that would not be fixed by adding another mutex.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-06-17 19:25: Subject: Pike localtime(), threads safe and low level localtime() / localtime_r() ?
Hi there,
According to FreeBSD / Darwin / Linux man page, the low level function localtime() is not thread safe and we should use locatime_r() instead to avoid that.
But the pike function localtime() use the low level localtime()
---/ from builtin_functions.c generated file - pike 7.4 /---
[...]
PMOD_EXPORT void f_localtime(INT32 args) { struct tm *tm; INT_TYPE tt; time_t t;
get_all_args("localtime", args, "%i", &tt);
t = tt; tm = localtime(&t); if (!tm) Pike_error ("localtime() on this system cannot handle " "the timestamp %ld.\n", (long) t); pop_n_elems(args); encode_struct_tm(tm);
[...]
---//--
Do you think it should be mutch better to
- either use localtime_r() if OS support it and provide it
- add a mutex or something to avoid threading problems.
Thanks,
/Xavier
/ Brevbäraren