-use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0;
-sub more ($$) {
- my $self = $_[0];
- if (MSG_MORE && !$self->{write_buf_size}) {
- my $n = send($self->{sock}, $_[1], MSG_MORE);
- if (defined $n) {
- my $dlen = length($_[1]);
- return 1 if $n == $dlen; # all done!
- $_[1] = substr($_[1], $n, $dlen - $n);
- # fall through to normal write:
- }
- }
- $self->write($_[1]);
-}
-
-my $pipelineq = [];
-my $next_tick;
-sub process_pipelineq () {
- $next_tick = undef;
- my $q = $pipelineq;
- $pipelineq = [];
- rbuf_process($_) foreach @$q;
-}
-
-# overrides existing Danga::Socket method
-sub event_write {
- my ($self) = @_;
- # only continue watching for readability when we are done writing:
- return if $self->write(undef) != 1;
-
- if ($self->{rbuf} eq '') { # wait for next request
- $self->watch_read(1);
- } else { # avoid recursion for pipelined requests
- push @$pipelineq, $self;
- $next_tick ||= Danga::Socket->AddTimer(0, *process_pipelineq);
- }