dns: fix c-ares error reporting regression
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 19 Sep 2013 04:38:37 +0000 (06:38 +0200)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Fri, 20 Sep 2013 16:39:14 +0000 (09:39 -0700)
commit03738183c74d0be43846f96562cb89dce929a953
tree2a88dc34872d54def1b7aa5220d0bed157a65626
parenta0f79867dcc4e58e0753af0644759025ad6e9749
dns: fix c-ares error reporting regression

The test case from the previous commit exposed a regression in the way
that c-ares errors are reported to JS land.  Said regression was
introduced in commit 756b622 ("src: add multi-context support").

Fixes the following test failure:

    $ out/Release/node test/simple/test-dns-regress-6244
    util.js:675
      var errname = uv.errname(err);
                       ^
    Error: err >= 0
        at Object.exports._errnoException (util.js:675:20)
        at errnoException (dns.js:43:15)
        at Object.onresolve [as oncomplete] (dns.js:145:19)

lib/dns.js erroneously assumed that the error code was a libuv error
code when it's really a c-ares status code.  Libuv handles getaddrinfo()
style lookups (which is by far the most common type of lookup), that's
why this bug wasn't discovered earlier.
lib/dns.js
src/cares_wrap.cc