Commit Graph

229 Commits

Author SHA1 Message Date
Andrew Paprocki
f62240b2d1
sunos: disable __attribute__((unused))
The Studio compiler prints out a warning when this attribute is used
because it does not support it (at least as of the latest 12.6 version):
https://docs.oracle.com/cd/E77782_01/html/E77788/gjzke.html#scrolltoc

PR-URL: https://github.com/libuv/libuv/pull/2200
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-16 13:20:40 -04:00
Santiago Gimeno
d16897c493
unix: refactor getsockname/getpeername methods
PR-URL: https://github.com/libuv/libuv/pull/1872
Backport-PR-URL: https://github.com/libuv/libuv/pull/2217
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-16 12:05:23 -04:00
Jameson Nash
2d2af382ce fsevents: really watch files with fsevents on macos 10.7+
In the original PR, the ifdef conditional was reversed,
leading to the old code-path still being used.
This also reduces some of the redundancy in the conditional checks,
by factoring out the common test.
And fixes a divergence in functionality kFSEventsRenamed =>
kFSEventStreamEventFlagItemRenamed
And actually includes the part of the original PR to kqueue that enabled
watching files with fsevents!

Fixes: https://github.com/libuv/libuv/pull/387
PR-URL: https://github.com/libuv/libuv/pull/2082
Refs: https://github.com/libuv/libuv/pull/1572
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-04 13:14:10 -05:00
Jameson Nash
f4a06a095c 2018.11.14, Version 1.24.0 (Stable)
Changes since version 1.23.2:
 
 * unix: do not require PATH_MAX to be defined (Brad King)
 
 * win,doc: path encoding in uv_fs_XX is UTF-8 (hitesh)
 
 * unix: add missing link dependency on kFreeBSD (Svante Signell)
 
 * unix: add support for GNU/Hurd (Samuel Thibault)
 
 * test: avoid memory leak for test_output (Carlo Marcelo Arenas Belón)
 
 * zos: avoid UB with NULL pointer arithmetic (Carlo Marcelo Arenas Belón)
 
 * doc: add vtjnash to maintainers (Jameson Nash)
 
 * unix: restore skipping of phys_addr copy (cjihrig)
 
 * unix,win: make uv_interface_addresses() consistent (cjihrig)
 
 * unix: remove unnecessary linebreaks (cjihrig)
 
 * unix,win: handle zero-sized allocations uniformly (Ben Noordhuis)
 
 * unix: remove unused uv__dup() function (Ben Noordhuis)
 
 * core,bsd: refactor process_title functions (Santiago Gimeno)
 
 * win: Redefine NSIG to consider SIGWINCH (Jeremy Studer)
 
 * test: make sure that reading a directory fails (Sakthipriyan Vairamani)
 
 * win, tty: remove zero-size read callbacks (Bartosz Sosnowski)
 
 * test: fix test runner getenv async-signal-safety (Ben Noordhuis)
 
 * test: fix test runner execvp async-signal-safety (Ben Noordhuis)
 
 * test,unix: fix race in test runner (Ben Noordhuis)
 
 * unix,win: support IDNA 2008 in uv_getaddrinfo() (Ben Noordhuis)
 
 * win, tcp: avoid starving the loop (Bartosz Sosnowski)
 
 * win, dl: proper error messages on some systems (Bartosz Sosnowski)
 
 * win,fs: retry if uv_fs_rename fails (Bartosz Sosnowski)
 
 * darwin: speed up uv_set_process_title() (Ben Noordhuis)
 
 * aix: fix race in uv_get_process_title() (Gireesh Punathil)
 
 * win: support more fine-grained windows hiding (Bartosz Sosnowski)
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - https://gpgtools.org
 
 iQIzBAABCgAdFiEElK42Z1xGTWS6+mjddDQ5C9vpucUFAlvqWTsACgkQdDQ5C9vp
 ucX3ug//b4BUrqkohyhH5bjTbdlk4GVLJYhDYS2ZVUbHnBpcn7HkMiA2iJIcUUXh
 W/unU/g4pTUPfe42zhW3Lpy+AXSxeU/L2I9UaR5zTrzurCb821lGN25+gEjJOiQs
 WmuOQ9nj18EfF/XpNZIpq63eXHtL9nuNqJYf5EvRa3h10KyayBcNYFoJNupWIW+a
 a1sH+JiqMXInoXymsf9gCNm2IrqIpRV8PivPOVuWFQ6cqrTRmzyQD2AzCT+Op3s8
 PE+MW2mZGbCzBMjfvzvzoXZqPqy0ESEDsi39+Q+O7B58prTIiIEXZS1fvNSLmqLR
 oFfwRTPJonylmbuRgbxtkrwVAmsbV7ZAN+Nxcz5G8lq7eLvUErlwP2k7EryQQK31
 iCx2ld33UU8madcl3G8T4ksxusPUyHUdjE64MOtqNT1bnI2CAm/4lY7XL3jiT0Nr
 NahA/HvSEqA+EpdnlVWLasSgbgVWu5sbu8q+a8jHxFLhfDj526aPGRLqW5aMn/8O
 hzNXwO3BMS422ToVZMu0MFp5e3np20NR5mCsCWTkEQvryKQ1rbchlme4gagxGCfE
 zxKB4Qg3BaciHlilz732aUKaqFm8aR5jlqqCOS5WnkjBPXbdER8/kROf01e9IbQx
 NcnvEDOxZJBo4Q7F7OecDi85MPjIuFrBAXLM7BBj1gXbbyG22fU=
 =65Oa
 -----END PGP SIGNATURE-----

