--- IO-AIO/AIO.xs 2005/08/17 03:01:56 1.24 +++ IO-AIO/AIO.xs 2005/08/17 03:16:56 1.25 @@ -269,9 +269,7 @@ static void atfork_prepare (void) { - pthread_mutex_lock (&frklock); - - fork_started = started; + int nstarted; for (;;) { while (nreqs) @@ -280,6 +278,7 @@ poll_cb (); } + nstarted = started; max_parallel (0); pthread_mutex_lock (&reqlock); @@ -292,6 +291,8 @@ min_parallel (fork_started); } + pthread_mutex_lock (&frklock); + fork_started = nstarted; pthread_mutex_lock (&reslock); assert (!started); @@ -303,18 +304,14 @@ static void atfork_parent (void) { pthread_mutex_unlock (&reslock); - min_parallel (fork_started); - pthread_mutex_unlock (&reqlock); pthread_mutex_unlock (&frklock); -} - -static void atfork_child (void) -{ - reqs = reqe = 0; + pthread_mutex_unlock (&reqlock); - atfork_parent (); + min_parallel (fork_started); } +#define atfork_child atfork_parent + /*****************************************************************************/ /* work around various missing functions */