On 05/01/2013 06:05 AM, Stefan Hajnoczi wrote:

>> +    error_printf(
>> +           "%4d-%02d-%02d %02d:%02d:%02d.%03lld+0000 ",
>> +           fields.tm_year + 1900, fields.tm_mon + 1, fields.tm_mday,
>> +           fields.tm_hour, fields.tm_min, fields.tm_sec,
>> +           now % 1000);
> 
> Can strftime(3) be used instead of copying code from glibc?

No, because glibc's strftime() is not async-signal safe, and therefore
is not safe to call between fork() and exec() (libvirt hit actual
deadlocks[1] where a child was blocked on a mutex associated with
time-related functions that happened to be held by another parent
thread, but where the fork nuked that other thread so the mutex would
never clear).  This code is copied from libvirt, which copied the
no-lock-needed safe portions of glibc for a reason.

[1] https://www.redhat.com/archives/libvir-list/2011-November/msg01609.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to