Merge tag 'v1.24.0' into merge_1.24.0

PR-URL: https://github.com/libuv/libuv/pull/2075
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-19 16:08:51 -05:00
Ben Noordhuis
fab6e64b39 unix: remove unused uv__dup() function
It was introduced in commit abdc3efffe ("unix: add uv__dup()") from
January 2012 to break ground for commit e34dc13496 ("unix: implement
uv_import() and uv_export()").

Those APIs were removed not much later but I forgot to remove the
helper function as well. Better late than never, eh?

PR-URL: https://github.com/libuv/libuv/pull/2043
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-10-17 20:26:03 +02:00
Santiago Gimeno
bf6c5be84d unix: refactor getsockname/getpeername methods
PR-URL: https://github.com/libuv/libuv/pull/1872
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-09-28 22:19:11 +02:00
Santiago Gimeno
6e7da5fbc0 2018.08.18, Version 1.23.0 (Stable)
Changes since version 1.22.0:
 
 * win,pipe: restore compatibility with the old IPC framing protocol (Bert
   Belder)
 
 * fs: add uv_open_osfhandle (Bartosz Sosnowski)
 
 * doc: update Visual C++ Build Tools URL (Michał Kozakiewicz)
 
 * unix: loop starvation on successful write complete (jBarz)
 
 * win: add uv__getnameinfo_work() error handling (A. Hauptmann)
 
 * win: return UV_ENOMEM from uv_loop_init() (cjihrig)
 
 * unix,win: add uv_os_{get,set}priority() (cjihrig)
 
 * test: fix warning in test-tcp-open (Santiago Gimeno)
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - https://gpgtools.org
 
 iQIzBAABCgAdFiEElK42Z1xGTWS6+mjddDQ5C9vpucUFAlt2LW8ACgkQdDQ5C9vp
 ucXlDBAAlCVoa6GZthYy7fOBddNn2410GVKNZTUwNZ+bZL6ctpFxhgoH/Vir2SVg
 /8Je+Se3jz6QXJx0cA2+gLZdZ+nmZn4cAOGo9p6pWq2SVhmtc7F89KkHc8DDG0GR
 yGF09utyM4fQL0pnDYLzg66iquQJPCd1BwP32LlHOM0kqDyqli+OVphw/X9ABeHl
 GFPMD8i8wuHAKcOQo7xLsIETZVax/LC6N7seeMxO2ZIdAZFSeBw4OEyHra9hLq2r
 eleTccsA5R+tZZE9gUyefZ4s0desZkfndC0iL3qoWaM+TVxwpuB379BquDwhVwC1
 CFaFv7HLikNjUgwTSz9nUbsqxni2z+QH5gmgaF7WWpPIJcSf3ZH4T8wW9abRwizR
 BIehRtVHEM+TmC3Hr1ttfnDjMoFtyO33Tw1lSpQ9vlhll+sotei8RP7+oPumjlAN
 rs6dfnZ2FTxjNDWG1yaDXxoh2GWwR9gbxr/SiL/ZhoNHukJNN+gPAamF11S3Sk0v
 +h+iC9dtdiOPPWipxCZ+xeB3Tdus5Z+HVgG7Se859nt1r0kwA5zKfGw9pv65La9g
 KZuTCZjgvx7fCh4Mcw+uVExJ1vTWy+x5kOKk4l62RQj+L9f1YJZxgljMrBQTG9AU
 s4hMGI4gDMblyVM35T3vHModFBvwY0Uy90hn/yBCNILGbznNmD0=
 =Uf50
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEYS8OrZQBYiN530QC8ow8jaM8A74FAlt/3vUACgkQ8ow8jaM8
 A76jzQ//fAIPMjf42ifdQhD3/EFskQ9AwdiPLmDALUM9qn5hzfGp6XZ/XJKq87kg
 i2tm9wqh8m+QknSbnRkZMjDQrpmQuOypS+mqBDTVuPHHJ5V53f0zgStqlZ2dE5h9
 B/5YcGTukVjK6BIlazFH5QO8urc9IsYefSvPp9gepO1XnLCzkE9OpVgL9jFTLcaG
 Yvovtkbm4tkdYlOYZEp8LitnocRH84eJCZZipA3cfwctaWShKjPL6i/vB6TsmyH2
 7QSdKcBkbYJ50r03gUSRYNQYpoJDJEg7eht/XGPVbUGMhcZ53oz6DqGE+bqalZ5P
 VbD76KC96tqDhW99nCUij/RdT4Xo7NbK2+RiMXznr2H3KkpIt3eKEdD62B3ax1Hc
 cNzk/fINareTe/6gPVg08A8Tzpsg48PNnLpGkzYpHghCn2XBR1iTtQNpIOa1UpxO
 Gqe+uEP8k08tQ/n9rpBzBnNsC+fCZQU6Q5LGpWnTXMRjNtQuWM99O9k06TBPmDWI
 AQyJ9MByEt5bwNqsIg9nVe+iXkxNbZBOLHmqbkDUWNTDhjY3+oVh8Dq/18nvfgMk
 dIIBrBa0FEGbG/r/uKpuMqNmxCQel8nkC0sQ5vdIN8CfzAfQnoMww93GyPEpQTSR
 FAwdk7ri+mGcGw3igUp8IsgAKwgjJAkkWzAX3gAwHrw1aoUnc60=
 =3idK
 -----END PGP SIGNATURE-----

Merge tag 'v1.23.0' into merge_1.23.0

PR-URL: https://github.com/libuv/libuv/pull/1952
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-08-24 12:33:18 +02:00
Ben Noordhuis
619937c783 unix,win: merge handle flags
Some long overdue refactoring that unifies more of the UNIX and Windows
backends.

PR-URL: https://github.com/libuv/libuv/pull/1904
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-06-29 22:24:52 +02:00
Ben Noordhuis
95c5bf8db1 unix,win: merge timers implementation
Merge src/unix/timer.c and src/win/timer.c into src/timer.c.  This
changes the Windows implementation from a binary tree to a binary
heap for generally better performance.

PR-URL: https://github.com/libuv/libuv/pull/1882
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-25 23:48:15 +02:00
Ben Noordhuis
2256be01b0 unix: catch some cases of watching fd twice
Libuv does not support multiple handles watching the same file
descriptor.  That condition is caught by an assert but it's detached
from the call site and therefore not always trivial to track down.

This commit turns cases where we can easily detect duplicates into
runtime `UV_EEXIST` errors.  More work is needed to catch _all_ cases.

Partially addresses https://github.com/libuv/libuv/issues/1172.

PR-URL: https://github.com/libuv/libuv/pull/1851
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-05-30 13:24:19 +02:00
Ben Noordhuis
bf605bd7d0 linux: don't use uv__nonblock_ioctl() on sparc
uv__nonblock_fcntl() and uv__nonblock_ioctl() do not commute when
O_NDELAY is not equal to O_NONBLOCK.  Case in point: linux/sparc32
and linux/sparc64, where O_NDELAY is O_NONBLOCK + another bit.

Libuv uses uv__nonblock_fcntl() directly sometimes so ensure that it
commutes with uv__nonblock().

Fixes: https://github.com/libuv/libuv/issues/1830
PR-URL: https://github.com/libuv/libuv/pull/1832
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-05-06 23:48:02 +02:00
Michael Kilburn
9ed3ed5fcb
unix: fix several instances of lost errno
This commit preserves errno properly in the following cases:

- new_socket() was previously discarding errno in some cases,
  and replacing it with the result of getsockname().
- uv__close() was not preserving errno when __MVS__ is defined.

Fixes: https://github.com/libuv/libuv/issues/1756
PR-URL: https://github.com/libuv/libuv/pull/1763
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-03 11:03:41 -05:00
Santiago Gimeno
f94282c7ab 2018.02.22, Version 1.19.2 (Stable)
Changes since version 1.19.1:
 
 * test: fix incorrect asserts (cjihrig)
 
 * test: fix a typo in test-fork.c (Felix Yan)
 
 * build: remove long-obsolete gyp workarounds (Ben Noordhuis)
 
 * build: split off tests into separate gyp file (Ben Noordhuis)
 
 * test: check uv_cond_timedwait more carefully (Jamie Davis)
 
 * include,src: introduce UV__ERR() macro (Mason X)
 
 * build: add url field to libuv.pc (Ben Noordhuis)
 
 * doc: mark IBM i as Tier 3 support (Jesse Gorzinski)
 
 * win,build: correct C2059 errors (Michael Fero)
 
 * zos: fix timeout for condition variable (jBarz)
 
 * win: CREATE_NO_WINDOW when stdio is not inherited (Nick Logan)
 
 * build: fix commmon.gypi comment (Ryuichi KAWAMATA)
 
 * doc: document uv_timer_start() on an active timer (Vladimír Čunát)
 
 * doc: add note about handle movability (Bartosz Sosnowski)
 
 * doc: fix syntax error in loop documentation (Bartosz Sosnowski)
 
 * osx,stream: retry sending handle on EMSGSIZE error (Santiago Gimeno)
 
 * unix: delay fs req register until after validation (cjihrig)
 
 * test: add tests for bad inputs (Joyee Cheung)
 
 * unix,win: ensure req->bufs is freed (cjihrig)
 
 * test: add additional fs memory management checks (cjihrig)
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - https://gpgtools.org
 
 iQIcBAABCgAGBQJajdXDAAoJEHQ0OQvb6bnF+gkQAIYnk1ujKETakcu/O8M/d+yu
 gZkLAnqkMYD5X5rTEFkaHrzrQMD85twxme+GgegSFweUDvhqVQWveeNG5zRJ8/ri
 HsysKioqBsMfzCtJw4W+wDLIL7ltja2vcZooTTyvrIArLd2zQ8sn0nHe/eTq2uKl
 wMPhup9qxl10THpevdab3AMr1jEJ3KSsFaNUaVLySf6DJJqY4pRV+ekDGQVrkNZU
 XzH67YN2XWP5dsavAVX0GsnQraX8kNWgYjcDK93D55hj93iyq+38ZYstEhNqIGF9
 9StzptoUyqK5KD5tyDYC2WmgwBJd9eAodmjCdq+ZP0td/irxEhQoRAX7aoAjBGzY
 j3vTb0JXhvvEghivap86mkxPhAQ6rmbGZkG/yOi6eexL/es1GwhGmfzE3NgUexCx
 nyKVCWqVo4IjL53+jndaX3wE4AIKpo0geah7f82v7cIJJqYN8DtaNN9imwZO3r7p
 WFUx2ujOYGuFcz1xbFNyLzBH0Rda2JnsvtAstGvWXSoXzCNSEU5PZ6rpn3jcOVU5
 mDjQ9z/x3kp25qp014+wxHD+mltZzcL8H8fJfQ9JkGWdYE+R3brzwib07GctdlKP
 3/PGH6vbDyiiCEiwfwjhjZpZWyJcaEuGegEc7J80uEm+/yq1/4HrdaFbI20D2heB
 NIj8XaaPt8Vqsafp0ZWp
 =Aa+M
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEYS8OrZQBYiN530QC8ow8jaM8A74FAlqRjUEACgkQ8ow8jaM8
 A77UBw//b71/tAhf1ZOEwouhCjuoy17PNrgfmpQFw8NbaJc6YALe2oQ+1+gc/GPp
 9kaPfjDLSlZwYJMVtiTmKaQoqYNj3Y6ZJatZYambZ89/3XCBjd4WbK2IMnpth+xU
 tLzvjd5RlNMNpyrdrlEXneZi5ql7/QeRLj85k2790LSSajODK8A4VoZZoRmfBL4S
 rnngc5BFI2MGNOyUcc4HBtAcusvt6KIZWxhiRHLa0vpNmrnUAcXqruxzp36+ct+3
 efy+9cx6uzbnqg7dv8WHljre+2we4NaHcH4W2zCkNuf0JrO9reJMjojBb3+NsVIt
 HBHonkVLvRf8eTv8VFoKQPqeMStVj2FtVRmuKqcZ8l/fZNH/Fz2R2tO2ZaLCrSax
 TkAiuLi7uOY32oBNNyI6GGwcJAD52ROl+UCBEoRCOpYVx6PWjZnun7zP7bYq+oJt
 h1qL7avrGfp7vG+ggDxfeEOlWZKeXBN6/uh+KnTFryxMwZ9GFNu46s2EttS2lATg
 eKvPXTPBF9xKVCxckDph5sBhT420SBt2xa8neeMMdEKXPaDPtyj9kMau6HeU84cO
 bcnGytFhlhx7qUv1sEO0gHp/fYkvdUYUhzsY5lWeVdz3U3j/YhQO+ErzBzhIOU+E
 arC+ldYO9eWzdgRxodOcHX6YFAEnHFeyXs5KfOKbUNdqD0dLNJQ=
 =lWVS
 -----END PGP SIGNATURE-----

Merge tag 'v1.19.2' into merge_1.19.2

PR-URL: https://github.com/libuv/libuv/pull/1753
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-02-24 17:04:48 +01: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
Kamil Rytarowski
60bf1dfb51
netbsd: use uv__cloexec and uv__nonblock
This commit causes NetBSD, like other BSDs, to reuse
uv__cloexec_ioctl and uv__nonblock_ioctl. This fixes
poll_nested_kqueue.

PR-URL: https://github.com/libuv/libuv/pull/1575
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-10-02 09:27:38 -04: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
Saúl Ibarra Corretgé
7043c79c2a Merge branch 'v1.x' into merge-v1 2017-07-09 13:52:50 +02:00
Ben Noordhuis
87df1448a4 unix,windows: refactor request init logic
Fixes a TODO in src/threadpool.c.  Updates the Windows code to drop the
unused `loop` parameter in calls to uv_req_init().

PR-URL: https://github.com/libuv/libuv/pull/1091
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-21 16:14:09 +01: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
Ben Noordhuis
5fc8aecd81 unix: simplify async watcher dispatch logic
Remove the unused `nevents` parameter from `uv__async_event()`
and remove the indirection of having a separate `uv__async`
type.  There is only one instance per event loop these days.

This incidentally removes the `assert(n == sizeof(val))` in a
Linux-specific code path that some users seem to hit from time
to time.  The cause is not well-understood and I've never been
able to reproduce it myself.  Presumably libuv gets an EAGAIN
when trying to read from the eventfd but when and why that
happens is unclear.

Since the byte count is unused, removing the assert seems safe.
Worst case, libuv sometimes iterates over the async watcher list
when it doesn't have to.

Fixes: https://github.com/libuv/libuv/issues/1171
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Supersedes: https://github.com/libuv/libuv/pull/1214
2017-03-15 10:03:10 +01:00
Santiago Gimeno
c355c8b1a6
test: fix tests on OpenBSD
It fixes `process_title`, `poll_bad_fdtype` and `poll_nested_kqueue`
tests.

Fixes: https://github.com/libuv/libuv/issues/1216
PR-URL: https://github.com/libuv/libuv/pull/1218
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-02-07 17:47:17 +01:00
John Barboza
011e02e3e5 zos: make platform functional
Fix all functional test cases:

* use PLO compare,swap,store for atomic instruction
* do not use semaphore.h
* use xplink flag when linking
* scandir implementation
* nanosleep implementation
* add proctitle
* uv_loadavg
* uv_fs_event_init/start
* uv_fs_event_stop
* uv_exepath using __getthent syscall
* read free/total memory from mvs data areas
* uv_resident_set_memory implementation
* network interfaces implementation
* cpu_info implementation
* implement uv__hrtime
* make uv__fs_mkdtemp implementation
* epoll implementation for asyncio
* uv__fs_event_close implementation
* set process title
* read ancillary data that remains on queue
* ancillary data
* implement uv__fs_access
* use /dev/urandom for temporary directory name
* disable proctitle on zos completely

PR-URL: https://github.com/libuv/libuv/pull/1037
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2017-01-18 08:42:59 -06:00
Saúl Ibarra Corretgé
adedc27dfc Merge branch 'v1.x' into merge-v1 2017-01-17 22:01:39 -06:00
Brad King
6b35ca8616 unix: don't include CoreServices globally on macOS
In unix/internal.h, CoreServices is included for AvailabilityMacros.h.
This commit just includes AvailabilityMacros.h directly instead.

PR-URL: https://github.com/libuv/libuv/pull/1092
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-10-16 13:35:47 -04:00
Saúl Ibarra Corretgé
912d42b728 unix,win: unify timers implementation
PR-URL: https://github.com/libuv/libuv/pull/1058
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-09-23 09:32:31 +01:00
Saúl Ibarra Corretgé
d8baf7a6f8 Merge branch 'v1.x' 2016-09-20 00:24:14 +02:00
John Barboza
f4ef897666 zos: track unbound handles and bind before listen
On zOS the listen call does not bind automatically if the socket
is unbound. Hence the manual binding to an arbitrary port is
required to be done manually.

PR-URL: https://github.com/libuv/libuv/pull/949
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-24 10:02:41 +01:00
Jeffrey Clark
0a4b51fcb4 build: GNU/kFreeBSD support
autotools support only, gvp does not support kfreebsd detection.

PR-URL: https://github.com/libuv/libuv/pull/960
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-20 08:55:30 +02:00
Saúl Ibarra Corretgé
d527ab90f4 core: switch to C99
PR-URL: https://github.com/libuv/libuv/pull/994
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-08-12 23:10:34 +01:00
Saúl Ibarra Corretgé
3118e5a4e4 unix,win: share loop watchers implementation
PR-URL: https://github.com/libuv/libuv/pull/974
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-08-05 12:49:29 +01:00
Saúl Ibarra Corretgé
46dbdd0f97 macOS: drop support for macOS < 10.9
PR-URL: https://github.com/libuv/libuv/pull/966
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-08-04 12:01:08 +01:00
Ben Noordhuis
c5c419f7c8 unix: allow nesting of kqueue fds in uv_poll_start
kqueue file descriptors don't support ioctl(FIONBIO) (or any other ioctl
for that matter) so retry using fcntl(F_GETFL) + fcntl(F_SETFL) when we
receive a ENOTTY error.

