[Bps-public-commit] r11013 - in Net-IMAP-Server: lib/Net/IMAP lib/Net/IMAP/Server lib/Net/IMAP/Server/Command
alexmv at bestpractical.com
alexmv at bestpractical.com
Wed Mar 5 15:18:24 EST 2008
Author: alexmv
Date: Wed Mar 5 15:18:08 2008
New Revision: 11013
Modified:
Net-IMAP-Server/ (props changed)
Net-IMAP-Server/lib/Net/IMAP/Server.pm
Net-IMAP-Server/lib/Net/IMAP/Server/Command/Fetch.pm
Net-IMAP-Server/lib/Net/IMAP/Server/Connection.pm
Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm
Log:
r28314 at kohr-ah: chmrr | 2008-03-05 15:17:55 -0500
* Coro isn't "local"-safe (or the other way around, depending how you
look at it). Use $Coro::current to have per-coro values for
$server->connection
* Don't undef connection when polling (as mailboxes may want to know
auth information, for example) but mark it as being passively
polled.
Modified: Net-IMAP-Server/lib/Net/IMAP/Server.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server.pm (original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server.pm Wed Mar 5 15:18:08 2008
@@ -246,7 +246,10 @@
sub connection {
my $self = shift;
- return $self->{connection};
+ if (@_) {
+ $self->{connection}{$Coro::current . ""} = shift;
+ }
+ return $self->{connection}{$Coro::current . ""};
}
=head2 concurrent_mailbox_connections [MAILBOX]
Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Command/Fetch.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Command/Fetch.pm (original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Command/Fetch.pm Wed Mar 5 15:18:08 2008
@@ -31,8 +31,6 @@
. " FETCH "
. $self->data_out( [ $m->fetch($spec) ] ) );
cede;
- warn "Connection is no longer me!" if $self->connection->server->connection ne $self->connection;
- $self->connection->server->{connection} = $self->connection;
}
$self->ok_completed();
Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Connection.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Connection.pm (original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Connection.pm Wed Mar 5 15:18:08 2008
@@ -10,7 +10,7 @@
use Net::IMAP::Server::Command;
__PACKAGE__->mk_accessors(
- qw(server io_handle _selected selected_read_only model pending temporary_messages temporary_sequence_map previous_exists untagged_expunge untagged_fetch ignore_flags last_poll commands timer coro)
+ qw(server io_handle _selected selected_read_only model pending temporary_messages temporary_sequence_map previous_exists untagged_expunge untagged_fetch ignore_flags last_poll in_poll commands timer coro)
);
=head1 NAME
@@ -127,13 +127,11 @@
sub handle_lines {
my $self = shift;
$self->coro->prio(-4);
-
- local $self->server->{connection} = $self;
+ $self->server->connection($self);
eval {
$self->greeting;
while ( $self->io_handle and $_ = $self->io_handle->getline() ) {
- $self->server->{connection} = $self;
$self->handle_command($_);
$self->commands( $self->commands + 1 );
if ( $self->is_unauth
@@ -255,6 +253,7 @@
$self->timer->stop if $self->timer;
$self->selected->close if $self->selected;
$self->model->close if $self->model;
+ $self->server->connection(undef);
}
=head2 parse_command LINE
@@ -373,11 +372,12 @@
return unless $self->is_auth and $self->is_selected;
if ( time >= $self->last_poll + $self->server->poll_every ) {
-
- # When we poll, the things that we find should affect this
- # connection as well; hence, the local to be "connection-less"
- local $Net::IMAP::Server::Server->{connection};
+ # We record that we're in a poll so that EXPUNGE knows that
+ # this connection should get a temporary message store if need
+ # be.
+ $self->in_poll(1);
$self->poll;
+ $self->in_poll(0);
}
for my $s ( keys %{ $self->untagged_fetch } ) {
@@ -536,8 +536,6 @@
$self->close;
die "Error printing\n";
}
- warn "Connection is no longer me!" if $self->server->connection ne $self;
- $self->server->{connection} = $self;
}
1;
Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm (original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm Wed Mar 5 15:18:08 2008
@@ -262,8 +262,11 @@
# Ensure that all other connections with this selected get a
# temporary message list, if they don't already have one
unless (
- ( $Net::IMAP::Server::Server->connection
- and $c eq $Net::IMAP::Server::Server->connection
+ # Except if we find our own connection; if this is
+ # *not* part of a poll, we asked for it, so no need to
+ # set up temporary messages.
+ ( $c eq $Net::IMAP::Server::Server->connection
+ and not $c->in_poll
)
or $c->temporary_messages
)
More information about the Bps-public-commit
mailing list