On 20 Jun 2005, at 13:57, Justin Erenkrantz wrote:

--On Monday, June 20, 2005 1:50 PM -0400 Matt Sergeant <[EMAIL PROTECTED]> wrote:

OK, so looking at the latest mod_perl sources we can dump all this bucket
stuff - the APR::Socket now has a recv() method so we can just read
straight from the socket.

If you do that, then you don't get SSL and other filtering goodies for free.
*shrug*  -- justin

Ah, no I was looking at the wrong sources. But there's now $bb->flatten which does exactly all we need by the looks of things.

This should be right:

Index: lib/Apache/Qpsmtpd.pm
===================================================================
--- lib/Apache/Qpsmtpd.pm       (revision 437)
+++ lib/Apache/Qpsmtpd.pm       (working copy)
@@ -16,7 +16,6 @@
 use APR::Socket ();
 use Apache2::Filter ();
 use ModPerl::Util ();
-# use Apache::TieBucketBrigade;

 our $VERSION = '0.02';

@@ -112,14 +111,11 @@
my $rc = $c->input_filters->get_brigade($bb, Apache2::Const::MODE_GETLINE);
         return if $rc == APR::Const::EOF;
die APR::Error::strerror($rc) unless $rc == APR::Const::SUCCESS;
-        my $data = '';
-
-        while (!$bb->is_empty) {
-            my $b = $bb->first;
-            $b->read(my $newdata);
-            $data .= $newdata;
-            return $data if index($newdata, "\n") >= 0;
-        }
+
+        next unless $bb->flatten(my $data);
+
+        $bb->cleanup;
+        return $data;
     }

     return '';
@@ -145,10 +141,11 @@
         my $bb = $self->{bb_out};
         my $line = $code . (@messages?"-":" ").$msg;
         $self->log(LOGDEBUG, $line);
-       my $bucket = APR::Bucket->new(($c->bucket_alloc), "$line\r\n");
+        my $bucket = APR::Bucket->new(($c->bucket_alloc), "$line\r\n");
         $bb->insert_tail($bucket);
         $c->output_filters->fflush($bb);
-        $bucket->remove;
+        # $bucket->remove;
+        $bb->cleanup;
     }
     return 1;
 }

Reply via email to