Fixes: https://github.com/libuv/libuv/issues/883
PR-URL: https://github.com/libuv/libuv/pull/885
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-05-24 17:12:31 +02:00
Kári Tristan Helgason
f57bfd4dca unix: fix bug in barrier fallback implementation
There was a memory corruption issue with the pthread barrier
implementation on android, where a barrier could still be in use by one
thread when being freed by another.

This fixes that issue and adds lots of missing error handling.

This implementation is now also used for the OSX fallback.

Fixes: https://github.com/libuv/libuv/issues/615
PR-URL: https://github.com/libuv/libuv/pull/790
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-04-26 09:35:47 +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
Santiago Gimeno
1c0281e3e2 process: fix uv_spawn edge-case
It can happen that the `parent` end of the `signal_pipe` is given a
STDIO file descriptor, so closing it using `uv__close` fails.

This problem is happening when running the `spawn_closed_process_io`
test in `SmartOS`. The reason being that when creating a socketpair in
`uv__process_init_stdio`, the `Illumos` implementation uses 3 sockets:
one is used as a listener, and the other 2 represent both ends of the
pipe. The listener socket is closed once the pipe is created. In the
test, the listener socket is assigned to the `0` fd, as it is the
first free fd in the system. So the fd `0` remained free after the call
to `socketpair`. Afterwards, when creating the `signal_pipe`, the fd `0`
is being assigned again, so closing it with `uv__close` made the test
fail. This issue is not happening in the other unixes because
`socketpair` doesn't use 3 fd's, but only 2.

