uv_guess_handle is currently squelching both fifo and all sockets on to the UV_NAMED_PIPE type. Rather than treating all sockets as UV_NAMED_PIPE, use getsockopt() and getsockaddr() to determine if the socket is an AF_UNIX stream (in which case return UV_NAMED_PIPE), or an AF_INET stream (in which case return UV_TCP), or an AF_INET datagram socket (in which case return UV_UDP). Additionally, currently all other file descriptor types are squelched to the UV_FILE type. Instead, only file descriptors that are marked as regular files are treated as UV_FILE. All other types (such as directories, character and block devices) are now treated as UV_UNKNOWN_HANDLE.
Replace `void f()` with `void f(void)`; the former means "a function that takes any number of arguments, including none" while the latter is what is actually intended: a function taking no arguments. The first form also isn't strictly conforming ANSI/ISO C.
Fixes a bug where timers expire prematurely when the following conditions hold: a) libuv first spends some time blocked in the platform poll function b) a callback then calls uv_timer_start() Cause: uv_timer_start() uses an out-of-date loop->time in its 'when should the timer callback run?' calculations. Solution: Update loop->time before invoking any callbacks. Fixes #678.
This commit renames the various uv_hrtime() implementations to uv__hrtime(). Libuv uses the high-res timer internally in performance-critical code paths. Calling the non-public version avoids going through the PLT when libuv is compiled as a shared object. The exported uv_hrtime() now has a single definition in src/unix/core.c that calls uv__hrtime(). A future optimization is to lift the uv__hrtime() declarations into header files so they can be inlined at the call sites. Then again, linking with -flto should accomplish the same thing.
Wake up the event loop with uv_async_send() when a request is cancelled. Ensures the done_cb is run on the next tick of the event loop. Not sending a wakeup signal results in the done_cb not getting called until another request completes, which may be a long time coming when it's the only request in the queue or when other requests are executing long-running jobs. Fixes #669.
A common way to check if a uv_fs_t request failed is to check that req->errorno != 0. With uv_fs_sendfile(), when the sendfile() syscall fails, req->errorno is set to (for example) ENOTSOCK, even when the emulation code path succeeds. Zero errno before the call to uv__fs_sendfile_emul() to prevent that from happening.