Thread (18 messages) flat view 18 messages, 2 authors, 2016-06-15

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

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:48:12

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help