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.
`#if FOO` (where FOO is undefined) is a legal construct in C89 and C99
but gcc, clang and sparse complain loudly about it at higher warning
levels.
Squelch those warnings. Makes the code more consistent as well.
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.
Introduced in 0db3274f but no longer necessary; uv__write() no longer
runs when the handle has been closed. Write callbacks receive a special
status code that informs them that the handle has been closed.
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.
Allows for running the event loop in 3 modes:
* default: loop runs until the refcount drops to zero
* once: poll for events only once and block until one is handled
* nowait: poll for events only once but don't block if there are
no pending events
Don't use the relaxed accept() algorithm introduced in be2a217 unless
explicitly requested. It causes a 50+% performance drop on some node.js
benchmarks:
$ alias bench='out/Release/node benchmark/http_simple_auto.js \
-c 10 -n 50000 bytes/1 2>&1 | grep Req'
$ UV_TCP_SINGLE_ACCEPT=0 bench
Requests per second: 12331.84 [#/sec] (mean)
$ UV_TCP_SINGLE_ACCEPT=1 bench
Requests per second: 3944.63 [#/sec] (mean)
File descriptor might be closed during callback, all events that was reported
before the callback are not valid and trying to remove them will result
in ENOENT. This error can be safely ignored.
Fix a rather obscure bug where the event loop stalls when an I/O watcher is
stopped while an artificial event, generated with uv__io_feed(), is pending.
Bert Belder informs me the current approach where a request is immediately
cancelled, is impossible to implement on Windows.
Rework the API to always invoke the "done" callback with an UV_ECANCELED error
code.
kqueue(2) on osx doesn't work (emits EINVAL error) with specific fds
(i.e. /dev/tty, /dev/null, etc). When given such descriptors - start
select(2) watcher thread that will emit io events.
Avoid the extra syscall, it's a no-op for non-listening sockets.
At least, it should be - it remains to be investigated if a FreeBSD kernel bug
affects ephemeral port allocation inside connect(). See [1] for details.
[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=174087
Running a make target that builds the shared object while overriding the CFLAGS
variable from the command line, would fail with a relocation error:
relocation R_X86_64_32 against `.text' can not be used when making a shared
object; recompile with -fPIC
Fix that by adding -fPIC unconditionally.
* If GetAdaptersAddresses() failed, it would return UV_OK nonetheless,
but the `adresses` and `count` out parameters would not be set.
* When adapters were enabled or added in between the two
GetAdaptersAddresses() calls, it would fail.
* In case of an out of memory situation, libuv would crash with a fatal
error.
* All interface information is now stored in a single heap-allocated
area.
* If GetAdaptersAddresses() failed, it would return UV_OK nonetheless,
but the `adresses` and `count` out parameters would not be set.
* When adapters were enabled or added in between the two
GetAdaptersAddresses() calls, it would fail.
* In case of an out of memory situation, libuv would crash with a fatal
error.
* All interface information is now stored in a single heap-allocated
area.