diff options
Diffstat (limited to 'src/hook_lib/file_hook.c')
-rw-r--r-- | src/hook_lib/file_hook.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/hook_lib/file_hook.c b/src/hook_lib/file_hook.c index cd3850a..493c206 100644 --- a/src/hook_lib/file_hook.c +++ b/src/hook_lib/file_hook.c @@ -539,9 +539,18 @@ pid_t fork(void) { __fixenv(); + // We have to get lock here because we can't be sure that other thread not in + // protected code. When we forks, only current thread gets copied, so + // child mutex may be always locked without this. + pthread_mutex_lock( &socketblock ); + int ret=_fork(); int saved_errno=errno; + // we must to handle fork for reconnect a socket + + pthread_mutex_unlock( &socketblock ); + if(ret==0) { __doreconnect(); // reinit connection for children |