Fix a number of duh's in new code

git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@446 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2005-06-22 18:56:58 +00:00
parent bc3f52a380
commit be6b0e203c

View File

@ -116,7 +116,7 @@ sub AddTimer {
my ($secs, $coderef) = @_; my ($secs, $coderef) = @_;
my $timeout = time + $secs; my $timeout = time + $secs;
if (!@Timers || ($timeout > $Timers[-1][0])) { if (!@Timers || ($timeout >= $Timers[-1][0])) {
push @Timers, [$timeout, $coderef]; push @Timers, [$timeout, $coderef];
return; return;
} }
@ -275,59 +275,55 @@ sub EpollEventLoop {
my @events; my @events;
my $i; my $i;
my $evcount; my $evcount = epoll_wait($Epoll, 1000, $timeout * 1000, \@events);
# get up to 1000 events, 1000ms timeout
while ($evcount = epoll_wait($Epoll, 1000, $timeout * 1000, \@events)) {
my @objs;
EVENT:
for ($i=0; $i<$evcount; $i++) {
my $ev = $events[$i];
# it's possible epoll_wait returned many events, including some at the end if (!$evcount) {
# that ones in the front triggered unregister-interest actions. if we foreach my $fd ( keys %DescriptorMap ) {
# can't find the %sock entry, it's because we're no longer interested my Danga::Socket $sock = $DescriptorMap{$fd};
# in that event. if ($sock->can('ticker')) {
my Danga::Socket $pob = $DescriptorMap{$ev->[0]}; $sock->ticker;
my $code;
my $state = $ev->[1];
# if we didn't find a Perlbal::Socket subclass for that fd, try other
# pseudo-registered (above) fds.
if (! $pob) {
if (my $code = $OtherFds{$ev->[0]}) {
$code->($state);
}
next;
} }
DebugLevel >= 1 && $class->DebugMsg("Event: fd=%d (%s), state=%d \@ %s\n",
$ev->[0], ref($pob), $ev->[1], time);
push @objs, [$pob, $state];
} }
next;
foreach (@objs) {
my ($pob, $state) = @$_;
$pob->event_read if $state & EPOLLIN && ! $pob->{closed};
$pob->event_write if $state & EPOLLOUT && ! $pob->{closed};
$pob->event_err if $state & EPOLLERR && ! $pob->{closed};
$pob->event_hup if $state & EPOLLHUP && ! $pob->{closed};
}
return unless PostEventLoop();
} }
foreach my $fd ( keys %DescriptorMap ) { my @objs;
my Danga::Socket $sock = $DescriptorMap{$fd}; EVENT:
if ($sock->can('ticker')) { for ($i=0; $i<$evcount; $i++) {
$sock->ticker; my $ev = $events[$i];
# it's possible epoll_wait returned many events, including some at the end
# that ones in the front triggered unregister-interest actions. if we
# can't find the %sock entry, it's because we're no longer interested
# in that event.
my Danga::Socket $pob = $DescriptorMap{$ev->[0]};
my $code;
my $state = $ev->[1];
# if we didn't find a Perlbal::Socket subclass for that fd, try other
# pseudo-registered (above) fds.
if (! $pob) {
if (my $code = $OtherFds{$ev->[0]}) {
$code->($state);
}
next;
} }
DebugLevel >= 1 && $class->DebugMsg("Event: fd=%d (%s), state=%d \@ %s\n",
$ev->[0], ref($pob), $ev->[1], time);
push @objs, [$pob, $state];
}
foreach (@objs) {
my ($pob, $state) = @$_;
$pob->event_read if $state & EPOLLIN && ! $pob->{closed};
$pob->event_write if $state & EPOLLOUT && ! $pob->{closed};
$pob->event_err if $state & EPOLLERR && ! $pob->{closed};
$pob->event_hup if $state & EPOLLHUP && ! $pob->{closed};
} }
return unless PostEventLoop(); return unless PostEventLoop();
print STDERR "Event loop ending; restarting.\n";
} }
exit 0; exit 0;
} }