From b03dddcb4895d8e8ebe47d5cc57b34052fb48136 Mon Sep 17 00:00:00 2001 From: Radu Greab Date: Mon, 2 Jun 2008 16:48:20 +0000 Subject: [PATCH] Send data to the remote server in large chunks. Reduces a lot the sending time when running on slow CPUs. git-svn-id: https://svn.perl.org/qpsmtpd/trunk@922 958fd67b-6ff1-0310-b445-bb7760255be9 --- plugins/async/queue/smtp-forward | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/async/queue/smtp-forward b/plugins/async/queue/smtp-forward index 3af2fd7..4e0d498 100644 --- a/plugins/async/queue/smtp-forward +++ b/plugins/async/queue/smtp-forward @@ -261,10 +261,19 @@ sub cmd_data { # $self->{state} = ST_DATA; $self->datasend($self->{tran}->header->as_string); $self->{tran}->body_resetpos; + my $write_buf = ''; while (my $line = $self->{tran}->body_getline) { - $self->log(LOGDEBUG, ">> $line"); $line =~ s/\r?\n/\r\n/; - $self->datasend($line); + $write_buf .= $line; + if (length($write_buf) >= 131072) { # 128KB, arbitrary value + $self->log(LOGDEBUG, ">> $write_buf"); + $self->datasend($write_buf); + $write_buf = ''; + } + } + if (length($write_buf)) { + $self->log(LOGDEBUG, ">> $write_buf"); + $self->datasend($write_buf); } $self->write(".\r\n"); $self->{command} = "DATAEND";