To solve the issue, a new `uv__close__nocheckstdio()` function has been
added and used.

PR-URL: https://github.com/libuv/libuv/pull/796
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-31 11:53:42 +02:00
cjihrig
217f81b6a1 unix,win: add uv_get_passwd()
This commit adds the uv_get_passwd() function, which returns a
subset of the current effective user's password file entry.

Refs: https://github.com/libuv/libuv/issues/11
Fixes: https://github.com/libuv/libuv/issues/731
PR-URL: https://github.com/libuv/libuv/pull/742
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-29 08:13:59 -04:00
Ben Noordhuis
27aa81fe5a aix: fix 'POLLRDHUP undeclared' build error
AIX doesn't have POLLRDHUP.  Fixes the following compile-time error:

    src/unix/core.c: In function 'uv__io_start':
    src/unix/core.c:831:40: error: 'POLLRDHUP' undeclared
    assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP)));

Fixes: https://github.com/libuv/libuv/issues/783
PR-URL: https://github.com/libuv/libuv/pull/785
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-03-26 11:31:23 +01:00
Santiago Gimeno
c7c8e916b8 poll: add UV_DISCONNECT event
It allows detecting the remote socket closing the connection. It's
emitted when `EPOLLRDHUP`(Linux), `EV_EOF`(BSD), `POLLRDHUP`(Solaris,
AIX) and `AFD_POLL_DISCONNECT`(Windows) events are received.

