about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-04-17 09:47:11 +0000
committerEric Wong <e@80x24.org>2021-04-17 10:00:45 +0000
commit5df7b58488e0af9b082ed472cc7e693de869ec63 (patch)
tree37e7c9cbb7652377901b85606bdab5f447fb1936
parent315157c2e0c52e9e7b8078ba5c8b79e0b1a3802e (diff)
downloadpublic-inbox-5df7b58488e0af9b082ed472cc7e693de869ec63.tar.gz
Since --stdin could be waiting on user keyboard input or
something else slow, we handle it in the event loop.  That
means other commands can change the working directory of
lei-daemon while a query is being trickled to us via stdin.

Rearranging query handling internals to delay opening the
--output destination in commit 26e0fe73de93f451 meant
another command could throw off our --output pathname if
it is relative.

Fixes: 26e0fe73de93f451 ("lei_query: rearrange internals to capture query early")
-rw-r--r--lib/PublicInbox/LeiQuery.pm3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index 7ddba4cf..385ba0a9 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -53,6 +53,9 @@ sub qstr_add { # PublicInbox::InputPipe::consume callback for --stdin
         my ($self) = @_; # $_[1] = $rbuf
         if (defined($_[1])) {
                 $_[1] eq '' and return eval {
+                        if (my $dfd = $self->{3}) {
+                                chdir($dfd) or return $self->fail("fchdir: $!");
+                        }
                         $self->{mset_opt}->{q_raw} = $self->{mset_opt}->{qstr};
                         $self->{lse}->query_approxidate($self->{lse}->git,
                                                 $self->{mset_opt}->{qstr});