diff options
author | 2012-02-12 02:55:09 +0600 | |
---|---|---|
committer | 2012-02-12 02:55:09 +0600 | |
commit | ee2122ad032c5b8601e6d590df75f2147531aae2 (patch) | |
tree | 7d1a5756fdc44abd98eac815df7ce3b1b64e31a6 | |
parent | fixed crashes in ruby's rb_thread_blocking_region(). Shrink buffer for proc e... (diff) | |
download | autodep-ee2122ad032c5b8601e6d590df75f2147531aae2.tar.gz autodep-ee2122ad032c5b8601e6d590df75f2147531aae2.tar.bz2 autodep-ee2122ad032c5b8601e6d590df75f2147531aae2.zip |
fixed a deadlock
-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 |