[libnet-dbus-perl] 275/335: Ensure reactor shuts down if shutdown is requested by a pre-select hook callback (rt #39068)
Intrigeri
intrigeri at moszumanska.debian.org
Sat Mar 21 01:08:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch experimental
in repository libnet-dbus-perl.
commit a5c6f2b7b0c0b9ce863451cf682bf2437d3688ee
Author: Daniel P. Berrange <berrange at redhat.com>
Date: Mon May 4 17:51:54 2009 +0100
Ensure reactor shuts down if shutdown is requested by a pre-select hook callback (rt #39068)
---
lib/Net/DBus/Reactor.pm | 8 ++++++--
t/25-reactor.t | 4 ++++
t/30-server.t | 1 +
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/Net/DBus/Reactor.pm b/lib/Net/DBus/Reactor.pm
index dc8e61c..03d61b2 100644
--- a/lib/Net/DBus/Reactor.pm
+++ b/lib/Net/DBus/Reactor.pm
@@ -362,9 +362,13 @@ sub step {
if (!$ric && !$wic && !$eic && !(defined $timeout)) {
$self->{running} = 0;
- return;
}
-
+
+ # One of the hooks we ran might have requested shutdown
+ # so check here to avoid a undesirable wait in select()
+ # cf RT #39068
+ return unless $self->{running};
+
my ($ro, $wo, $eo);
my $n = select($ro=$ri,$wo=$wi,$eo=$ei, (defined $timeout ? ($timeout ? $timeout/1000 : 0) : undef));
diff --git a/t/25-reactor.t b/t/25-reactor.t
index 503fd61..b7917be 100644
--- a/t/25-reactor.t
+++ b/t/25-reactor.t
@@ -65,6 +65,7 @@ $reactor->add_write($w2,
$reactor->add_hook(Net::DBus::Callback->new(method => \&hook));
+$reactor->{running} = 1;
$reactor->step;
ok($r1c == 1, "read one byte a");
@@ -74,12 +75,14 @@ ok($hookc == 1, "hook 1\n");
write $w1, "11", 2;
write $w2, "1", 1;
+$reactor->{running} = 1;
$reactor->step;
ok($r1c == 2, "read 2 byte a");
ok($r2c == 1, "read one byte b");
ok($hookc == 2, "hook 2\n");
+$reactor->{running} = 1;
$reactor->step;
ok($r1c == 3, "read 2 byte a");
@@ -88,6 +91,7 @@ ok($hookc == 3, "hook 3\n");
$reactor->toggle_write($w1, 1);
$reactor->toggle_write($w2, 1);
+$reactor->{running} = 1;
$reactor->step;
ok($w1c == 1, "write 1 byte a");
diff --git a/t/30-server.t b/t/30-server.t
index d6e1596..80f0b86 100644
--- a/t/30-server.t
+++ b/t/30-server.t
@@ -29,6 +29,7 @@ my $client = Net::DBus::Binding::Connection->new(address => "unix:path=/tmp/dbus
ok ($client->is_connected, "client connected");
$reactor->manage($client);
+$reactor->{running} = 1;
$reactor->step;
ok (defined $incoming, "incoming");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-dbus-perl.git
More information about the Pkg-perl-cvs-commits
mailing list