Now working on v0.10.22
windows: avoid assertion failure when pipe server is closed

When a pipe server is closed, all pending accept requests and their
associated HANDLEs are closed to force windows to cancel the
ConnectNamedPipe IRP. The returned request has the `pipeHandle` field
set to INVALID_HANDLE_VALUE, which trips an assert in
uv_pipe_process_accept_req. This patch fixes that.
code style: strip trailing whitespace
test: add pipe-server-close test

Add a regression test for the pipe server close issue on Windows, which
was reported in joyent/node#6749 and fixed in 7b16a3f.
test: make test-pipe-server-close pass on linux

When a server and a client are both part of the same event loop, and
the client connects to the server, the order in which the connect
callback and the connection callback are called is unspecified.
Apparently on linux the connection callback sometimes happens first,
which is not a bug, and should not make this test fail.
osx: Fix a possible segfault in uv__io_poll

In our build infrastructure, I've seen a lot of segfaults recently that
were all only happening on OSX. Upon inspecting the coredumps, it
appearded that all segfaults happened at the same instruction, and upon
translating the assembly back to the source, I found that an array could
be indexed with a -1 index before the index was checked to be not -1.

As concrete evidence, here is the situation that I found caused the
segfault.  The instruction in question along with the relevant register
values was:

    mov    (%r8,%r15,8),%r12

    r8  = 0x7fb0ba800000
    r15 = 0xffffffffffffffff

    r8 + r15 * 8 == 0x7fb0ba7ffff8

It appears that the base of loop->watchers was page aligned, and by
going back one word I guess that the page wasn't mapped, causing our
segfaults.
2014.01.08, Version 0.10.22 (Stable)

Changes since version 0.10.21:

* windows: avoid assertion failure when pipe server is closed (Bert
  Belder)
Now working on v0.10.23
linux: relax assumption on /proc/stat parsing

CPU entries in /proc/stat are not guaranteed to be monotonically
increasing, asserting on this assumption can break in cases such
as the UltraSparc II machine shown in #1080.

Signed-off-by: Luca Bruno <lucab@debian.org>
openbsd: fix obvious bug in uv_cpu_info

`int which[]` should not be static here, as the function itself is
changing it

fix joyent/node#6878
process: close stdio after dup2'ing it

Thus allow passing the same file descriptor as the source of multiple
stdios.

Committed with the help and code parts from:

  * Sam Roberts <sam@strongloop.com>

fix #1074
2014.01.23, Version 0.10.23 (Stable)

Changes since version 0.10.22:

* linux: relax assumption on /proc/stat parsing (Luca Bruno)

* openbsd: fix obvious bug in uv_cpu_info (Fedor Indutny)

* process: close stdio after dup2'ing it (Fedor Indutny)
Now working on v0.10.24
linux: move sscanf() out of the assert()

If asserts are turned off then the sscanf() wouldn't have run, being
placed directly in the assert() itself.
linux: fix C99/C++ comment
2014.01.30, Version 0.10.24 (Stable)

Changes since version 0.10.23:

* linux: move sscanf() out of the assert() (Trevor Norris)

* linux: fix C99/C++ comment (Fedor Indutny)
Now working on v0.10.25
stream: start thread after assignments

Changed the order of the member assignments since the thread
may start before the parameters are assigned. This especially
happens when the osx scheduler is very busy.
unix: correct error when calling uv_shutdown twice

This is a backport of a284b90 for v0.10 branch
windows: freeze in uv_tcp_endgame

The event_handle field of unused accept requests was not being
initialized properly. As a result, uv_tcp_endgame would try to close
an invalid handle and this could lead to unexpected behavior.

This fixes node.js test test-cluster-disconnect.js on Windows.