Commit Graph

114 Commits

Author SHA1 Message Date
yiyuaner
8635170d8f
linux-core: add proper divide by zero assert
PR-URL: https://github.com/libuv/libuv/pull/3166
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2021-05-12 18:41:30 -04:00
Santiago Gimeno
0101affb68
unix: fix uv_uptime() regression
As it was in the original version of
https://github.com/libuv/libuv/pull/3072, `%lf` must be used in
`sscanf()` as the value is being stored in a `double` and not a `float`.

PR-URL: https://github.com/libuv/libuv/pull/3080
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-12-30 13:13:58 +01:00
schamberg97
b2ccbbb8a4
unix: fix uv_uptime() on linux
First check `/proc/uptime`, then fallback to `clock_gettime()`.

Fixes: https://github.com/libuv/libuv/issues/3068
PR-URL: https://github.com/libuv/libuv/pull/3072
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2020-12-28 12:18:55 +01:00
Daniel Bevenius
f4af7ff2d4
src: suppress user_timeout maybe-uninitialized
This commit initializes user_timeout in uv__io_poll to avoid a
maybe-uninitialized warning:

$ cmake .. -DCMAKE_C_FLAGS="-Wmaybe-uninitialized -O3"
...
[ 14%] Building C object CMakeFiles/uv.dir/src/unix/tty.c.o
/libuv/libuv/src/unix/linux-core.c: In function ‘uv__io_poll’:
/libuv/libuv/src/unix/linux-core.c:351:10: warning:
‘user_timeout’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
  351 |       if (timeout == -1)
      |          ^

PR-URL: https://github.com/libuv/libuv/pull/2976
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-09-20 11:33:31 -04:00
Trevor Norris
e8effd4556 core: add API to measure event loop idle time
The API addition `uv_metrics_idle_time()` is a thread safe call that
allows the user to retrieve the amount of time the event loop has spent
in the kernel's event provider (i.e. poll). It was done this way to
allow retrieving this value without needing to interrupt the execution
of the event loop. This option can be enabled by passing
`UV_METRICS_IDLE_TIME` to `uv_loop_configure()`.

One important aspect of this change is, when enabled, to always first
call the event provider with a `timeout == 0`. This allows libuv to know
whether any events were waiting in the event queue when the event
provider was called. The importance of this is because libuv is tracking
the amount of "idle time", not "poll time". Thus the provider entry time
is not recorded when `timeout == 0` (the event provider never idles in
this case).

While this does add a small amount of overhead, when enabled, but the
overhead decreases when the event loop has a heavier load. This is
because poll events will be waiting when the event provider is called.
Thus never actually recording the provider entry time.

Checking if `uv_loop_t` is configured with `UV_METRICS_IDLE_TIME` always
happens in `uv__metrics_set_provider_entry_time()` and
`uv__metrics_update_idle_time()`. Making the conditional logic wrapping
each call simpler and allows for instrumentation to always hook into
those two function calls.

Rather than placing the fields directly on `uv__loop_internal_fields_t`
add the struct `uv__loop_metrics_t` as a location for future metrics API
additions.

Tests and additional documentation has been included.

