Diego d'Ambra wrote:
> 
> >>> Sending an email using tls plugin with qpsmtpd-prefork (revision 936)
> >>> will result in child exiting next time a client connects with:
> 
> I've not be able to find a way to do it and maybe the solution is 
> something entirely different, e.g. found in the plugin handling TLS?

In the case of non-async qpsmtpd, the tls plugin is creating the SSL
socket by duplicating the connection file descriptor. If the
qpsmtpd-prefork code attempts to close the connection file descriptor,
without the SSL file descriptor being closed first, it gets the error
you posted.

If the tls plugin closes the SSL socket at the end of the connection,
then qpsmtpd-prefork can close STDIN and STDOUT without error.

Here is a patch, tested on async, forkserver and prefork, that, by my
tests, fixes the problem. Please review it and if there are no
objections I will commit it in the following days:


=== plugins/tls
==================================================================
--- plugins/tls (revision 958)
+++ plugins/tls (revision 959)
@@ -152,6 +152,19 @@
     return DECLINED;
 }
 
+sub hook_post_connection {
+    my ($self, $transaction) = @_;
+
+    my $tls_socket = $self->connection->notes('tls_socket');
+    if (defined $tls_socket && 
$self->connection->notes('tls_socket_is_duped')) {
+        $tls_socket->close;
+        $self->connection->notes('tls_socket', undef);
+        $self->connection->notes('tls_socked_is_duped', 0);
+    }
+
+    return DECLINED;
+}
+
 sub _convert_to_ssl {
     my ($self) = @_;
 
@@ -175,6 +188,7 @@
         $self->qp->connection($self->connection->clone());
         $self->qp->reset_transaction;
         *STDIN = *STDOUT = $self->connection->notes('tls_socket', $tlssocket);
+        $self->connection->notes('tls_socket_is_duped', 1);
         $self->connection->notes('tls_enabled', 1);
     };
     if ($@) {

Reply via email to