-sub dwaitpid ($;$$) {
- my ($pid, $cb, $arg) = @_;
- if ($in_loop) {
- push @$wait_pids, [ $pid, $cb, $arg ];
- # We could've just missed our SIGCHLD, cover it, here:
- enqueue_reap();
- } else {
- my $ret = waitpid($pid, 0);
- if ($ret == $pid) {
- if ($cb) {
- eval { $cb->($arg, $pid) };
- carp "E: dwaitpid($pid) !in_loop: $@" if $@;
- }
- } else {
- carp "waitpid($pid, 0) = $ret, \$!=$!, \$?=$?";
- }
+sub dflush {} # overridden by DSdeflate
+sub compressed {} # overridden by DSdeflate
+sub long_response_done {} # overridden by Net::NNTP
+
+sub long_step {
+ my ($self) = @_;
+ # wbuf is unset or empty, here; {long} may add to it
+ my ($fd, $cb, $t0, @args) = @{$self->{long_cb}};
+ my $more = eval { $cb->($self, @args) };
+ if ($@ || !$self->{sock}) { # something bad happened...
+ delete $self->{long_cb};
+ my $elapsed = now() - $t0;
+ $@ and warn("$@ during long response[$fd] - ",
+ sprintf('%0.6f', $elapsed),"\n");
+ $self->out(" deferred[$fd] aborted - %0.6f", $elapsed);
+ $self->close;
+ } elsif ($more) { # $self->{wbuf}:
+ # control passed to ibx_async_cat if $more == \undef
+ requeue_once($self) if !ref($more);
+ } else { # all done!
+ delete $self->{long_cb};
+ $self->long_response_done;
+ my $elapsed = now() - $t0;
+ my $fd = fileno($self->{sock});
+ $self->out(" deferred[$fd] done - %0.6f", $elapsed);
+ my $wbuf = $self->{wbuf}; # do NOT autovivify
+ requeue($self) unless $wbuf && @$wbuf;