[Bps-public-commit] r9689 - in Net-Server-IMAP: lib/Net/Server/IMAP
alexmv at bestpractical.com
alexmv at bestpractical.com
Fri Nov 16 14:23:43 EST 2007
Author: alexmv
Date: Fri Nov 16 14:23:42 2007
New Revision: 9689
Modified:
Net-Server-IMAP/ (props changed)
Net-Server-IMAP/lib/Net/Server/IMAP/Connection.pm
Net-Server-IMAP/lib/Net/Server/IMAP/Mailbox.pm
Log:
r24864 at zoq-fot-pik: chmrr | 2007-11-16 14:22:10 -0500
* Bulletproofing printing. Net::SSLeay also needs a patch to prevent
segfaults, for complete bulletproofing.
* Better dealing for multiple closes
Modified: Net-Server-IMAP/lib/Net/Server/IMAP/Connection.pm
==============================================================================
--- Net-Server-IMAP/lib/Net/Server/IMAP/Connection.pm (original)
+++ Net-Server-IMAP/lib/Net/Server/IMAP/Connection.pm Fri Nov 16 14:23:42 2007
@@ -24,7 +24,7 @@
sub handle_lines {
my $self = shift;
my $i = 0;
- ++$i and $self->handle_command($_) while $_ = $self->io_handle->getline();
+ ++$i and $self->handle_command($_) while $self->io_handle and $_ = $self->io_handle->getline();
if ( not $i ) {
$self->log("Connection closed by remote host");
@@ -78,9 +78,12 @@
sub close {
my $self = shift;
- delete $self->server->connections->{ $self->io_handle->fileno };
- $self->server->select->remove( $self->io_handle );
- $self->io_handle->close;
+ if ($self->io_handle) {
+ delete $self->server->connections->{ $self->io_handle->fileno };
+ $self->server->select->remove( $self->io_handle );
+ $self->io_handle->close;
+ $self->io_handle(undef);
+ }
$self->model->close if $self->model;
}
@@ -243,18 +246,18 @@
sub out {
my $self = shift;
my $msg = shift;
-
- if ($self->io_handle) {
+ if ($self->io_handle and $self->io_handle->peerport) {
$self->io_handle->blocking(1);
- $self->io_handle->print($msg) or warn "********************** $!\n";
- $self->io_handle->blocking(0);
-
- $self->log("S(@{[$self->io_handle->peerport]},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $msg");
+ if ($self->io_handle->print($msg)) {
+ $self->io_handle->blocking(0);
+ $self->log("S(@{[$self->io_handle->peerport || 'undef']},@{[$self->auth ? $self->auth->user : '???']},@{[$self->is_selected ? $self->selected->full_path : 'unselected']}): $msg");
+ } else {
+ $self->io_handle->close if $self->io_handle;
+ $self->close;
+ }
} else {
- warn "Connection closed unexpectedly\n";
$self->close;
}
-
}
1;
Modified: Net-Server-IMAP/lib/Net/Server/IMAP/Mailbox.pm
==============================================================================
--- Net-Server-IMAP/lib/Net/Server/IMAP/Mailbox.pm (original)
+++ Net-Server-IMAP/lib/Net/Server/IMAP/Mailbox.pm Fri Nov 16 14:23:42 2007
@@ -242,10 +242,10 @@
sub prep_for_destroy {
my $self = shift;
my @kids = @{$self->children || []};
- $self->children(undef);
+ $self->children([]);
$_->prep_for_destroy for @kids;
- my @messages = @{$self->messages};
- $self->messages(undef) if @messages;
+ my @messages = @{$self->messages || []};
+ $self->messages([]);
$_->prep_for_destroy for @messages;
$self->parent(undef);
}
More information about the Bps-public-commit
mailing list