develooper Front page | perl.qpsmtpd | Postings from October 2010

Transaction.pm body_fh() badly broken [was: qpsmtpd-v0.84 seems toignore size_threshold]

Thread Next
From:
David Favor
Date:
October 22, 2010 12:31
Subject:
Transaction.pm body_fh() badly broken [was: qpsmtpd-v0.84 seems toignore size_threshold]
Message ID:
4CC1E673.2030007@davidfavor.com
Since no one responded to my previous email I've
combed through the code and found the problem.

root@hive1:# git-describe
v0.84-36-g0b0e4e9

perldoc lib/Qpsmtpd/Transaction.pm says...

    body_fh( )
        Returns the file handle to the temporary file
        of the email. This will return undef if the file
        is not opened (yet). In hook_data( ) or later you can
        force spooling to disk by calling $transaction->body_filename.

This use to be true and at some point the body_fh() code changed to:

    sub body_fh {
        my ($self) = @_;
        # Spool to disk if we weren't already doing so
        $self->body_spool() unless $self->{_filename};
        return $self->{_body_file};
    }

Per the documentation this subroutine should be a single line:

        return $self->{_body_fh};

Lord knows when this code changed or what other code written
depends on this change.

Suggested fixes:

    1) Fix the documentation to correctly reflect calling body_fh()
       is the same as calling body_spool()

    2) Add a subroutine spooled() which returns 1 if the data is
       spooled to a file or 0 if in memory

Better fix, deprecate body_fh() and force body_spool() to be called.

-- 
Love feeling your best ever, all day, every day?
Click http://RadicalHealth.com for the easy way!

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About