PR-URL: https://github.com/libuv/libuv/pull/691
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-03-15 23:39:49 +01:00
Kári Tristan Helgason
d7910e42d0 unix: add fork-safe open file function
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:26 +01:00
Ben Noordhuis
a0b56059cf unix: report errors for unpollable fds
Libuv would abort() when trying to watch a file descriptor that is
not compatible with epoll-style polling; file descriptors referring
to on-disk files fall into this category.

File descriptors that libuv creates itself are not an issue but
external ones that come in through the uv_poll_init() API are.

Make uv_poll_init() check whether the file descriptor is accepted by
the underlying system call and return an error when it's not.

Fixes: https://github.com/libuv/libuv/issues/658
PR-URL: https://github.com/libuv/libuv/pull/659
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-21 17:57:00 +01:00
Saúl Ibarra Corretgé
01544d861b Revert "stream: squelch ECONNRESET error if already closed"
This reverts commit 05a003a3f7.

This commit triggerd "test-tls-hello-parser-failure" failure in io.js.
See the reference below for a more thorough explanation.

Refs: https://github.com/nodejs/io.js/pull/2310
PR-URL: https://github.com/libuv/libuv/pull/475
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-07 14:19:08 +02:00
ronkorving
2bf782777f unix: allow nbufs > IOV_MAX in uv_fs_{read,write}
This allows writing and reading any amount of buffers,
regardless of what IOV_MAX may be defined as.

