Here's two patches.
The first one is straight forward, and necessary to prevent the
disable_read call in DNS::new from making can_read stall.
The second is a cleanup of watch_read(0) -> disable_read() and
watch_read(1) -> enable_read(). It's working for me, but you may want to
check it for sanity.
Brian
=== lib/Danga/Client.pm
==================================================================
--- lib/Danga/Client.pm (revision 1567)
+++ lib/Danga/Client.pm (revision 1568)
@@ -49,8 +49,7 @@
# warn("Calling can-read\n");
$self->{can_read_mode} = 1;
if (!length($self->{line})) {
- my $old = $self->watch_read();
- $self->watch_read(1);
+ $self->disable_read();;
# 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}) ||
@@ -59,7 +58,7 @@
$self->EventLoop();
#warn("get_line POST\n");
}
- $self->watch_read($old);
+ $self->enable_read();;
}
$self->{can_read_mode} = 0;
$self->SetPostLoopCallback(undef);
=== lib/Danga/Client.pm
==================================================================
--- lib/Danga/Client.pm (revision 1569)
+++ lib/Danga/Client.pm (local)
@@ -33,7 +33,7 @@
#warn("get_line PRE\n");
$self->EventLoop();
#warn("get_line POST\n");
- $self->watch_read(0);
+ $self->disable_read();
}
return if $self->{closing};
# now have a line.
=== lib/Danga/DNS.pm
==================================================================
--- lib/Danga/DNS.pm (revision 1569)
+++ lib/Danga/DNS.pm (local)
@@ -39,25 +39,25 @@
if ($options{type}) {
if ($options{type} eq 'TXT') {
if (!$resolver->query_txt($self, @{$self->{hosts}})) {
- $client->watch_read(1) if $client;
+ $client->enable_read() if $client;
return;
}
}
elsif ($options{type} eq 'A') {
if (!$resolver->query($self, @{$self->{hosts}})) {
- $client->watch_read(1) if $client;
+ $client->enable_read() if $client;
return;
}
}
elsif ($options{type} eq 'PTR') {
if (!$resolver->query($self, @{$self->{hosts}})) {
- $client->watch_read(1) if $client;
+ $client->enable_read() if $client;
return;
}
}
elsif ($options{type} eq 'MX') {
if (!$resolver->query_mx($self, @{$self->{hosts}})) {
- $client->watch_read(1) if $client;
+ $client->enable_read() if $client;
return;
}
}
@@ -67,7 +67,7 @@
}
else {
if (!$resolver->query($self, @{$self->{hosts}})) {
- $client->watch_read(1) if $client;
+ $client->enable_read() if $client;
return;
}
}
=== qpsmtpd
==================================================================
--- qpsmtpd (revision 1569)
+++ qpsmtpd (local)
@@ -224,13 +224,13 @@
return;
}
- $client->watch_read(1);
+ $client->enable_read();
while (1) {
my $line = $client->get_line;
last if !defined($line);
my $output = $out->process_line($line);
$out->write($output) if $output;
- $client->watch_read(1);
+ $client->enable_read();
}
}
@@ -324,7 +324,7 @@
setsockopt($csock, IPPROTO_TCP, TCP_NODELAY, pack("l", 1)) or die;
my $client = Qpsmtpd::ConfigServer->new($csock);
- $client->watch_read(1);
+ $client->enable_read();
return;
}
@@ -414,7 +414,7 @@
}
$client->push_back_read("Connect\n");
- $client->watch_read(1);
+ $client->enable_read();
return 1;
}
@@ -453,7 +453,7 @@
$client->close;
exit;
}
- $client->watch_read(1);
+ $client->enable_read();
while (1) {
my $line = $client->get_line;
@@ -461,7 +461,7 @@
my $resp = $client->process_line($line);
# if ($resp) { print "S: $_\n" for split(/\n/, $resp) }
$client->write($resp) if $resp;
- $client->watch_read(1);
+ $client->enable_read();
}
::log(LOGDEBUG, "Finished with child %d.\n", fileno($csock))