c-ares: upgrade to 1.9.0
c-ares: libuv-ify c-ares
c-ares: ignore rogue DNS servers reported by windows
Revert "test: improve clean-up in test-fs-event"

There were too many errors in this commits; it totally broke on
Windows. Besides, when the moon is dark, the cleanup code could delete
some random files from my hard drive.

This reverts commit 7573f4a4c4072fe90b448fe748bf27e53bee1c30.
test: fix test-gethostbyname to not use a DNS server on localhost

Because, you know, not everybody has one.
Merge branch 'v0.8'
unix: move uv__connect() to tcp.c
unix: deduplicate socket creation code in tcp.c

Incidentally fixes a rather obscure bug where uv_tcp_connect() reconnected
and leaked a file descriptor when the handle was already busy connecting,
handle->fd was zero (unlikely) and uv_tcp_connect() got called again.
unix: fix EINPROGRESS busy loop

Don't make the event loop spin when connect() returns EINPROGRESS.

Test case:

  #include "uv.h"

  static void connect_cb(uv_connect_t* req, int status) {
    // ...
  }

  int main() {
    uv_tcp_t handle;
    uv_connect_t req;
    struct sockaddr_in addr;
    addr = uv_ip4_addr("8.8.8.8", 1234); // unreachable
    uv_tcp_init(uv_default_loop(), &handle);
    uv_tcp_connect(&req, (uv_stream_t*)&handle, addr, connect_cb);
    uv_run(uv_default_loop()); // busy loops until connection times out
    return 0;
  }

After EINPROGRESS, there are zero active handles and one active request. That
in turn makes uv__poll_timeout() believe that it should merely poll, not block,
in epoll() / kqueue() / port_getn().

Sidestep that by artificially starting the handle on connect() and stopping it
again once the TCP handshake completes / is rejected / times out.

It's a slightly hacky approach because I don't want to change the ABI of the
stable branch. I'll address it properly in the master branch.
test: add 'unexpected read' tcp test

Regression test that verifies that the event loop doesn't busy loop when
the server sends a message and the client isn't reading.
unix: fix busy loop on unexpected tcp message

Don't start reading immediately after connecting. If the server sends a message
and the client hasn't called uv_read_start() yet, the event loop will busy loop
because the pending message keeps waking it up.
unix: fix 'zero handles, one request' busy loop

Fixes #484.
unix: revert 0971598, obsoleted by 889ab21
bench: improve async_pummel benchmark

Benchmark the performance of uv_async_send() when the handle is contended for
by 1, 2, 4 or 8 threads.
unix: speed up uv_async_send() some more

Use atomic compare-and-swap to detect if we've been preempted by another thread
and therefore can avoid making the expensive write() syscall.

Speeds up the heavily contended case by about 1-2% and has little if any impact
on the non-contended case. I wasn't able to measure the difference at any rate.
unix: rename linux/core.c to linux/linux-core.c

This is a back-port of commit e1320757 from the master branch.

Newer versions of gyp do not support files with the same basenames (example:
core.c and linux/core.c).

The nominal reason is consistency across build systems. Apparently, msbuild
doesn't support it either.

Somewhere, someplace, baby Jesus cries sad little tears...

Fixes #464.
test: allow 80 ms intervals in hrtime test

The hrtimer functionality on my FreeBSD 9 system is fairly coarse, it's usually
just over the 60 ms that we tested for before this commit.
unix: fix memory corruption in freebsd.c
unix: speed up uv_async_send() some more still

__sync_val_compare_and_swap() emits a CMPXCHG instruction on i386 and x86_64.
Use XCHG instead, it's about four times faster.
test: add missing return statement