]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: sto_done_request: add eval guard
authorEric Wong <e@80x24.org>
Tue, 14 Sep 2021 02:39:02 +0000 (02:39 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Sep 2021 02:56:53 +0000 (02:56 +0000)
Failures here can cause the lei-daemon event loop to break
since PktOp doesn't guard dispatch.  Add a guard here (and
not deeper in the stack) so we can use the $lei object to
report errors.

lib/PublicInbox/LEI.pm

index f0caac03b1b622c2cfd24474f71c33aef963ec71..e529c86a853890b1adb2632db5c474d21b8f4329 100644 (file)
@@ -1500,12 +1500,15 @@ sub lms { # read-only LeiMailSync
 
 sub sto_done_request { # only call this from lei-daemon process (not workers)
        my ($lei, $sock) = @_;
-       if ($sock //= $lei->{sock}) {
-               $LIVE_SOCK{"$sock"} = $sock;
-               $lei->{sto}->ipc_do('done', "$sock"); # issue, async wait
-       } else { # forcibly wait
-               my $wait = $lei->{sto}->ipc_do('done');
-       }
+       eval {
+               if ($sock //= $lei->{sock}) { # issue, async wait
+                       $LIVE_SOCK{"$sock"} = $sock;
+                       $lei->{sto}->ipc_do('done', "$sock");
+               } else { # forcibly wait
+                       my $wait = $lei->{sto}->ipc_do('done');
+               }
+       };
+       $lei->err($@) if $@;
 }
 
 sub sto_done_complete { # called in lei-daemon when LeiStore->done is complete