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

[email protected] (David Favor)
Newsgroups perl.qpsmtpd
Message-ID <[email protected]>
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!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.