Skip to content

Commit

Permalink
Switch from an implicit EV dependency to an explicit AnyEvent dependency
Browse files Browse the repository at this point in the history
Previously, EV::timer was used to set up the inactivity timers, despite
EV not being imported explicitly.  With Net::Server::Coro 1.3, EV is no
longer a dependency; it has switched to the more general AnyEvent
module.  Follow suit by using AnyEvent for the one explicit timer that
is needed.
  • Loading branch information
alexmv committed Nov 12, 2012
1 parent e3df0b1 commit 1704f8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -10,6 +10,7 @@ license('perl');
readme_from('lib/Net/IMAP/Server.pm');
sign;

requires('AnyEvent');
requires('Class::Accessor');
requires('Coro');
requires('DateTime');
Expand Down
12 changes: 6 additions & 6 deletions lib/Net/IMAP/Server/Connection.pm
Expand Up @@ -6,6 +6,7 @@ use strict;
use base 'Class::Accessor';

use Coro;
use AnyEvent;
use Scalar::Util qw/weaken/;

use Net::IMAP::Server::Error;
Expand Down Expand Up @@ -216,7 +217,6 @@ Updates the inactivity timer.

sub update_timer {
my $self = shift;
$self->timer->stop if $self->timer;
$self->timer(undef);
my $weakself = $self;
weaken($weakself);
Expand All @@ -225,15 +225,15 @@ sub update_timer {
$weakself->coro->ready;
};
if ( $self->is_unauth and $self->server->unauth_idle ) {
$self->timer( EV::timer $self->server->unauth_idle, 0, $timeout );
$self->timer( AnyEvent->timer( after => $self->server->unauth_idle, cb => $timeout ) );
} elsif ( $self->server->auth_idle ) {
$self->timer( EV::timer $self->server->auth_idle, 0, $timeout );
$self->timer( AnyEvent->timer( after => $self->server->auth_idle, cb => $timeout ) );
}
}

=head2 timer [EV watcher]
=head2 timer [AnyEvent watcher]
Returns the L<EV> watcher in charge of the inactivity timer.
Returns the L<AnyEvent> watcher in charge of the inactivity timer.
=head2 commands
Expand Down Expand Up @@ -343,7 +343,7 @@ sub close {
$self->io_handle->close;
$self->io_handle(undef);
}
$self->timer->stop if $self->timer;
$self->timer( undef ) if $self->timer;
$self->selected->close if $self->selected;
$self->model->close if $self->model;
$self->server->connection(undef);
Expand Down
2 changes: 2 additions & 0 deletions t/lib/Net/IMAP/Server/Test.pm
Expand Up @@ -5,6 +5,8 @@ use strict;
use warnings;

use Socket;
use AnyEvent;
AnyEvent::detect();
use IO::Socket::SSL;
use Time::HiRes qw();

Expand Down

0 comments on commit 1704f8a

Please sign in to comment.