Author: radu
Date: Thu Sep  4 04:37:38 2008
New Revision: 937

Modified:
   trunk/Changes
   trunk/plugins/tls

Log:
Close the SSL socket created by duplicating the connection file
descriptor. This allows the server to close the connection file
descriptor without getting errors like:

  Can't call method "close" on an undefined value at 
  /usr/share/perl5/IO/Socket/SSL.pm line 780.


Modified: trunk/Changes
==============================================================================
--- trunk/Changes       (original)
+++ trunk/Changes       Thu Sep  4 04:37:38 2008
@@ -1,3 +1,5 @@
+  plugins/tls: close the file descriptor for the SSL socket
+
   Set the Return-Path header when queuing into maildir mailboxes.
 
   prefork, forkserver: restart on SIGHUP (reload all modules, with register() /

Modified: trunk/plugins/tls
==============================================================================
--- trunk/plugins/tls   (original)
+++ trunk/plugins/tls   Thu Sep  4 04:37:38 2008
@@ -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