Open GoogleCodeExporter opened 9 years ago
[deleted comment]
I should add that the patch I gave only supports forks in processes that are
single-threaded. The problem in a multi-threaded process is that one thread in
that process might be executing in the glog library while holding some locks
and another thread calls a 'fork'. In the child, only the thread that called
'fork' would be created - the remaining threads won't be - so there would be
some locks that would never get unlocked by anyone. So there's potential for
deadlock.
Here's a potential solution for supporting forks from multi-threaded
applications:
All calls into glog would go through a reader-writers lock that would be
acquired normally for read access. glog library would call pthread_atfork()
that would provide all three handlers - 'prepare', 'parent', and 'child' (see
http://linux.die.net/man/3/pthread_atfork). The 'prepare' handler would acquire
the readers-writers lock with write access - this would ensure that no other
application threads are executing within the glog library. Both the 'parent'
and 'child' handlers would then release this lock. The child handler in
addition to would delete the LogDestination objects as it is already being done
by the patch I provided.
Original comment by mohit.a...@gmail.com
on 16 Jun 2012 at 6:59
Uploading patch with some minor fixes ...
Original comment by mohit.a...@gmail.com
on 16 Jun 2012 at 7:48
Attachments:
Original issue reported on code.google.com by
mohit.a...@gmail.com
on 1 Oct 2011 at 8:23