First, since EventLoop goes off and does other things, any PostLoopCallback
can signal "our" EventLoop to return. To ensure we wait the full time, we must loop around until the end condition is truly satisfied. git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@425 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
3b9c5b69fd
commit
56451a722f
@ -51,15 +51,18 @@ sub can_read {
|
||||
if (!length($self->{line})) {
|
||||
my $old = $self->watch_read();
|
||||
$self->watch_read(1);
|
||||
$self->SetPostLoopCallback(sub { (length($self->{line}) ||
|
||||
(Time::HiRes::time > $end)) ? 0 : 1 });
|
||||
#warn("get_line PRE\n");
|
||||
$self->EventLoop();
|
||||
#warn("get_line POST\n");
|
||||
# loop because any callback, not just ours, can make EventLoop return
|
||||
while( !(length($self->{line}) || (Time::HiRes::time > $end)) ) {
|
||||
$self->SetPostLoopCallback(sub { (length($self->{line}) ||
|
||||
(Time::HiRes::time > $end)) ? 0 : 1 });
|
||||
#warn("get_line PRE\n");
|
||||
$self->EventLoop();
|
||||
#warn("get_line POST\n");
|
||||
}
|
||||
$self->watch_read($old);
|
||||
}
|
||||
$self->{can_read_mode} = 0;
|
||||
$self->SetPostLoopCallback(sub { $self->have_line ? 0 : 1 });
|
||||
$self->SetPostLoopCallback(undef);
|
||||
return if $self->{closing};
|
||||
$self->{alive_time} = time;
|
||||
# warn("can_read returning for '$self->{line}'\n");
|
||||
|
Loading…
Reference in New Issue
Block a user