]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
lei: deep clone {ovv} for l2m workers
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 22cd20f6edbbf1d0a5fdfd5731a5e7250b1a70b5..08554932ab8b06957c81380feb9aee1ad6c18192 100644 (file)
@@ -14,10 +14,9 @@ use Getopt::Long ();
 use Socket qw(AF_UNIX SOCK_SEQPACKET MSG_EOR pack_sockaddr_un);
 use Errno qw(EPIPE EAGAIN EINTR ECONNREFUSED ENOENT ECONNRESET);
 use Cwd qw(getcwd);
-use POSIX ();
+use POSIX qw(strftime);
 use IO::Handle ();
 use Fcntl qw(SEEK_SET);
-use Sys::Syslog qw(syslog openlog);
 use PublicInbox::Config;
 use PublicInbox::Syscall qw(SFD_NONBLOCK EPOLLIN EPOLLET);
 use PublicInbox::Sigfd;
@@ -402,8 +401,9 @@ sub atfork_parent_wq {
        my ($self, $wq) = @_;
        my $env = delete $self->{env}; # env is inherited at fork
        my $lei = bless { %$self }, ref($self);
-       if (my $dedupe = delete $lei->{dedupe}) {
-               $lei->{dedupe} = $wq->deep_clone($dedupe);
+       for my $f (qw(dedupe ovv)) {
+               my $tmp = delete($lei->{$f}) or next;
+               $lei->{$f} = $wq->deep_clone($tmp);
        }
        $self->{env} = $env;
        delete @$lei{qw(3 -lei_store cfg old_1 pgr lxs)}; # keep l2m
@@ -861,7 +861,7 @@ sub dclose {
                if ($wq->wq_kill) {
                        $wq->wq_close
                } elsif ($wq->wq_kill_old) {
-                       $wq->wq_wait_old;
+                       $wq->wq_wait_old($self);
                }
        }
        close(delete $self->{1}) if $self->{1}; # may reap_compress
@@ -1007,9 +1007,9 @@ sub lazy_start {
                                warn "$path dev/ino changed, quitting\n";
                                $path = undef;
                        }
-               } elsif (defined($path)) {
-                       warn "stat($path): $!, quitting ...\n";
-                       undef $path; # don't unlink
+               } elsif (defined($path)) { # ENOENT is common
+                       warn "stat($path): $!, quitting ...\n" if $! != ENOENT;
+                       undef $path;
                        $quit->();
                }
                return 1 if defined($path);
@@ -1029,18 +1029,14 @@ sub lazy_start {
        # STDIN was redirected to /dev/null above, closing STDERR and
        # STDOUT will cause the calling `lei' client process to finish
        # reading the <$daemon> pipe.
-       openlog($path, 'pid', 'user');
        local $SIG{__WARN__} = sub {
-               $current_lei ? err($current_lei, @_) : syslog('warning', "@_");
+               $current_lei ? err($current_lei, @_) : warn(
+                 strftime('%Y-%m-%dT%H:%M:%SZ', gmtime(time))," $$ ", @_);
        };
-       my $on_destroy = PublicInbox::OnDestroy->new($$, sub {
-               syslog('crit', "$@") if $@;
-       });
        open STDERR, '>&STDIN' or die "redirect stderr failed: $!";
        open STDOUT, '>&STDIN' or die "redirect stdout failed: $!";
        # $daemon pipe to `lei' closed, main loop begins:
        PublicInbox::DS->EventLoop;
-       @$on_destroy = (); # cancel on_destroy if we get here
        exit($exit_code // 0);
 }