Add dup_body_fh to return a dup'd body FH
It wasn't suitable to dup the body FH returned by plain old body_fh(), so here's a separate function to return that. Signed-off-by: Ask Bjørn Hansen <ask@develooper.com>
This commit is contained in:
parent
04f8f7dd98
commit
16b4dbcd81
@ -217,6 +217,12 @@ sub body_fh {
|
||||
return shift->{_body_file};
|
||||
}
|
||||
|
||||
sub dup_body_fh {
|
||||
my ($self) = @_;
|
||||
open(my $fh, '<&=', $self->body_fh);
|
||||
return $fh;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
# would we save some disk flushing if we unlinked the file before
|
||||
@ -380,6 +386,13 @@ Returns the file handle to the temporary file of the email. This will return
|
||||
undef if the file is not opened (yet). In I<hook_data( )> or later you can
|
||||
force spooling to disk by calling I<$transaction-E<gt>body_filename>.
|
||||
|
||||
=head2 dup_body_fh( )
|
||||
|
||||
Returns a dup()'d file handle to the temporary file of the email. This can be
|
||||
useful if an external module may call close() on the filehandle that is passed
|
||||
to it. This should only be used for reads, as writing to a dup'd filehandle
|
||||
may have unintended consequences.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Mail::Header>, L<Qpsmtpd::Address>, L<Qpsmtpd::Connection>
|
||||
|
Loading…
Reference in New Issue
Block a user