It also moves the IOV_MAX test from stream to core.

This is based on the excellent work of @bwijen in #269.

Refs: https://github.com/libuv/libuv/pull/269
PR-URL: https://github.com/libuv/libuv/pull/448
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-04 11:31:04 +02:00
Santiago Gimeno
05a003a3f7 stream: squelch ECONNRESET error if already closed
Add new UV__POLLRDHUP event to be emitted when EPOLLRDHUP(in Linux) or
EV_EOF(in BSD / OSX) is detected and only if UV_READABLE is set.

When a read returns ECONNRESET after a UV__POLLRDHUP event, emit EOF instead
of the error.

Add tcp-squelch-connreset test. Not to be run on Windows as it returns
ECONNRESET error.

Fixes in test-poll and test-tcp-open so they pass after these changes.

PR-URL: https://github.com/libuv/libuv/pull/403
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-07-10 09:25:01 +02:00
Saúl Ibarra Corretgé
1816dbc85f unix: make sure UDP send callbacks are asynchronous
Fixes: https://github.com/libuv/libuv/issues/301
PR-URL: https://github.com/libuv/libuv/pull/371
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-05-28 11:05:45 +02:00
Ole André Vadla Ravnås
d557ad73e0 darwin: fix size calculation in select() fallback
Apple's `fd_set` stores its bits in an array of 32-bit integers, which
means `FD_ISSET()` may read out of bounds if we allocate storage at
byte granularity. There's also a chance that the `select()` call could
corrupt the heap, although I didn't investigate that.

This issue was discovered by LLVM's AddressSanitizer which caught
`FD_ISSET()` trying to read out of bounds.

PR-URL: https://github.com/libuv/libuv/pull/241
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-05 21:05:00 +01:00
Andrius Bentkus
32747c75ce win,unix: move loop functions which have identical implementations
uv_default_loop, uv_loop_new, uv_loop_close, uv_loop_delete

PR-URL: https://github.com/libuv/libuv/pull/144
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-20 12:22:28 +01:00
Alexey Melnichuk
0473ac90bb common: move STATIC_ASSERT to uv-common.h
PR-URL: https://github.com/libuv/libuv/pull/82
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-02 16:17:10 +01:00
Ben Noordhuis
a6f2a4f834 Merge branch 'v0.10' into v1.x
Conflicts:
	AUTHORS
	ChangeLog
	README.md
	config-unix.mk
	include/uv.h
	src/unix/internal.h
	src/unix/kqueue.c
	src/unix/linux-core.c
	src/unix/stream.c
	src/uv-common.c
	src/uv-common.h
	src/version.c
	test/test-osx-select.c
2014-12-05 19:18:36 +01:00
Ben Noordhuis
2daf9448b1 unix: add flag for blocking SIGPROF during poll
Add a per-event loop flag for blocking SIGPROF signals when polling for
events.

The motivation for this addition is to reduce the number of wakeups and
subsequent clock_gettime() system calls when using a sampling profiler.

On Linux, this switches from epoll_wait() to epoll_pwait() when enabled.
Other platforms bracket the poll syscall with pthread_sigmask() calls.

Refs strongloop/strong-agent#3 and strongloop-internal/scrum-cs#37.

PR-URL: https://github.com/libuv/libuv/pull/15
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-05 17:38:31 +01:00
Ben Noordhuis
cb5140023b build: remove dtrace probes
The existing probes, all two of them, cause a great deal of pain for
people trying to build libuv on Linux because of SystemTap's dtrace(1)
utilitity not understanding the -xnolibs flag.

We could hack around that but it's easier to just remove the probes:
they are largely useless and unused while still needing a lot of
supporting infrastructure.  This commit removes 200 lines of code
and configuration.

Refs joyent/libuv#1478.
2014-11-10 20:12:50 -03:00
Saúl Ibarra Corretgé
fdbc8567af unix: fix colliding flag value
Fixes #1425
2014-08-18 10:14:21 +02:00
Andrew Low
cdc979dbe0 aix: improve AIX compatibility 2014-07-22 22:57:24 +02:00
Saúl Ibarra Corretgé
8d11aacb79 unix, windows: use the same threadpool implementation 2014-06-27 14:27:04 +02:00
Chernyshev Viacheslav
4018f72615 osx: pass const handle pointer to uv___stream_fd
uv___stream_fd does not modify passed parameter, so non-const
pointer is not required here.
2014-04-18 12:07:38 +02:00
Saúl Ibarra Corretgé
7a4c42a054 unix: add UV_HANDLE_IPV6 flag to tcp and udp handles 2014-04-02 01:24:39 +02:00
Saúl Ibarra Corretgé
db2a9072bc unix, windows: removed unused status parameter
async, timer, prepare, idle and check handles don't need the status
parameter.
2014-03-17 21:42:36 +01:00
Saúl Ibarra Corretgé
b197515367 unix: reopen tty as /dev/tty
Reopen the file descriptor when it refers to a tty. This lets us put the
tty in non-blocking mode without affecting other processes that share it
with us.

This brings back commit 31f9fbc, which was reverted in 20bb1bf. The OSX
select trick is working now.

