Danga::Socket::AnyEvent and fixing DNS issues

50 views
Skip to first unread message

Bron Gondwana

unread,
Oct 27, 2012, 3:37:23 PM10/27/12
to djab...@googlegroups.com
I notice that nobody ever followed up to the post from 3 years ago about an AnyEvent backend to Danga::Socket.

It seems the world of Perl is converging on AnyEvent as the preferred way of running evented code.  In particular you get things like this:

http://search.cpan.org/~mlehmann/AnyEvent-7.02/lib/AnyEvent/DNS.pm

A nice stable DNS implementation which we can just use, instead of

Djabberd::DNS

Which contains such gems as this:

    # FIXME: is this right?  right order and direction?
    my @targets = sort {
        $a->priority <=> $b->priority ||
        $a->weight   <=> $b->weight
    } grep { ref $_ eq "Net::DNS::RR::SRV" && $_->port } @ans;

To which the answer is "kinda yes, but it doesn't load balance correctly.

Even worse, it uses Net::DNS::Resolver->bgsend, which only queries the first nameserver in /etc/resolv.conf.  If that's not available, it silently fails.  I have just had production issues because of this, so I care!

So basically, I'd like to have access to AnyEvent.  I'm even wondering if we should perform enough surgery on DJabberd that Danga::Socket mainly goes away.  It was great for its time, but it doesn't offer anything which AnyEvent doesn't.

The alternative is fixing DNS another way, but I don't see the point in implementing another DNS library when AnyEvent's says this:

       AnyEvent::DNS::srv $service, $proto, $domain, $cb->(@srv_rr)
           Tries to resolve the given service, protocol and domain name into a list of service records.

           Each $srv_rr is an array reference with the following contents: "[$priority, $weight, $transport, $target]".

           They will be sorted with lowest priority first, then randomly distributed by weight as per RFC 2782.

Who wants to do that work again?

Bron ( I guess the real question is - since I expect to be doing all the work - is anyone looking to take DJabberd in any other direction, or wedded to keeping it how it is now... ? )

Mika Raento

unread,
Oct 28, 2012, 6:01:29 AM10/28/12
to djab...@googlegroups.com
Not exactly what you were looking for, but I did implement a slightly cleaner DNS lookup on top of Danga::Socket a few years ago. You can get it from


Doesn't support multiple servers, and only does A lookups but might be a reasonable place to start if you need something better than DJabberd::DNS.

   Mika

Martin Atkins

unread,
Oct 29, 2012, 11:21:11 AM10/29/12
to djab...@googlegroups.com

Bron,

In the longer term I agree that it would be better to port djabberd's
connection classes to AnyEvent rather than using my
Danga::Socket::AnyEvent shim, but that depends on whether anyone is
inspired by working on forward-thinking refactoring for djabberd. If you
are, then I'd say go for it!

As a data point, at Say Media we're using Danga::Socket::AnyEvent as the
event loop for a (relatively low-volume) perlbal deployment, and in the
process of getting that out we fixed a few bugs in it (fixed in 0.04)...
so although I still can't really speak to the performance of it, it does
at least seem to functionally work enough that Perlbal is happy with it,
so hopefully DJabberd would work too, as a short-term shim.
Reply all
Reply to author
Forward
0 new messages