unix: clear UV_STREAM_SHUTTING after shutdown()

Fix a state machine buglet where the UV_STREAM_SHUTTING flag didn't get
cleared.
unix: fix busy loop, write if POLLERR or POLLHUP

This fixes a busy loop by working around a quirk with Linux kernels
<= 2.6.32 where an EPIPE or ECONNRESET error on a file descriptor that
is polled for EPOLLOUT but not EPOLLIN gets reported by epoll_wait() as
just EPOLLERR|EPOLLHUP, like this:

  epoll_wait(5, {{EPOLLERR|EPOLLHUP, {u32=12, u64=12}}}, 1024, 433) = 1

Before this commit, libuv called uv__read() which attempts to read from
the file descriptor.  With newer kernels and on other operating systems
that fails like this:

  read(12, "", 65536)         = -1 EPIPE (Broken pipe)

Which tells libuv there is a connection error and it should notify the
user of that.  On the affected Linux kernels however, the read succeeds
with an EOF:

  read(12, "", 65536)         = 0

Which is subsequently passed on to the user. In most cases, the user
will close the handle and everything is fine.

Node.js however sometimes keeps the handle open in an attempt to flush
pending write requests.  While libuv doesn't officially support this,
unofficially it works...

...except on those older kernels.  Because the kernel keeps waking up
the event loop without setting POLLOUT and because the read calls EOF
but don't error, libuv's I/O state machine doesn't progress.

That's why this commit changes uv__stream_io() to also write pending
data.  While the read() system call doesn't error, the write() system
call will.

Fixes joyent/node#5504.
2013.06.13, Version 0.10.11 (Stable)

Changes since version 0.10.10:

* unix: unconditionally stop handle on close (Ben Noordhuis)

* freebsd: don't enable dtrace if it's not available (Brian White)

* build: make HAVE_DTRACE=0 should disable dtrace (Timothy J. Fontaine)

* unix: remove overzealous assert (Ben Noordhuis)

* unix: clear UV_STREAM_SHUTTING after shutdown() (Ben Noordhuis)

* unix: fix busy loop, write if POLLERR or POLLHUP (Ben Noordhuis)
Now working on v0.10.12
Merge remote-tracking branch 'origin/v0.10'

Conflicts:
	src/unix/stream.c
	src/version.c
linux: add support for MIPS
Merge remote-tracking branch 'origin/v0.10'
queue: fix pointer truncation on LLP64 platforms

QUEUE_DATA used to cast a pointer to long and back to pointer. This can
corrupt pointers on systems where the long type isn't large enough to
store pointer, like Windows x64. This commit fixes that.

Fixes #835
build: set OS=="android" for android builds

Work around the build name issues by instead manually adding the build
target for android builds using '-DOS=android'

This additionally resolves problems caused by the OS variable being
rewritten from "android" to "linux" in gyp. This causes errors, as
real-time support (-lrt) and pthread support (-lpthread) is not
available in the android NDK toolchain as libraries.

The functions present in these libraries are included automatically
during the build instead during the android compilation process.
windows: don't use uppercase in include filename

Change <Winsock2.h> to <winsock2.h>. The former breaks
cross-compilation with mingw.
test: open stdout fd in write-only mode

Fixes #771.
windows: uv_spawn shouldn't reject reparse points

This fixes an issue where uv_spawn would not try to run a reparse point,
and continue to scan the PATH instead. Effectively, it was impossible to
spawn a symlinked binary. This commit fixes that.

Also see #748
stream: add an API to make streams do blocking writes

This patch adds the `uv_stream_set_blocking` API which makes all
uv_write calls to that stream blocking. It currently only works for
pipes, on windows.
windows: use WSAGetLastError(), not errno

setsockopt() doesn't touch errno on failure. Use WSAGetLastError()
instead.
windows: use WSAGetLastError(), not errno

setsockopt() doesn't touch errno on failure. Use WSAGetLastError()
instead.

This is a back-port of commit 30a8b44 from the master branch.
build: darwin: disable -fstrict-aliasing warnings

gcc 4.2.1 as shipped with Xcode complains incessantly about aliasing
warnings, which, while technically true, disregards the fact that the
aliased types have the same layout in memory. Squelch the warnings.
test: fix signed/unsigned compiler warning
test: add 'start timer from check handle' test

Check that a timer that is started from a check handle gets picked up
correctly, i.e. that it influences the timeout used in the next tick
of the event loop.
build: `all` now builds static and dynamic lib

The `make all` target now builds both libuv.a and libuv.{so,dylib}
rather than just libuv.a.
2013.06.27, Version 0.11.5 (Unstable)

Changes since version 0.11.4:

* build: remove CSTDFLAG, use only CFLAGS (Ben Noordhuis)

* unix: support for android builds (Linus Mårtensson)

* unix: avoid extra read, short-circuit on POLLHUP (Ben Noordhuis)

* uv: support android libuv standalone build (Linus Mårtensson)

* src: make queue.h c++ compatible (Ben Noordhuis)

* unix: s/ngx-queue.h/queue.h/ in checksparse.sh (Ben Noordhuis)

* unix: unconditionally stop handle on close (Ben Noordhuis)

* freebsd: don't enable dtrace if it's not available (Brian White)

* build: make HAVE_DTRACE=0 should disable dtrace (Timothy J. Fontaine)

* unix: remove overzealous assert (Ben Noordhuis)

* unix: remove unused function uv_fatal_error() (Ben Noordhuis)

* unix, windows: clean up uv_thread_create() (Ben Noordhuis)

* queue: fix pointer truncation on LLP64 platforms (Bert Belder)

* build: set OS=="android" for android builds (Linus Mårtensson)

* windows: don't use uppercase in include filename (Ben Noordhuis)

* stream: add an API to make streams do blocking writes (Henry Rawas)

* windows: use WSAGetLastError(), not errno (Ben Noordhuis)