PR-URL: https://github.com/libuv/libuv/pull/2725
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 10:31:42 -04:00
Ben Noordhuis
10a9c25a12 unix: use relaxed loads/stores for clock id
This was part of commit c70dd705 ("unix: use relaxed loads/stores for
feature checks") and was reviewed as such but I accidentally dropped
it in the rebase before the final merge.

Fixes: https://github.com/libuv/libuv/issues/2884
PR-URL: https://github.com/libuv/libuv/pull/2886
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-07-10 10:10:00 +02:00
Ben Noordhuis
c70dd705bc unix: use relaxed loads/stores for feature checks
Make ThreadSanitizer stop complaining about the static variables that
libuv uses to record the presence (or lack) of system calls and other
kernel features.

Fixes: https://github.com/libuv/libuv/issues/2884
PR-URL: https://github.com/libuv/libuv/pull/2886
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-06-16 11:42:51 +02:00
gengjiawen
e50b631daf android: remove patch code for below 21
PR-URL: https://github.com/libuv/libuv/pull/2880
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-06-12 12:22:06 +02:00
Ben Noordhuis
1c22b44380 linux: read load average from /proc/loadavg
It was reported that uv_loadavg() reports the wrong values inside an
lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/loadavg
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/loadavg first and fall back to
sysinfo(2) in case /proc isn't mounted.

This commit is very similar to commit 3a1be725 ("linux: read free/total
memory from /proc/meminfo") from April 2019.

Fixes: https://github.com/nodejs/node/issues/33791
PR-URL: https://github.com/libuv/libuv/pull/2876
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-06-12 12:17:33 +02:00
Ben Noordhuis
1a89003635 linux: refactor /proc file reader logic
Move common logic into a separate function that will be reused in a
follow-up commit. This commit also adds a minor correctness fix in
that the `read(2)` system call is now retried on `EINTR`.

PR-URL: https://github.com/libuv/libuv/pull/2876
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-06-12 12:17:21 +02:00
James Ross
37a8affbd3 linux: make cpu_times consistently be milliseconds
On Linux, cpu_times have been calculated differently to all other
platforms for a while. Other platforms (FreeBSD, Mac, Windows) are all
in milliseconds, but Linux has been returning values ten times larger.

libuv has not previously documented what unit cpu_times uses, even
though NodeJS did - as milliseconds.

Here we're both documenting that the cpu_times are indeed in
milliseconds, and fixing the inconsistency on Linux.

Fixes: https://github.com/libuv/libuv/issues/2773
PR-URL: https://github.com/libuv/libuv/pull/2796
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-22 10:46:07 +02:00
Anna Henningsen
02e7a78628
unix: handle uv__open_cloexec return value correctly
`uv__open_cloexec()` already returns a libuv error code in case
of failure, and not `-1` like syscalls do.

Fixes: https://github.com/nodejs/help/issues/2099
PR-URL: https://github.com/libuv/libuv/pull/2645
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-01-21 20:02:56 +01:00
Ben Noordhuis
5cb8860b45 unix: suppress -Waddress-of-packed-member warning
Fixes: https://github.com/libuv/libuv/issues/2418
PR-URL: https://github.com/libuv/libuv/pull/2584
Refs: https://github.com/libuv/libuv/pull/2580
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-12-30 18:25:11 +01:00
Yang Yu
e2c0f60c10 build: fix build error with __ANDROID_API__ < 21
Fix the following undefined symbols error with __ANDROID_API__ < 21:
- epoll_create1
- epoll_pwait
- futimens
2019-09-16 11:16:56 +02:00
Yang Yu
3bff0d3878 Revert "linux: drop code path for epoll_pwait-less kernels"
This reverts commit f43c663433.
2019-09-16 11:16:56 +02:00
Santiago Gimeno
040543eebf
src: move uv_free_cpu_info to uv-common.c
PR-URL: https://github.com/libuv/libuv/pull/2433
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-19 23:01:17 +02:00
Ben Noordhuis
d7f0055b80
linux: fix sscanf() overflows reading from /proc
Use `"%" PRIu64` and uint64_t for sscanf-ing large values, not `"%lu"`
and unsigned long. The latter can overflow when libuv is a 32 bits
application running on a 64 bits machine.

Fixes: https://github.com/libuv/libuv/issues/2297
PR-URL: https://github.com/libuv/libuv/pull/2305
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-21 09:02:15 -04:00
Kelvin Jin
c4e9657d59
unix,win: add uv_get_constrained_memory()
Fixes: https://github.com/libuv/libuv/issues/2286
PR-URL: https://github.com/libuv/libuv/pull/2289
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-15 11:35:05 -04:00
Santiago Gimeno
8b87533863
linux: set correct mac address for IP-aliases
IP-alias format is the interface name followed by a colon and a string
(usually a number). Set the physical address to the one in the 'base'
interface.

PR-URL: https://github.com/libuv/libuv/pull/2248
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-26 20:04:16 +02:00
Ben Noordhuis
3a1be72532 linux: read free/total memory from /proc/meminfo
It was reported that uv_get_free_memory() and uv_get_total_memory()
report the wrong values inside an lxc container.

Libuv calls sysinfo(2) but that isn't intercepted by lxc. /proc/meminfo
however is because /proc is a FUSE fs inside the container.

This commit makes libuv try /proc/meminfo first and fall back to
sysinfo(2) in case /proc isn't mounted.

Fixes: https://github.com/libuv/libuv/issues/2249
PR-URL: https://github.com/libuv/libuv/pull/2258
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-23 11:49:37 +02:00
Ben Noordhuis
ab5859129b linux: use O_CLOEXEC instead of EPOLL_CLOEXEC
It was reported that EPOLL_CLOEXEC is not defined on Android API < 21,
a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all
architectures, we just use that instead.

Fixes: https://github.com/libuv/libuv/issues/2167
PR-URL: https://github.com/libuv/libuv/pull/2272
Refs: https://github.com/libuv/libuv/pull/2216
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-23 10:45:28 +02:00
Andreas Rohner
d0fb86cdf3
unix: fix uv_interface_addresses()
The memset() in the inner loop clears previously copied phys_addrs. As a
result, every interface is reported to have a phys_addr of
00:00:00:00:00:00, except the last one. This bug only manifests on
systems with multiple interfaces.

PR-URL: https://github.com/libuv/libuv/pull/2153
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2019-04-10 06:52:11 +02:00
Ben Noordhuis
1ce6393a57
unix: don't attempt to invalidate invalid fd
Add a missing check in uv__io_close() where it called
uv__platform_invalidate_fd() without checking that the
watcher actually has a valid file descriptor assigned.

Fixes: https://github.com/libuv/libuv/issues/2181
PR-URL: https://github.com/libuv/libuv/pull/2182
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-10 10:11:19 -05:00
Ashe Connor
0813f5b97a
unix: zero epoll_event before use
Valgrind will emit the following error on a system where `int` is 32
bits:

==21616== Syscall param epoll_ctl(event) points to uninitialised byte(s)
==21616==    at 0x693E06A: epoll_ctl (syscall-template.S:84)
==21616==    by 0x529F35B: uv__io_poll (in .../libuv/libuv.so)
==21616==    by 0x528AE62: uv_run (in .../libuv/libuv.so)
[...]
==21616==  Address 0x1ffeffc8ec is on thread 1's stack
==21616==  in frame #1, created by uv__io_poll (???:)

We only initialise e.events and e.data.fd, meaning half of
e.data (the 32 bits not covered by the 4-byte `fd`) is
uninitialised.

PR-URL: https://github.com/libuv/libuv/pull/1996
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-11-20 22:01:35 -05:00
cjihrig
6e23a36603
unix: remove unnecessary linebreaks
As a requested style nit, remove two unnecessary line breaks.

PR-URL: https://github.com/libuv/libuv/pull/2039
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-10-15 14:51:11 -04:00
cjihrig
5fb9517200
unix,win: make uv_interface_addresses() consistent
This commit does a few things to make the function more
consistent across platforms:

- Initialize the output parameters before everything else.
- Return early if there are no interfaces instead of performing
  zero-sized allocations.
- Add a missing memory deallocation.

Refs: https://github.com/libuv/libuv/pull/2035
PR-URL: https://github.com/libuv/libuv/pull/2039
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-10-15 14:49:13 -04:00
cjihrig
69e4af1577
unix: restore skipping of phys_addr copy
Prior to https://github.com/libuv/libuv/pull/1999,
uv_interface_addresses() did not populate the phys_addr field on
Cygwin or MinGW. This commit restores that behavior, which was
mistakenly changed.

Fixes: https://github.com/libuv/libuv/issues/2034
PR-URL: https://github.com/libuv/libuv/pull/2035
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-15 14:33:34 -04:00
cjihrig
3dc0f53965
unix: initialize uv_interface_address_t.phys_addr
This commit ensures that the memory of the phys_addr field is
initialized on all platforms.

Fixes: https://github.com/nodejs/node/issues/23043
PR-URL: https://github.com/libuv/libuv/pull/1999
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-09-25 09:40:22 -04:00
Ben Noordhuis
f43c663433 linux: drop code path for epoll_pwait-less kernels
Remove the support for kernels that don't support epoll_pwait()
now that the minimum requirements are kernel 2.6.32 + glibc 2.12.

PR-URL: https://github.com/libuv/libuv/pull/1372
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-06 13:07:42 +02:00
Ben Noordhuis
9208df0c93 linux: remove epoll syscall wrappers
Remove the syscalls wrappers now that the minimum requirements are
kernel 2.6.32 + glibc 2.12.

This commit should fix the epoll_pwait()-related issues that have
been reported against mips/mipsel builds.

Fixes: https://github.com/libuv/libuv/issues/335
PR-URL: https://github.com/libuv/libuv/pull/1372
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-09-06 13:07:13 +02:00
Brad King
06cb00c84f
linux: handle exclusive POLLHUP with UV_DISCONNECT
In commit c7c8e916b8 (poll: add UV_DISCONNECT event, 2016-01-11) we
forgot to update the workaround added by commit 24bfef2ef4 (linux:
handle EPOLLHUP without EPOLLIN/EPOLLOUT, 2013-11-08).  On
linux-sparc64, epoll returns just POLLHUP during part of our
`poll_duplex` and `poll_unidirectional` tests, triggering the need for
the workaround to recognize UV_DISCONNECT.

Fixes: https://github.com/libuv/libuv/issues/1859
PR-URL: https://github.com/libuv/libuv/pull/1896
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-19 09:00:00 -04:00
Saúl Ibarra Corretgé
99ae3edf28 core: move all include files except uv.h to uv/
This is a cherry-pick of commit d010030ad5 from the master branch.

Conflicts:
 	Makefile.am
 	include/uv.h
 	include/uv/unix.h
 	libuv.nsi (deleted)
 	src/unix/pthread-barrier.c (deleted)

PR-URL: https://github.com/libuv/libuv/pull/1850
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-14 18:39:32 +02:00
Mason X
89cbbc895b
include,src: introduce UV__ERR() macro
Using -errno, -E**, and -pthread_function() can be
error prone, and breaks compatibility with some operating
systems that already negate errno's (e.g. Haiku).

This commit adds a UV__ERR() macro that ensures libuv
errors are negative.

Fixes: https://github.com/libuv/help/issues/39
PR-URL: https://github.com/libuv/libuv/pull/1687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-02-08 22:38:02 -05:00
XadillaX
f1e0fc43d1 unix: fix wrong MAC of uv_interface_address
fix a wrong `if` in `uv_interface_address` about MAC.

Fixes: https://github.com/nodejs/node/issues/13581
PR-URL: https://github.com/libuv/libuv/pull/1375
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-07-17 13:34:02 +02:00
CurlyMoo
d731fd1bd9 poll: add support for OOB TCP and GPIO interrupts
Out-of-band TCP messages are used for TCP data
transmission outside (outband) the inbound TCP
data. These packets are sent with an
"urgent pointer", but previously discarded.

Additionally, when using (e)poll a POLLPRI is
triggered when an interrupt signal is received
on GPIO capable systems such as the Raspberry Pi.

PR-URL: https://github.com/libuv/libuv/pull/1040
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-07-12 23:04:34 +02:00
Brad King
77326e86a2 unix: factor out reusable procfs exepath impl
On Linux we read `/proc/self/exe` for the path to the executable.
Factor out a dedicated source file to make this implementation
available for use on other platforms that support it.

PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:12:18 +02:00
Brad King
76bcf9f91d unix: factor out reusable sysinfo loadavg impl
On Linux we use `sysinfo(2)` to look up the load average.
Factor out a dedicated source file to make this implementation
available for use on other platforms that support it.

PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:12:16 +02:00
Brad King
ea795b29ef unix: factor out reusable sysinfo memory lookup
On Linux we use `sysinfo(2)` to look up available memory.
Factor out a dedicated source file to make this implementation
available for use on other platforms that support it.

PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:12:14 +02:00
Jason Madden
fd7ce57f2b unix: make loops and watchers usable after fork()
Added the uv_loop_fork() API that must be called in a child process to
continue using an existing loop. Internally this calls a uv__io_fork
function for each supported platform, similar to the way
uv__platform_loop_init works.

After this call, existing and new IO, async and signal watchers will
contiue working as before on all platforms, as will the
threadpool (although any threads it was using are of course gone).

On Linux and BSDs that use kqueue, existing and new fsevent watchers
will also continue to work as expected. On OS X, though, directory
fsevents will not be able to use the optimized CoreFoundation path if
they had already been used in the parent process, instead falling back
to the kqueue path used on other BSDs.

Existing fsevent watchers will not function on AIX or SunOS. This
could be relatively easily fixed by someone with AIX knowledge in the
future, but SunOS will require some additional work to keep track if
the watchers.

A new test file, test/test-fork.c, was added to contain fork-related
tests to verify functionality in the child process.

PR-URL: https://github.com/libuv/libuv/pull/846
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-03-21 12:23:44 +01:00
Brad King
0f84c305e0 unix: factor out getifaddrs result filter
On platforms using getifaddrs we iterate over the interfaces two or
three times.  First we count them, then we enumerate them, and then we
fill in physical addresses.  Each loop needs to do the same filtering,
so factor out the exclusion test into a helper function for each
platform.

PR-URL: https://github.com/libuv/libuv/pull/1240
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-03-14 08:33:28 +01:00
Ben Noordhuis
70002c80bf linux: fix potential event loop stall
It was pointed out[0] that libuv could effectively enter an infinite
loop (but not a busy loop) under certain conditions when polling for
events:

1. When the architecture is 32 bits, and
2. When timeout > 0, i.e., finite, and
3. When timeout > max_safe_timeout (~30 minutes), and
4. When epoll_wait(timeout) returns 0, then
5. timeout was not properly updated on the next call to epoll_wait().

Inspection of the code uncovered a secondary bug where under a similar
set of circumstances the timeout could drift when the epoll_wait()
system call returned late.

[0] https://github.com/libuv/libuv/pull/354#discussion_r67837112

PR-URL: https://github.com/libuv/libuv/pull/922
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-07-04 19:10:12 +02:00
Nicolas Cavallari
c4e917790e linux-core: fix uv_get_total/free_memory on uclibc
The _SC_PHYS_PAGES and _SC_AVPHYS_PAGES are not POSIX sysconf values, so
the standart C libraries have no obligation to support it, even on
Linux.  Use the Linux sysinfo() system call instead.

PR-URL: https://github.com/libuv/libuv/pull/901
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-06-09 22:05:45 +02:00
Ben Noordhuis
4a5b3f982e unix: delay signal handling until after normal i/o
It was reported that some node.js tests fail on AIX because the exit
event sometimes comes before the final stdio output of a child process.

Work around that by deferring the signal watcher that is used for
process management until after the dispatch of regular i/o watchers.

Fixes: https://github.com/libuv/libuv/issues/610
PR-URL: https://github.com/libuv/libuv/pull/611
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-04-15 12:04:57 +02:00
Ben Noordhuis
60ef1e7f13 linux: fix long lines in linux-core.c
Introduced in commit 6798876a, "linux: fix cpu count".

PR-URL: https://github.com/libuv/libuv/pull/822
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-12 21:21:56 +02:00
Ben Noordhuis
732fb03ac6 linux: don't abort on malformed /proc/stat
Return an error instead of aborting when /proc/stat doesn't have the
expected format.

PR-URL: https://github.com/libuv/libuv/pull/822
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-12 21:21:55 +02:00
Ben Noordhuis
2bf7b3855c linux: fix fd leaks in uv_cpu_info() error paths
Introduced in commit 6798876a, "linux: fix cpu count".

PR-URL: https://github.com/libuv/libuv/pull/822
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-12 21:21:37 +02:00
Ben Noordhuis
375ba2d76d unix: use POLL{IN,OUT,etc} constants directly
Remove the UV__POLL defines and use POLL{IN,OUT,etc} directly.
On Linux, we lean on the fact that the POLL constants correspond
one-to-one to their EPOLL counterparts.

Fixes: https://github.com/libuv/libuv/issues/816
PR-URL: https://github.com/libuv/libuv/pull/817
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-04-11 10:51:13 +02:00
Krishnaraj Bhat
365bdec434 linux: remove redundant call to rewind()
It's already called in callee read_times()

PR-URL: https://github.com/libuv/libuv/pull/751
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-08 09:12:40 +01:00
Kári Tristan Helgason
2f02ae5f51 linux: replace calls to fopen with uv__open_file
PR-URL: https://github.com/libuv/libuv/pull/743
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-08 09:10:56 +01:00
Kári Tristan Helgason
80d9d86e0f linux: add braces to multi-statement if
PR-URL: https://github.com/libuv/libuv/pull/750
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-05 00:30:25 +01:00