]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/SolverGit.pm
fd43940f6901f083de5e5c7c73b2a6ec553645e5
[public-inbox.git] / lib / PublicInbox / SolverGit.pm
1 # Copyright (C) 2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # "Solve" blobs which don't exist in git code repositories by
5 # searching inboxes for post-image blobs.
6
7 # this emits a lot of debugging/tracing information which may be
8 # publically viewed over HTTP(S).  Be careful not to expose
9 # local filesystem layouts in the process.
10 package PublicInbox::SolverGit;
11 use strict;
12 use warnings;
13 use File::Temp 0.19 ();
14 use Fcntl qw(SEEK_SET);
15 use PublicInbox::Git qw(git_unquote git_quote);
16 use PublicInbox::MsgIter qw(msg_iter msg_part_text);
17 use PublicInbox::Qspawn;
18 use PublicInbox::Tmpfile;
19 use URI::Escape qw(uri_escape_utf8);
20
21 # POSIX requires _POSIX_ARG_MAX >= 4096, and xargs is required to
22 # subtract 2048 bytes.  We also don't factor in environment variable
23 # headroom into this.
24 use POSIX qw(sysconf _SC_ARG_MAX);
25 my $ARG_SIZE_MAX = (sysconf(_SC_ARG_MAX) || 4096) - 2048;
26 my $OID_MIN = 7;
27
28 # By default, "git format-patch" generates filenames with a four-digit
29 # prefix, so that means 9999 patch series are OK, right? :>
30 # Maybe we can make this configurable, main concern is disk space overhead
31 # for uncompressed patch fragments.  Aside from space, public-inbox-httpd
32 # is otherwise unaffected by having many patches, here, as it can share
33 # work fairly.  Other PSGI servers may have trouble, though.
34 my $MAX_PATCH = 9999;
35
36 # di = diff info / a hashref with information about a diff ($di):
37 # {
38 #       oid_a => abbreviated pre-image oid,
39 #       oid_b => abbreviated post-image oid,
40 #       tmp => anonymous file handle with the diff,
41 #       hdr_lines => arrayref of various header lines for mode information
42 #       mode_a => original mode of oid_a (string, not integer),
43 #       ibx => PublicInbox::Inbox object containing the diff
44 #       smsg => PublicInbox::SearchMsg object containing diff
45 #       path_a => pre-image path
46 #       path_b => post-image path
47 #       n => numeric path of the patch (relative to worktree)
48 # }
49
50 # don't bother if somebody sends us a patch with these path components,
51 # it's junk at best, an attack attempt at worse:
52 my %bad_component = map { $_ => 1 } ('', '.', '..');
53
54 sub dbg ($$) {
55         print { $_[0]->{out} } $_[1], "\n" or ERR($_[0], "print(dbg): $!");
56 }
57
58 sub ERR ($$) {
59         my ($self, $err) = @_;
60         print { $self->{out} } $err, "\n";
61         my $ucb = delete($self->{user_cb});
62         eval { $ucb->($err) } if $ucb;
63         die $err;
64 }
65
66 # look for existing objects already in git repos
67 sub solve_existing ($$) {
68         my ($self, $want) = @_;
69         my $oid_b = $want->{oid_b};
70         my $have_hints = scalar keys %$want > 1;
71         my @ambiguous; # Array of [ git, $oids]
72         foreach my $git (@{$self->{gits}}) {
73                 my ($oid_full, $type, $size) = $git->check($oid_b);
74                 if (defined($type) && (!$have_hints || $type eq 'blob')) {
75                         return [ $git, $oid_full, $type, int($size) ];
76                 }
77
78                 next if length($oid_b) == 40;
79
80                 # parse stderr of "git cat-file --batch-check"
81                 my $err = $git->last_check_err;
82                 my (@oids) = ($err =~ /\b([a-f0-9]{40})\s+blob\b/g);
83                 next unless scalar(@oids);
84
85                 # TODO: do something with the ambiguous array?
86                 # push @ambiguous, [ $git, @oids ];
87
88                 dbg($self, "`$oid_b' ambiguous in " .
89                                 join("\n\t", $git->pub_urls($self->{psgi_env}))
90                                 . "\n" .
91                                 join('', map { "$_ blob\n" } @oids));
92         }
93         scalar(@ambiguous) ? \@ambiguous : undef;
94 }
95
96 sub extract_diff ($$$$$) {
97         my ($self, $p, $re, $ibx, $smsg) = @_;
98         my ($part) = @$p; # ignore $depth and @idx;
99         my $hdr_lines; # diff --git a/... b/...
100         my $tmp;
101         my $ct = $part->content_type || 'text/plain';
102         my ($s, undef) = msg_part_text($part, $ct);
103         defined $s or return;
104         my $di = {};
105
106         # Email::MIME::Encodings forces QP to be CRLF upon decoding,
107         # change it back to LF:
108         my $cte = $part->header('Content-Transfer-Encoding') || '';
109         if ($cte =~ /\bquoted-printable\b/i && $part->crlf eq "\n") {
110                 $s =~ s/\r\n/\n/sg;
111         }
112
113         foreach my $l (split(/^/m, $s)) {
114                 if ($l =~ $re) {
115                         $di->{oid_a} = $1;
116                         $di->{oid_b} = $2;
117                         if (defined($3)) {
118                                 my $mode_a = $3;
119                                 if ($mode_a =~ /\A(?:100644|120000|100755)\z/) {
120                                         $di->{mode_a} = $mode_a;
121                                 }
122                         }
123
124
125                         # start writing the diff out to a tempfile
126                         my $path = ++$self->{tot};
127                         $di->{n} = $path;
128                         open($tmp, '>', $self->{tmp}->dirname . "/$path") or
129                                                         die "open(tmp): $!";
130
131                         push @$hdr_lines, $l;
132                         $di->{hdr_lines} = $hdr_lines;
133                         utf8::encode($_) for @$hdr_lines;
134                         print $tmp @$hdr_lines or die "print(tmp): $!";
135
136                         # for debugging/diagnostics:
137                         $di->{ibx} = $ibx;
138                         $di->{smsg} = $smsg;
139                 } elsif ($l =~ m!\Adiff --git ("?[^/]+/.+) ("?[^/]+/.+)$!) {
140                         last if $tmp; # got our blob, done!
141
142                         my ($path_a, $path_b) = ($1, $2);
143
144                         # diff header lines won't have \r because git
145                         # will quote them, but Email::MIME gives CRLF
146                         # for quoted-printable:
147                         $path_b =~ tr/\r//d;
148
149                         # don't care for leading 'a/' and 'b/'
150                         my (undef, @a) = split(m{/}, git_unquote($path_a));
151                         my (undef, @b) = split(m{/}, git_unquote($path_b));
152
153                         # get rid of path-traversal attempts and junk patches:
154                         foreach (@a, @b) {
155                                 return if $bad_component{$_};
156                         }
157
158                         $di->{path_a} = join('/', @a);
159                         $di->{path_b} = join('/', @b);
160                         $hdr_lines = [ $l ];
161                 } elsif ($tmp) {
162                         utf8::encode($l);
163                         print $tmp $l or die "print(tmp): $!";
164                 } elsif ($hdr_lines) {
165                         push @$hdr_lines, $l;
166                         if ($l =~ /\Anew file mode (100644|120000|100755)$/) {
167                                 $di->{mode_a} = $1;
168                         }
169                 }
170         }
171         return undef unless $tmp;
172         close $tmp or die "close(tmp): $!";
173         $di;
174 }
175
176 sub path_searchable ($) { defined($_[0]) && $_[0] =~ m!\A[\w/\. \-]+\z! }
177
178 # ".." appears in path names, which confuses Xapian into treating
179 # it as a range query.  So we split on ".." since Xapian breaks
180 # on punctuation anyways:
181 sub filename_query ($) {
182         join('', map { qq( dfn:"$_") } split(/\.\./, $_[0]));
183 }
184
185 sub find_extract_diffs ($$$) {
186         my ($self, $ibx, $want) = @_;
187         my $srch = $ibx->search or return;
188
189         my $post = $want->{oid_b} or die 'BUG: no {oid_b}';
190         $post =~ /\A[a-f0-9]+\z/ or die "BUG: oid_b not hex: $post";
191
192         my $q = "dfpost:$post";
193         my $pre = $want->{oid_a};
194         if (defined $pre && $pre =~ /\A[a-f0-9]+\z/) {
195                 $q .= " dfpre:$pre";
196         } else {
197                 $pre = '[a-f0-9]{7}'; # for $re below
198         }
199
200         my $path_b = $want->{path_b};
201         if (path_searchable($path_b)) {
202                 $q .= filename_query($path_b);
203
204                 my $path_a = $want->{path_a};
205                 if (path_searchable($path_a) && $path_a ne $path_b) {
206                         $q .= filename_query($path_a);
207                 }
208         }
209
210         my $msgs = $srch->query($q, { relevance => 1 });
211         my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: ([0-9]+))?/;
212
213         my @di;
214         foreach my $smsg (@$msgs) {
215                 $ibx->smsg_mime($smsg) or next;
216                 msg_iter(delete($smsg->{mime}), sub {
217                         my $di = extract_diff($self, $_[0], $re, $ibx, $smsg);
218                         push @di, $di if defined($di);
219                 });
220         }
221         @di ? \@di : undef;
222 }
223
224 sub update_index_result ($$) {
225         my ($bref, $self) = @_;
226         my ($qsp, $msg) = delete @$self{qw(-qsp -msg)};
227         if (my $err = $qsp->{err}) {
228                 ERR($self, "git update-index error: $err");
229         }
230         dbg($self, $msg);
231         next_step($self); # onto do_git_apply
232 }
233
234 sub prepare_index ($) {
235         my ($self) = @_;
236         my $patches = $self->{patches};
237         $self->{nr} = 0;
238
239         my $di = $patches->[0] or die 'no patches';
240         my $oid_a = $di->{oid_a} or die '{oid_a} unset';
241         my $existing = $self->{found}->{$oid_a};
242
243         # no index creation for added files
244         $oid_a =~ /\A0+\z/ and return next_step($self);
245
246         die "BUG: $oid_a not not found" unless $existing;
247
248         my $oid_full = $existing->[1];
249         my $path_a = $di->{path_a} or die "BUG: path_a missing for $oid_full";
250         my $mode_a = $di->{mode_a} || extract_old_mode($di);
251
252         my $in = tmpfile("update-index.$oid_full") or die "tmpfile: $!";
253         print $in "$mode_a $oid_full\t$path_a\0" or die "print: $!";
254         $in->flush or die "flush: $!";
255         sysseek($in, 0, 0) or die "seek: $!";
256
257         dbg($self, 'preparing index');
258         my $rdr = { 0 => fileno($in), -hold => $in };
259         my $cmd = [ qw(git update-index -z --index-info) ];
260         my $qsp = PublicInbox::Qspawn->new($cmd, $self->{git_env}, $rdr);
261         $path_a = git_quote($path_a);
262         $self->{-qsp} = $qsp;
263         $self->{-msg} = "index prepared:\n$mode_a $oid_full\t$path_a";
264         $qsp->psgi_qx($self->{psgi_env}, undef, \&update_index_result, $self);
265 }
266
267 # pure Perl "git init"
268 sub do_git_init ($) {
269         my ($self) = @_;
270         my $dir = $self->{tmp}->dirname;
271         my $git_dir = "$dir/git";
272
273         foreach ('', qw(objects refs objects/info refs/heads)) {
274                 mkdir("$git_dir/$_") or die "mkdir $_: $!";
275         }
276         open my $fh, '>', "$git_dir/config" or die "open git/config: $!";
277         print $fh <<'EOF' or die "print git/config $!";
278 [core]
279         repositoryFormatVersion = 0
280         filemode = true
281         bare = false
282         fsyncObjectfiles = false
283         logAllRefUpdates = false
284 EOF
285         close $fh or die "close git/config: $!";
286
287         open $fh, '>', "$git_dir/HEAD" or die "open git/HEAD: $!";
288         print $fh "ref: refs/heads/master\n" or die "print git/HEAD: $!";
289         close $fh or die "close git/HEAD: $!";
290
291         my $f = 'objects/info/alternates';
292         open $fh, '>', "$git_dir/$f" or die "open: $f: $!";
293         foreach my $git (@{$self->{gits}}) {
294                 print $fh $git->git_path('objects'),"\n" or die "print $f: $!";
295         }
296         close $fh or die "close: $f: $!";
297         my $tmp_git = $self->{tmp_git} = PublicInbox::Git->new($git_dir);
298         $tmp_git->{-tmp} = $self->{tmp};
299         $self->{git_env} = {
300                 GIT_DIR => $git_dir,
301                 GIT_INDEX_FILE => "$git_dir/index",
302         };
303         prepare_index($self);
304 }
305
306 sub extract_old_mode ($) {
307         my ($di) = @_;
308         if (join('', @{$di->{hdr_lines}}) =~
309                         /^old mode (100644|100755|120000)\b/) {
310                 return $1;
311         }
312         '100644';
313 }
314
315 sub do_finish ($$) {
316         my ($self, $user_cb) = @_;
317         my $found = $self->{found};
318         my $oid_want = $self->{oid_want};
319         if (my $exists = $found->{$oid_want}) {
320                 return $user_cb->($exists);
321         }
322
323         # let git disambiguate if oid_want was too short,
324         # but long enough to be unambiguous:
325         my $tmp_git = $self->{tmp_git};
326         if (my @res = $tmp_git->check($oid_want)) {
327                 return $user_cb->($found->{$res[0]});
328         }
329         if (my $err = $tmp_git->last_check_err) {
330                 dbg($self, $err);
331         }
332         $user_cb->(undef);
333 }
334
335 sub event_step ($) {
336         my ($self) = @_;
337         eval {
338                 # step 1: resolve blobs to patches in the todo queue
339                 if (my $want = pop @{$self->{todo}}) {
340                         # this populates {patches} and {todo}
341                         resolve_patch($self, $want);
342
343                 # step 2: then we instantiate a working tree once
344                 # the todo queue is finally empty:
345                 } elsif (!defined($self->{tmp_git})) {
346                         do_git_init($self);
347
348                 # step 3: apply each patch in the stack
349                 } elsif (scalar @{$self->{patches}}) {
350                         do_git_apply($self);
351
352                 # step 4: execute the user-supplied callback with
353                 # our result: (which may be undef)
354                 # Other steps may call user_cb to terminate prematurely
355                 # on error
356                 } elsif (my $user_cb = delete($self->{user_cb})) {
357                         do_finish($self, $user_cb);
358                 } else {
359                         die 'about to call user_cb twice'; # Oops :x
360                 }
361         }; # eval
362         my $err = $@;
363         if ($err) {
364                 $err =~ s/^\s*Exception:\s*//; # bad word to show users :P
365                 dbg($self, "E: $err");
366                 my $ucb = delete($self->{user_cb});
367                 eval { $ucb->($err) } if $ucb;
368         }
369 }
370
371 sub next_step ($) {
372         my ($self) = @_;
373         # if outside of public-inbox-httpd, caller is expected to be
374         # looping event_step, anyways
375         my $async = $self->{psgi_env}->{'pi-httpd.async'} or return;
376         # PublicInbox::HTTPD::Async->new
377         $async->(undef, undef, $self);
378 }
379
380 sub mark_found ($$$) {
381         my ($self, $oid, $found_info) = @_;
382         my $found = $self->{found};
383         $found->{$oid} = $found_info;
384         my $oid_cur = $found_info->[1];
385         while ($oid_cur ne $oid && length($oid_cur) > $OID_MIN) {
386                 $found->{$oid_cur} = $found_info;
387                 chop($oid_cur);
388         }
389 }
390
391 sub parse_ls_files ($$) {
392         my ($self, $bref) = @_;
393         my ($qsp, $di) = delete @$self{qw(-qsp -cur_di)};
394         if (my $err = $qsp->{err}) {
395                 die "git ls-files error: $err";
396         }
397
398         my ($line, @extra) = split(/\0/, $$bref);
399         scalar(@extra) and die "BUG: extra files in index: <",
400                                 join('> <', @extra), ">";
401
402         my ($info, $file) = split(/\t/, $line, 2);
403         my ($mode_b, $oid_b_full, $stage) = split(/ /, $info);
404         if ($file ne $di->{path_b}) {
405                 die
406 "BUG: index mismatch: file=$file != path_b=$di->{path_b}";
407         }
408
409         my $tmp_git = $self->{tmp_git} or die 'no git working tree';
410         my (undef, undef, $size) = $tmp_git->check($oid_b_full);
411         defined($size) or die "check $oid_b_full failed";
412
413         dbg($self, "index at:\n$mode_b $oid_b_full\t$file");
414         my $created = [ $tmp_git, $oid_b_full, 'blob', $size, $di ];
415         mark_found($self, $di->{oid_b}, $created);
416         next_step($self); # onto the next patch
417 }
418
419 sub ls_files_result {
420         my ($bref, $self) = @_;
421         eval { parse_ls_files($self, $bref) };
422         ERR($self, $@) if $@;
423 }
424
425 sub oids_same_ish ($$) {
426         (index($_[0], $_[1]) == 0) || (index($_[1], $_[0]) == 0);
427 }
428
429 sub skip_identical ($$$) {
430         my ($self, $patches, $cur_oid_b) = @_;
431         while (my $nxt = $patches->[0]) {
432                 if (oids_same_ish($cur_oid_b, $nxt->{oid_b})) {
433                         dbg($self, 'skipping '.di_url($self, $nxt).
434                                 " for $cur_oid_b");
435                         shift @$patches;
436                 } else {
437                         return;
438                 }
439         }
440 }
441
442 sub apply_result ($$) {
443         my ($bref, $self) = @_;
444         my ($qsp, $di) = delete @$self{qw(-qsp -cur_di)};
445         dbg($self, $$bref);
446         my $patches = $self->{patches};
447         if (my $err = $qsp->{err}) {
448                 my $msg = "git apply error: $err";
449                 my $nxt = $patches->[0];
450                 if ($nxt && oids_same_ish($nxt->{oid_b}, $di->{oid_b})) {
451                         dbg($self, $msg);
452                         dbg($self, 'trying '.di_url($self, $nxt));
453                 } else {
454                         ERR($self, $msg);
455                 }
456         } else {
457                 skip_identical($self, $patches, $di->{oid_b});
458         }
459
460         my @cmd = qw(git ls-files -s -z);
461         $qsp = PublicInbox::Qspawn->new(\@cmd, $self->{git_env});
462         $self->{-cur_di} = $di;
463         $self->{-qsp} = $qsp;
464         $qsp->psgi_qx($self->{psgi_env}, undef, \&ls_files_result, $self);
465 }
466
467 sub do_git_apply ($) {
468         my ($self) = @_;
469         my $dn = $self->{tmp}->dirname;
470         my $patches = $self->{patches};
471
472         # we need --ignore-whitespace because some patches are CRLF
473         my @cmd = (qw(git -C), $dn, qw(apply --cached --ignore-whitespace
474                         --unidiff-zero --whitespace=warn --verbose));
475         my $len = length(join(' ', @cmd));
476         my $total = $self->{tot};
477         my $di; # keep track of the last one for "git ls-files"
478         my $prv_oid_b;
479
480         do {
481                 my $i = ++$self->{nr};
482                 $di = shift @$patches;
483                 dbg($self, "\napplying [$i/$total] " . di_url($self, $di) .
484                         "\n" . join('', @{$di->{hdr_lines}}));
485                 my $path = $di->{n};
486                 $len += length($path) + 1;
487                 push @cmd, $path;
488                 $prv_oid_b = $di->{oid_b};
489         } while (@$patches && $len < $ARG_SIZE_MAX &&
490                  !oids_same_ish($patches->[0]->{oid_b}, $prv_oid_b));
491
492         my $rdr = { 2 => 1 };
493         my $qsp = PublicInbox::Qspawn->new(\@cmd, $self->{git_env}, $rdr);
494         $self->{-cur_di} = $di;
495         $self->{-qsp} = $qsp;
496         $qsp->psgi_qx($self->{psgi_env}, undef, \&apply_result, $self);
497 }
498
499 sub di_url ($$) {
500         my ($self, $di) = @_;
501         # note: we don't pass the PSGI env unconditionally, here,
502         # different inboxes can have different HTTP_HOST on the same instance.
503         my $ibx = $di->{ibx};
504         my $env = $self->{psgi_env} if $ibx eq $self->{inboxes}->[0];
505         my $url = $ibx->base_url($env);
506         my $mid = $di->{smsg}->{mid};
507         defined($url) ? "$url$mid/" : "<$mid>";
508 }
509
510 sub resolve_patch ($$) {
511         my ($self, $want) = @_;
512
513         if (scalar(@{$self->{patches}}) > $MAX_PATCH) {
514                 die "Aborting, too many steps to $self->{oid_want}";
515         }
516
517         # see if we can find the blob in an existing git repo:
518         my $cur_want = $want->{oid_b};
519         if ($self->{seen_oid}->{$cur_want}++) {
520                 die "Loop detected solving $cur_want\n";
521         }
522         if (my $existing = solve_existing($self, $want)) {
523                 my ($found_git, undef, $type, undef) = @$existing;
524                 dbg($self, "found $cur_want in " .
525                         join("\n", $found_git->pub_urls($self->{psgi_env})));
526
527                 if ($cur_want eq $self->{oid_want} || $type ne 'blob') {
528                         eval { delete($self->{user_cb})->($existing) };
529                         die "E: $@" if $@;
530                         return;
531                 }
532                 mark_found($self, $cur_want, $existing);
533                 return next_step($self); # onto patch application
534         }
535
536         # scan through inboxes to look for emails which results in
537         # the oid we want:
538         foreach my $ibx (@{$self->{inboxes}}) {
539                 my $diffs = find_extract_diffs($self, $ibx, $want) or next;
540
541                 unshift @{$self->{patches}}, @$diffs;
542                 dbg($self, "found $cur_want in ".
543                         join("\n\t", map { di_url($self, $_) } @$diffs));
544
545                 # good, we can find a path to the oid we $want, now
546                 # lets see if we need to apply more patches:
547                 my $di = $diffs->[0];
548                 my $src = $di->{oid_a};
549
550                 unless ($src =~ /\A0+\z/) {
551                         # we have to solve it using another oid, fine:
552                         my $job = { oid_b => $src, path_b => $di->{path_a} };
553                         push @{$self->{todo}}, $job;
554                 }
555                 return next_step($self); # onto the next todo item
556         }
557         if (length($cur_want) > $OID_MIN) {
558                 chop($cur_want);
559                 dbg($self, "retrying $want->{oid_b} as $cur_want");
560                 $want->{oid_b} = $cur_want;
561                 push @{$self->{todo}}, $want;
562                 return next_step($self); # retry with shorter abbrev
563         }
564
565         dbg($self, "could not find $cur_want");
566         eval { delete($self->{user_cb})->(undef) }; # not found! :<
567         die "E: $@" if $@;
568 }
569
570 # this API is designed to avoid creating self-referential structures;
571 # so user_cb never references the SolverGit object
572 sub new {
573         my ($class, $ibx, $user_cb) = @_;
574
575         bless {
576                 gits => $ibx->{-repo_objs},
577                 user_cb => $user_cb,
578                 # -cur_di, -qsp, -msg => temporary fields for Qspawn callbacks
579
580                 # TODO: config option for searching related inboxes
581                 inboxes => [ $ibx ],
582         }, $class;
583 }
584
585 # recreate $oid_want using $hints
586 # hints keys: path_a, path_b, oid_a
587 # Calls {user_cb} with: [ ::Git object, oid_full, type, size, di (diff_info) ]
588 # with found object, or undef if nothing was found
589 # Calls {user_cb} with a string error on fatal errors
590 sub solve ($$$$$) {
591         my ($self, $env, $out, $oid_want, $hints) = @_;
592
593         # should we even get here? Probably not, but somebody
594         # could be manually typing URLs:
595         return (delete $self->{user_cb})->(undef) if $oid_want =~ /\A0+\z/;
596
597         $self->{oid_want} = $oid_want;
598         $self->{out} = $out;
599         $self->{seen_oid} = {};
600         $self->{tot} = 0;
601         $self->{psgi_env} = $env;
602         $self->{todo} = [ { %$hints, oid_b => $oid_want } ];
603         $self->{patches} = []; # [ $di, $di, ... ]
604         $self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }
605         $self->{tmp} = File::Temp->newdir("solver.$oid_want-XXXXXXXX", TMPDIR => 1);
606
607         dbg($self, "solving $oid_want ...");
608         if (my $async = $env->{'pi-httpd.async'}) {
609                 # PublicInbox::HTTPD::Async->new
610                 $async->(undef, undef, $self);
611         } else {
612                 event_step($self) while $self->{user_cb};
613         }
614 }
615
616 1;