'wbuf_off', # offset into first element of wbuf to start writing at
);
-use Errno qw(EAGAIN EINVAL);
-use Carp qw(croak confess carp);
-require File::Spec;
+use Errno qw(EAGAIN EINVAL);
+use Carp qw(confess carp);
my $nextq; # queue for next_tick
my $WaitPids; # list of [ pid, callback, callback_arg ]
# reentrant SIGCHLD handler (since reap_pids is not reentrant)
sub enqueue_reap ($) { push @$nextq, \&reap_pids };
-sub running () { ($SIG{CHLD} // '') eq \&enqueue_reap }
-
sub EpollEventLoop {
local $in_loop = 1;
do {
sub msg_more ($$) {
my $self = $_[0];
my $sock = $self->{sock} or return 1;
+ my $wbuf = $self->{wbuf};
- if (MSG_MORE && !$self->{wbuf} && ref($sock) ne 'IO::Socket::SSL') {
+ if (MSG_MORE && (!defined($wbuf) || !scalar(@$wbuf)) &&
+ ref($sock) ne 'IO::Socket::SSL') {
my $n = send($sock, $_[1], MSG_MORE);
if (defined $n) {
my $nlen = bytes::length($_[1]) - $n;
return 1 if $nlen == 0; # all done!
# queue up the unwritten substring:
my $tmpio = tmpio($self, \($_[1]), $n) or return 0;
- $self->{wbuf} = [ $tmpio ];
+ $self->{wbuf} //= $wbuf //= [];
+ push @$wbuf, $tmpio;
epwait($sock, EPOLLOUT|EPOLLONESHOT);
return 0;
}