tags 395369 + patch thanks Hi,
The following is the diff for my libpoe-component-client-dns-perl 1:0.99-1.1 NMU. diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/CHANGES /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/CHANGES --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/CHANGES 2005-08-08 00:38:12.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/CHANGES 2006-05-21 22:46:28.000000000 +0200 @@ -1,3 +1,39 @@ +========================= +2006-05-21 20:45:46 v0_99 +========================= + + 2006-05-21 20:45:11 (r58) by rcaputo; DNS.pm M + + Bump up the version. + + 2006-05-21 20:44:39 (r57) by rcaputo; DNS.pm M + + Fix shutdown(). It was not performing nearly enough cleanup. + + Replace some post() calls with call() to avoid race conditions. In + general, method interfaces should use call() rather than post() so + that they affect internal structures synchronously. + + 2006-05-21 20:43:08 (r56) by rcaputo + t/02_tag_args.t M; t/03_api_3.t M; t/05_api_4.t M; t/06_hosts.t M + + Turn on ASSERT_DEFAULT for some of the tests. Add _stop handlers so + they don't fail with all POE asserts on. + + 2006-03-24 03:58:51 (r55) by rcaputo; DNS.pm M + + Belatedly bump up the version. + +=========================== +2005-12-05 18:36:03 v0_9803 +=========================== + + 2005-12-05 18:34:05 (r53) by rcaputo; t/04_errors.t M + + Add the CATCH_EXCEPTIONS toggle that lets me catch my own damn + errors. Sweet! Also expanded the common test code so that line + numbers would be properly reported. + =========================== 2005-08-07 22:37:35 v0_9802 =========================== @@ -51,67 +87,6 @@ Change cvs-log.perl to svn-log.perl in Makefile.PL. -========================= -2004-10-07 03:34:35 v0_98 -========================= - - 2004-10-07 03:34:35 (r42) by rcaputo; DNS.pm M - - Bump the version to 0.98 for release, and document the deprecations - more carefully. - - 2004-10-07 03:16:45 (r41) by rcaputo; DNS.pm M - - Add code to look for /etc/hosts in various other places on Windows - systems. Oh, the horrors! - - 2004-10-07 03:04:31 (r40) by rcaputo - t/04_errors.t M; t/05_api_4.t A; MANIFEST M - - Added new tests to cover the additional public interface. - - 2004-10-07 03:03:42 (r39) by rcaputo; DNS.pm M - - Added the "version 4" interface, which is just a method in front of - the "version 3" interface. The method-based interface lets us build a - resolver cache later. The component will be able to return resolver - answers from the cache without incurring any POE event loop overhead. - - Documented the new interface. Updated the SYNOPSIS to show it. Tested - the SYNOPSIS code. - - Changed the private event handler names to include a leading - underscore, so that Pod::Coverage will automatically discount them in - its reports. - - Switched to object methods as event handlers. Moved the HEAP data - into $self. This lets us get at the data members from the public - object methods and the public/private event handlers. - - 2004-10-07 01:23:43 (r38) by rcaputo; DNS.pm M - - Rewrite the documentation to explain the new interface. - - 2004-10-07 01:23:08 (r37) by rcaputo; t/03_api_3.t M - - Remove some unnecessary code from this test. A previous test was - copied as the basis for this one, and some useless code came along. - - 2004-10-06 18:06:11 (r36) by rcaputo - DNS.pm M; t/03_api_3.t A; t/04_errors.t A; MANIFEST M; Makefile.PL M - - Add a saner (currently undocumented) API, and maintain backward - compatibility. Increase test coverage to >80%. - - 2004-06-12 16:51:31 (r35) by rcaputo; DNS.pm M - - "Overlord Q" reported a syntax error in the SYNOPSIS. This change - corrects the mistake and improves the code's readability. - - 2004-02-13 02:21:12 (r34) by rcaputo; MANIFEST M - - Add META.yml to the MANIFEST. - ============== End of Excerpt ============== diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/DNS.pm /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/DNS.pm --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/DNS.pm 2005-08-08 00:37:12.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/DNS.pm 2006-05-21 22:45:24.000000000 +0200 @@ -1,4 +1,4 @@ -# $Id: DNS.pm 51 2005-08-01 17:07:05Z rcaputo $ +# $Id: DNS.pm 58 2006-05-21 20:45:11Z rcaputo $ # License and documentation are after __END__. package POE::Component::Client::DNS; @@ -6,7 +6,7 @@ use strict; use vars qw($VERSION); -$VERSION = '0.9802'; +$VERSION = '0.99'; use Carp qw(croak); @@ -14,6 +14,8 @@ use Net::DNS; use POE; +use constant DEBUG => 0; + # Keep track of requests for each response socket. Used to pass data # around select_read(). @@ -35,6 +37,7 @@ sub SF_HOSTS_INODE () { 7 } sub SF_HOSTS_CACHE () { 8 } sub SF_HOSTS_BYTES () { 9 } +sub SF_SHUTDOWN () { 10 } # Spawn a new PoCo::Client::DNS session. This basically is a # constructor, but it isn't named "new" because it doesn't create a @@ -70,6 +73,7 @@ 0, # SF_HOSTS_INODE { }, # SF_HOSTS_CACHE 0, # SF_HOSTS_BYTES + 0, # SF_SHUTDOWN ], $type; # Set the list of nameservers, if one was supplied. @@ -82,10 +86,11 @@ $self => { _default => "_dns_default", _start => "_dns_start", + _stop => "_dns_stop", got_dns_response => "_dns_response", resolve => "_dns_resolve", send_request => "_dns_do_request", - shutdown => "_dns_shutdown", + shutdown => "_dns_shutdown", }, ], ); @@ -104,15 +109,14 @@ croak "resolve() must include a 'context'" unless exists $args{context}; croak "resolve() must include a 'host'" unless exists $args{host}; - $poe_kernel->post( $self->[SF_ALIAS], "resolve", \%args ); + $poe_kernel->call( $self->[SF_ALIAS], "resolve", \%args ); return undef; } sub shutdown { my $self = shift; - - $poe_kernel->post( $self->[SF_ALIAS], "shutdown" ); + $poe_kernel->call( $self->[SF_ALIAS], "shutdown" ); } # Start the resolver session. Record the parameters which were @@ -124,6 +128,12 @@ $kernel->alias_set($object->[SF_ALIAS]); } +# Dummy handler to avoid ASSERT_DEFAULT problems. + +sub _dns_stop { + # do nothing +} + # Receive a request. Version 4 API. This uses extra reference counts # to keep the client sessions alive until responses are ready. @@ -226,7 +236,8 @@ # back to itself for retrying. my $now = time(); - $kernel->yield( + $kernel->call( + $self->[SF_ALIAS], send_request => { sender => $sender, event => $event, @@ -279,6 +290,9 @@ $kernel->delay($resolver_socket, $remaining, $resolver_socket); $kernel->select_read($resolver_socket, 'got_dns_response'); + + # Save the socket for pre-emptive shutdown. + $req->{resolver_socket} = $resolver_socket; } # A resolver query timed out. Post an error back. @@ -346,9 +360,27 @@ sub _dns_shutdown { my ($self, $kernel) = @_[OBJECT, KERNEL]; - foreach my $alias ( $kernel->alias_list( $_[SESSION] ) ) { - $kernel->alias_remove( $alias ); + # Clean up all pending socket timeouts and selects. + foreach my $socket (keys %req_by_socket) { + DEBUG and warn "SHT: Shutting down resolver socket $socket"; + my $req = delete $req_by_socket{$socket}; + + $kernel->delay($socket); + $kernel->select($req->{resolver_socket}); + + # Let the client session go. + DEBUG and warn "SHT: Releasing sender ", $req->{sender}->ID; + $poe_kernel->refcount_decrement($req->{sender}->ID, __PACKAGE__); } + + # Clean out our global timeout. + $kernel->delay(send_request => undef); + + # Clean up our global alias. + DEBUG and warn "SHT: Resolver removing alias $self->[SF_ALIAS]"; + $kernel->alias_remove($self->[SF_ALIAS]); + + $self->[SF_SHUTDOWN] = 1; } # Send a response. Fake a postback for older API versions. Send a @@ -449,7 +481,7 @@ $self->[SF_HOSTS_MTIME] == $mtime and $self->[SF_HOSTS_CTIME] == $ctime and $self->[SF_HOSTS_INODE] == $inode and - $self->[SF_HOSTS_BYTES] == $bytes + $self->[SF_HOSTS_BYTES] == $bytes ) { return unless open(HOST, "<", $use_hosts_file); diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/META.yml /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/META.yml --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/META.yml 2005-08-08 00:38:05.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/META.yml 2006-05-21 22:46:18.000000000 +0200 @@ -1,13 +1,15 @@ -# http://module-build.sourceforge.net/META-spec.html -#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# -name: POE-Component-Client-DNS -version: 0.9802 -version_from: DNS.pm -installdirs: site -requires: +--- #YAML:1.0 +name: POE-Component-Client-DNS +version: 0.99 +abstract: Non-blocking/concurrent DNS queries using Net::DNS and POE +license: unknown +generated_by: ExtUtils::MakeMaker version 6.30_01 +author: Rocco Caputo <[EMAIL PROTECTED]> +distribution_type: module +requires: Net::DNS: 0.53 POE: 0.31 Test::More: 0 - -distribution_type: module -generated_by: ExtUtils::MakeMaker version 6.28 +meta-spec: + url: <http://module-build.sourceforge.net/META-spec-new.html>; + version: 1.1 diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/debian/changelog /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/debian/changelog --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/debian/changelog 2006-11-09 11:08:39.000000000 +0100 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/debian/changelog 2006-11-09 11:08:39.000000000 +0100 @@ -1,3 +1,11 @@ +libpoe-component-client-dns-perl (1:0.99-1.1) unstable; urgency=medium + + * non-maintainer upload. + * New upstream release, fixes various test failures, + Closes: #395369 + + -- Michael Ablassmeier <[EMAIL PROTECTED]> Thu, 9 Nov 2006 11:00:13 +0100 + libpoe-component-client-dns-perl (0.9802-1) unstable; urgency=low * New upstream release. (Closes: #329646) diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/02_tag_args.t /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/02_tag_args.t --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/02_tag_args.t 2005-05-05 07:07:10.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/02_tag_args.t 2006-05-21 21:13:46.000000000 +0200 @@ -29,6 +29,8 @@ } }, + _stop => sub { }, # for asserts + reverse => sub { if ($_[ARG0][3] eq "TEST WORKED") { $tests[$_[ARG0][4]] = ""; diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/03_api_3.t /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/03_api_3.t --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/03_api_3.t 2005-05-05 07:07:09.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/03_api_3.t 2006-05-21 22:43:20.000000000 +0200 @@ -1,9 +1,11 @@ #!/usr/bin/perl -w -# $Id: 03_api_3.t 37 2004-10-07 01:23:08Z rcaputo $ +# $Id: 03_api_3.t 56 2006-05-21 20:43:08Z rcaputo $ +# vim: filetype=perl # Test the version 3 API. use strict; +sub POE::Kernel::ASSERT_DEFAULT () { 1 } use POE qw(Component::Client::DNS); use Test::More tests => 4; @@ -16,6 +18,7 @@ inline_states => { _start => \&start_tests, response => \&got_response, + _stop => sub { }, # avoid assert problems } ); diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/04_errors.t /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/04_errors.t --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/04_errors.t 2005-05-05 07:07:09.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/04_errors.t 2005-12-05 19:34:05.000000000 +0100 @@ -1,9 +1,12 @@ #!/usr/bin/perl -w -# $Id: 04_errors.t 40 2004-10-07 03:04:31Z rcaputo $ +# $Id: 04_errors.t 53 2005-12-05 18:34:05Z rcaputo $ +# vim: filetype=perl # Deliberately trigger errors. use strict; + +sub POE::Kernel::CATCH_EXCEPTIONS () { 0 } use POE qw(Component::Client::DNS); use Test::More tests => 9; @@ -11,74 +14,105 @@ # Avoid a warning. POE::Kernel->run(); -sub test_err { - my ($err, $target) = @_; +{ + eval { POE::Component::Client::DNS->spawn(1); }; + my $err = $@; $err =~ s/ at \S+ line \d+.*//s; - ok($err eq $target, $target); + is( + $err, "POE::Component::Client::DNS requires an even number of parameters" + ); } -eval { POE::Component::Client::DNS->spawn(1); }; -test_err( - $@, - "POE::Component::Client::DNS requires an even number of parameters" -); - -eval { POE::Component::Client::DNS->spawn(moo => "nope"); }; -test_err( - $@, - "POE::Component::Client::DNS doesn't know these parameters: moo" -); +{ + eval { POE::Component::Client::DNS->spawn(moo => "nope"); }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is( + $err, "POE::Component::Client::DNS doesn't know these parameters: moo" + ); +} my $resolver = POE::Component::Client::DNS->spawn(); -eval { - $poe_kernel->call( - "resolver", "resolve", { - } - ); -}; -test_err($@, "Must include an 'event' in Client::DNS request"); - -eval { - $poe_kernel->call( - "resolver", "resolve", { - event => "moo", - } - ); -}; -test_err($@, "Must include a 'context' in Client::DNS request"); - -eval { - $poe_kernel->call( - "resolver", "resolve", { - event => "moo", - context => "bar", - } - ); -}; -test_err($@, "Must include a 'host' in Client::DNS request"); - -eval { - $resolver->resolve(1); -}; -test_err($@, "resolve() needs an even number of parameters"); - -eval { - $resolver->resolve(); -}; -test_err($@, "resolve() must include an 'event'"); - -eval { - $resolver->resolve( - event => "moo", - ); -}; -test_err($@, "resolve() must include a 'context'"); - -eval { - $resolver->resolve( - event => "moo", - context => "bar", - ); -}; -test_err($@, "resolve() must include a 'host'"); +{ + eval { + $poe_kernel->call( + "resolver", "resolve", { + } + ); + }; + my $err = $@; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "Must include an 'event' in Client::DNS request"); +} + +{ + eval { + $poe_kernel->call( + "resolver", "resolve", { + event => "moo", + } + ); + }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "Must include a 'context' in Client::DNS request"); +} + +{ + eval { + $poe_kernel->call( + "resolver", "resolve", { + event => "moo", + context => "bar", + } + ); + }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "Must include a 'host' in Client::DNS request"); +} + +{ + eval { + $resolver->resolve(1); + }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "resolve() needs an even number of parameters"); +} + +{ + eval { + $resolver->resolve(); + }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "resolve() must include an 'event'"); +} + +{ + eval { + $resolver->resolve( + event => "moo", + ); + }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "resolve() must include a 'context'"); +} + +{ + eval { + $resolver->resolve( + event => "moo", + context => "bar", + ); + }; + my $err = $@; + $err =~ s/ at \S+ line \d+.*//s; + is($err, "resolve() must include a 'host'"); +} + +exit; diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/05_api_4.t /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/05_api_4.t --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/05_api_4.t 2005-05-05 07:07:10.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/05_api_4.t 2006-05-21 22:43:20.000000000 +0200 @@ -1,9 +1,11 @@ #!/usr/bin/perl -w -# $Id: 05_api_4.t 40 2004-10-07 03:04:31Z rcaputo $ +# $Id: 05_api_4.t 56 2006-05-21 20:43:08Z rcaputo $ +# vim: filetype=perl # Test the version 3 API. use strict; +sub POE::Kernel::ASSERT_DEFAULT () { 1 } use POE qw(Component::Client::DNS); use Test::More tests => 4; @@ -15,6 +17,7 @@ POE::Session->create( inline_states => { _start => \&start_tests, + _stop => sub { }, # avoid assert problems response => \&got_response, } ); diff -Nru /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/06_hosts.t /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/06_hosts.t --- /tmp/CmM0ZHoSXf/libpoe-component-client-dns-perl-0.9802/t/06_hosts.t 2005-08-01 19:06:41.000000000 +0200 +++ /tmp/mwuOukjqNi/libpoe-component-client-dns-perl-0.99/t/06_hosts.t 2006-05-21 22:43:21.000000000 +0200 @@ -1,11 +1,12 @@ #!/usr/bin/perl -# $Id: 06_hosts.t 50 2005-08-01 17:06:41Z rcaputo $ +# $Id: 06_hosts.t 56 2006-05-21 20:43:08Z rcaputo $ # vim: filetype=perl # Test the hosts file stuff. use warnings; use strict; +sub POE::Kernel::ASSERT_DEFAULT () { 1 } use POE qw(Component::Client::DNS); use Test::More tests => 3; @@ -20,6 +21,7 @@ POE::Session->create( inline_states => { _start => \&start_tests, + _stop => sub { }, # avoid assert problems response_no_hosts => \&response_no_hosts, response_hosts_match => \&response_hosts_match, response_hosts_nomatch => \&response_hosts_nomatch, -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]