Subject: Re: [RFC PATCHv2 09/10] gitweb/cache.pm - Regenerate (refresh) cache in background

From: Jakub Narebski <[email-masked]>
Date: Tue, 9 Feb 2010 23:23:17 +0100

On Tue, 9 Feb 2010, Jakub Narebski wrote:

[...]
> +               my $pid = fork() if ($data && $self->get_background_cache());
> +               if (!defined $pid || $pid) {
> +                       # parent, or didn't fork
> +                       $data = $p_coderef->($self, $p_key);
> +                       $self->set($p_key, $data);
> +
> +                       if ($pid) {
> +                               # releases lock before waiting and exiting
> +                               close $lock_fh;
> +                               # wait for child (which would print) and exit
> +                               waitpid $pid, 0;
> +                               exit 0;
> +                       }
> +               } else {
> +                       # child is to serve stale data
> +                       return $data;
> +               }
[...]

I have decide to rely on $SIG{CHLD} = 'IGNORE' to not generate zombies,
and consistently exit in child (in forked process) and return in parent.
This change would be in next version of this series.

-- 
Jakub Narebski
Poland