On 2006-03-15 09:33:03 -0500, Matt Sergeant wrote:
> On 14-Mar-06, at 5:50 PM, Peter J. Holzer wrote:
> >>There is code in trunk to deal with this specific issue, around  
> >>line 124
> >>of ~/qpsmtpd, where the _fork subroutine is defined.
> >
> >You are right. But I don't understand it:
[...]
> >which version of Net::DNS has a variable %Net::DNS::Resolver::global?
> >Neither 0.48 nor 0.57 seem to have it. Is this for some old version
> >or a new one which hasn't been released yet?
> 
> Old version IIRC. The newer versions of Net::DNS didn't require any  
> work on this as they fixed this bug.

I don't think so. I can still see the bug with 0.57 (which is
the current version according to CPAN and net-dns.org)

Here is a script to demonstrate it:

#!/usr/bin/perl
use warnings;
use strict;
use Net::DNS;
use Net::DNS::Header;

my $inc_id = 0;

for (1 .. 10) {
    if (my $pid = fork()) {
        waitpid($pid, 0);
        sleep(3);
    } else {
        print "--------------------------------\n";
        print "pid: $$\n";
        print "\n";
        if ($inc_id) {
            srand();
            for (0 .. rand(65536)) {
                Net::DNS::Header::nextid();
            }
        }
        my $res = Net::DNS::Resolver->new;
        my $answer = $res->query('wsr.ac.at', 'MX');
        #$answer->print;
        $answer->header->print;
        sleep(1);
        $answer = $res->query('hjp.at', 'MX');
        #$answer->print;
        $answer->header->print;
        print "\n";
        print "\n";
        exit(0);
    }
}

It forks off 10 child processes, performs two queries in each and prints
the header of the replies. On my systems the IDs are always the same for
all child processes.

The section in «if ($inc_id) { ... }» is my proposed workaround.

        hp

-- 
   _  | Peter J. Holzer    | Ich sehe nun ein, dass Computer wenig
|_|_) | Sysadmin WSR       | geeignet sind, um sich was zu merken.
| |   | [EMAIL PROTECTED]         |
__/   | http://www.hjp.at/ |    -- Holger Lembke in dan-am

Attachment: pgpIh2EGWw2fK.pgp
Description: PGP signature

Reply via email to