Original patch by @bnoordhuis
2014-03-10 19:37:29 +01:00
Fedor Indutny
b05a3ee4d1 pipe: allow queueing pending handles
Introduce `int uv_pipe_pending_count(uv_pipe_t*)` and
`uv_handle_type uv_pipe_pending_type(uv_pipe_t*)`. They should be
used in IPC pipe's read cb to accept incoming handles:

    int count = uv_pipe_pending_count(pipe);
    int i;
    for (i = 0; i < count; i++) {
      uv_handle_type type = uv_pipe_pending_type(pipe);
      /* ... */
      uv_accept(...);
    }
2014-03-04 00:34:29 +04:00
Fedor Indutny
6abe1e4b95 fs: uv__cloexec() opened fd
Every file descriptor opened using libuv should be automatically marked
as CLOEXEC to prevent it from leaking to a child process. Note that
since we are opening fds in a thread pool, there is a possible race
condition between `uv_spawn()` and the `open()` + `uv__cloexec()`. The
rwlock was added to avoid it.

see https://github.com/joyent/node/issues/6905
2014-02-01 01:02:37 +04:00
ci-innoq
c438e739a8 fsevents: remove kFSEventStreamCreateFlagNoDefer polyfill
The kFSEventStreamCreateFlagNoDefer flag is already
defined in CarbonCore/FSEvents.h since OS X 10.5.

Fixes #1000.
2013-11-23 12:20:30 +04:00
Ben Noordhuis
e9f75fb146 unix: set close-on-exec flag on received fds
Set the close-on-exec flag on file descriptors that we've received with
recvmsg() so we don't leak them when calling fork() afterwards.

On Linux, we use the MSG_CMSG_CLOEXEC flag when supported (2.6.23 and
up.)

On older Linux versions and other platforms, we walk the received file
descriptors and set the close-on-exec flag for each fd manually.  That
won't entirely avoid race conditions when other threads call fork() or
clone() but at least we're less likely to leak file descriptors now.
2013-11-15 23:13:06 +01:00
Fedor Indutny
6149b66ccb Merge branch 'v0.10'
Conflicts:
	build.mk
	src/unix/core.c
	src/unix/darwin.c
2013-11-12 15:30:54 +04:00
Fedor Indutny
bbccafbe70 unix: fix reopened fd bug
When fd is closed and new one (with the same number) is opened inside
kqueue/epoll/port loop's callback - stale events might invoke callbacks
on wrong watchers.

Check if watcher was changed after invocation and invalidate all events
with the same fd.

fix #826
2013-11-12 15:02:59 +04:00
Fedor Indutny
0f5c28b684 fsevents: use FlagNoDefer for FSEventStreamCreate
Otherwise `FSEventStreamCreate()` will coalesce events, even if they're
happening in the interval, bigger than supplied `latency`. In other
words, if this flag is not set events will happen in separate callback
only if there was a delay bigger than `latency` between two consecutive
events.
2013-11-10 13:05:27 +04:00
Ben Noordhuis
21c37a7db8 linux: use CLOCK_MONOTONIC_COARSE if available
On some systems, clock_gettime(CLOCK_MONOTONIC) is only serviced from
the vDSO when the __vdso_clock_gettime() wrapper is confident enough
that the vDSO timestamp is highly accurate.  When in doubt, it falls
back to making a traditional SYS_clock_gettime system call with all
the overhead that entails.

While a commendable approach, it's overkill for our purposes because we
don't usually need high precision time. That's why this commit switches
to CLOCK_MONOTONIC_COARSE for low-precision timekeeping, provided said
clock has at least a one millisecond resolution.

This change should eliminate the system call on almost all systems,
including virtualized ones, provided the kernel is >= 2.6.32 and glibc
is new enough to find and parse the vDSO.
2013-10-29 21:24:42 +01:00
Ben Noordhuis
38df93cfed unix: revert recent FSEvent changes
This commit reverts the following commits:

    983fa68 darwin: fix 10.6 build error in fsevents.c
    684e212 fsevents: use shared FSEventStream
    ea4cb77 fsevents: FSEvents is most likely not thread-safe
    9bae606 darwin: create fsevents thread on demand

Several people have reported stability issues on OS X 10.8 and bus
errors on the 10.9 developer preview.

See also joyent/node#6296 and joyent/node#6251.
2013-10-05 18:24:33 +02:00
Ben Noordhuis
359d667893 unix: sanity-check fds before closing
Ensure that close() system calls don't close stdio file descriptors
because that is almost never the intention.

This is also a partial workaround for a kernel bug that seems to affect
all Linux kernels when stdin is a pipe that gets closed: fd 0 keeps
signalling EPOLLHUP but a subsequent call to epoll_ctl(EPOLL_CTL_DEL)
fails with EBADF.  See joyent/node#6271 for details and a test case.
2013-10-01 03:55:54 +02:00
Ben Noordhuis
12933f43c9 unix: move loop functions from core.c to loop.c
Move uv_default_loop(), uv_loop_new() and uv_loop_delete() to loop.c.
2013-08-27 22:48:16 +02:00
Ben Noordhuis
9bae606d41 darwin: create fsevents thread on demand
* Move CF run loop code to fsevents.c.

* Create the fsevents thread on demand rather than at startup.

* Remove use of ACCESS_ONCE. All accesses to loop->cf_loop are
  protected by full memory barriers so no reordering can take place.

Fixes #872.

Conflicts:
	src/unix/darwin.c
2013-08-22 16:48:53 +04:00
Ben Noordhuis
06c4fa67ed darwin: create fsevents thread on demand
* Move CF run loop code to fsevents.c.

* Create the fsevents thread on demand rather than at startup.

* Remove use of ACCESS_ONCE. All accesses to loop->cf_loop are
  protected by full memory barriers so no reordering can take place.

Fixes #872.
2013-08-13 11:41:48 +02:00
Ben Noordhuis
1920513735 sunos: remove futimes() macro
Remove a macro from src/unix/internal.h that aliases futimes() to
futimesat(). Deal with the platform inconsistency in src/unix/fs.c.
2013-08-12 07:46:22 +02:00
Ben Noordhuis
fd23dbf5c6 unix: clean up __attribute__((quux)) usage
Macro-ify __attribute__((destructor)) and __attribute__((unused)).

The macros are no-ops when the compiler does not support function
attributes.
2013-08-12 07:41:49 +02:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Ben Noordhuis
43205ed553 unix: remove unused function uv_fatal_error() 2013-06-06 08:54:36 +02:00
Ben Noordhuis
442d11d618 unix: avoid extra read, short-circuit on POLLHUP
Avoid going through an extra alloc_cb -> read() -> read_cb cycle when
the POLLHUP flag is set because we know the next read() will hit EOF.

Fixes #803.
2013-05-30 22:34:03 +02:00
Bert Belder
79f96298c1 Merge branch 'v0.10' 2013-04-18 02:58:44 +02:00
Ben Noordhuis
ef85bdaffb unix: silence STATIC_ASSERT compiler warnings
Newer versions of gcc complain about the definition of the zero element
array. Squelch that warning by turning it into a one element array.
2013-04-12 19:40:57 +02:00
Ben Noordhuis
145f7b3560 darwin: look up file path with F_GETPATH
Look up the file path with fcntl(F_GETPATH) and pass it to
the uv_fs_event_cb callback.
2013-04-10 19:45:43 +02:00
Timothy J Fontaine
e1ffc6c0ee unix: dtrace probes for tick-start and tick-stop 2013-04-10 14:10:05 +02:00
Fedor Indutny
b45a74fab3 stream: run try_select only for pipes and ttys
Its not necesary for TCP and other streams, since fd is always working
with kqueue there.
2013-03-16 23:29:24 +01:00
Ben Noordhuis
ef9b065532 unix: add STATIC_ASSERT macro 2013-03-07 00:52:50 +01:00
Ben Noordhuis
ee9899e28b unix: fix strict aliasing warnings, macro-ify functions
Replace a few internal functions in uv-common.h with macros to avoid
strict aliasing warnings with older versions of gcc.

It's not smart enough to figure out that e.g. a uv_tcp_t is an instance
of uv_handle_t with similar alignment requirements and therefore no
aliasing happens. More recent versions of gcc don't suffer from this.

I'm not normally in the habit of catering to compiler defects but the
aliasing warnings drown out legitimate warnings, hence the change.
2013-03-06 23:47:43 +01:00
Ben Noordhuis
92151658eb unix: abstract away async pipe infrastructure
This commit lays the groundwork for the switch to eventfds on Linux.
2013-02-25 02:36:52 +01:00
Ben Noordhuis
b607a7fed7 linux: move files out of src/unix/linux
Flattens the source tree and simplifies the Makefile.
2013-01-29 17:07:41 +01:00
Ben Noordhuis
edd10071eb unix: fix up #if defined checks
`#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.
2013-01-06 22:31:47 +01:00
Ben Noordhuis
0a06c2f3b2 unix: fix up function prototypes in signal.c 2013-01-06 21:25:58 +01:00
Ben Noordhuis
2f55353490 unix: update loop->time after poll
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.
2013-01-06 18:30:03 +01:00
Ben Noordhuis
339033afc0 unix: use uv__hrtime() internally
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.
2013-01-06 17:35:34 +01:00
Ben Noordhuis
69ab328d9f sunos: fix !defined(PORT_SOURCE_FILE) build 2012-12-28 12:45:47 +01:00
Ben Noordhuis
e079a99abd unix: fix event loop stall
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.
2012-12-13 20:17:12 +01:00
Fedor Indutny
731adacad2 unix: use select() for specific fds on OS X
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.
2012-12-09 15:43:08 +01:00
Ben Noordhuis
52c8a8617d unix: add uv_cancel() 2012-12-09 15:12:42 +01:00
Ben Noordhuis
4a69c4bb5f unix: change uv_backend_timeout() prototype
* change return value to signed int
* constify loop argument
2012-11-28 17:02:30 +01:00
Ben Noordhuis
e997dd5981 dragonflybsd: fix uv_fs_futime() 2012-11-20 00:38:24 +01:00
Ben Noordhuis
665a316aa9 unix: remove libev 2012-11-16 17:33:29 +01:00
Ben Noordhuis
65bb6f068e unix: rename UV__IO_* constants 2012-11-16 17:33:29 +01:00
Ben Noordhuis
1282d64868 unix: remove dependency on libev 2012-11-16 17:33:25 +01:00
Stephen Gallagher
e318b06a0e include: split off libev function prototypes
This patch creates a new header - ev-proto.h - which contains all of the
protoypes for libev functions. This allows us to create a shared object of
libuv without exposing libev internal functions.
2012-11-07 16:55:49 +01:00
Leonard Hecker
97c527ac43 darwin: make it possible to compile for iOS
Relocate the include of TargetConditionals.h and fixe the use of
TARGET_OS_IPHONE. Furthermore, uv__fsevents_init() and uv__fsevents_close are
now empty functions for iOS, since the FSEvents API is not available there.
2012-10-29 23:45:52 +01:00