Commit Graph

46 Commits

Author SHA1 Message Date
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
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
Saúl Ibarra Corretgé
f2bb8d394c unix, win: add synchronous uv_get{addr,name}info
PR-URL: https://github.com/libuv/libuv/pull/156
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-01-23 01:12:05 +01:00
Saúl Ibarra Corretgé
2d5eaea1cd unix: simplify how process handle queue is managed 2014-09-04 10:06:52 +02:00
Saúl Ibarra Corretgé
4ca9a36389 unix, windows: add uv_fileno
Returns the platform specific file descriptor for handles that are
backed by one. The datatype is abstracted as uv_os_fd_t, which maps to
int on Unices and HANDLE on Windows.

Users can use this function to set specific socket options, for example,
in a non portable way.

This function is essentially a shotgun, you better be careful with
whatever you do with it, don't blame me if you used it to get the fd of
a stream, close it yourself and expect things to Just Work.
2014-08-27 10:53:40 +02:00
Saúl Ibarra Corretgé
df8ab507a0 fs: extend reported types in uv_fs_readdir_next
Support all possible types on Unix, and files, directories and links on
Windows. Some systems (hello SunOS!) don't have the d_type field on struct
dirent, so mark them as UV_DIRENT_UNKNOWN.
2014-08-15 16:44:44 +02:00
Fedor Indutny
ab2c4425a5 fs: introduce uv_readdir_next() and report types
Introduce:

    int uv_fs_readdir_next(uv_fs_t* req, uv_dirent_t* ent);

`uv_fs_readdir()` is not returning a file names list in `req->ptr`
anymore, the proper way to gather them is to call `uv_fs_readdir_next()`
in a callback.
2014-08-14 17:19:45 +04:00
Leonard Hecker
4c90cc8e14 unix: fix typedef of uv_buf_t
Typedefs of unnamed structs cannot be forward declared.
Giving the uv_buf_t struct a name makes forward declarations possible.
2014-08-10 17:30:13 +02:00
Andrew Low
cdc979dbe0 aix: improve AIX compatibility 2014-07-22 22:57:24 +02:00
Saúl Ibarra Corretgé
4bace4d67c unix: use struct sockaddr_storage for target UDP addr 2014-06-29 23:52:46 +02:00
Saúl Ibarra Corretgé
8d11aacb79 unix, windows: use the same threadpool implementation 2014-06-27 14:27:04 +02:00
Saúl Ibarra Corretgé
029e1273b8 unix: define NI_MAXHOST and NI_MAXSERV if needed
OSX only exposes them if _POSIX_C_SOURCE is not defined, for instance.
2014-06-24 10:20:43 +02:00
Rasmus Christian Pedersen
70c42563c1 unix, windows: getnameinfo implementation
Closes #852
2014-05-20 17:33:52 +02:00
Trevor Norris
f212ceffae include: reorder UV_HANDLE_PRIVATE_FIELDS
The fields for UV_HANDLE_PRIVATE_FIELDS in uv-win.h and uv-unix.h are
the same, but in different order. Simply swap them so uv_handle_t are
the same on both platforms.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-17 14:31:23 +04: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
Benjamin Saunders
13dd3502a7 fs: vectored IO API for filesystem read/write
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
2014-02-23 17:24:05 +01:00
Ben Noordhuis
f17c535b73 unix: use a heap for timers
Replace the red-black tree with a heap.  The most common operation that
libuv performs on timers is looking up the first timer to expire.  With
a red-black tree, that operation is O(log n).  With a heap, it's O(1).
2014-02-19 13:36:14 +01:00
Fedor Indutny
a03ea239db Revert "fs: vectored IO API for filesystem read/write"
This reverts commit 7df24583e5.
2014-02-18 21:48:13 +04:00
Benjamin Saunders
7df24583e5 fs: vectored IO API for filesystem read/write
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
2014-02-18 12:30:20 +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
Fedor Indutny
8b6c19e219 Revert "pipe: allow queueing pending handles"
The commit is quite broken and must be refactored before going into.

This reverts commit 08aeaf6193.
2013-12-24 02:17:12 +04:00
Fedor Indutny
08aeaf6193 pipe: allow queueing pending handles
If multiple handles arrive to the IPC pipe at the same time (happens on
some platforms), libuv will queue them internally, and call `read2_cb`
multiple times with a null-buffer and proper `handle_type`.
2013-12-23 14:15:32 +04:00
Alex Crichton
f764bff699 unix: return exec errors from uv_spawn, not async
If spawning a process fails due to an exec() failure (but it succeeded
in forking), then this should be considered a spawn failure instead of
an asynchronous termination of the process. This allows to check for
common exec() failure conditions such as a bad path quickly instead of
having to rely on keeping track of the async callback.

Additionally, the meaning of the two fields returned in the callback are
now exactly what they advertise to be. The process exit argument is not
one of two values depending on what happened to the child.

Fixes #978.
2013-11-07 22:10:38 +01:00
Ben Noordhuis
5c00a0ee33 unix: fix SIGCHLD waitpid() race in process.c
Before this commit, multiple event loops raced with each other when a
SIGCHLD signal was received.  More concretely, it was possible for
event loop A to consume waitpid() events that should have been
delivered to event loop B.

This commit addresses that by doing a linear scan over the list of
child processes.  An O(n) scan is not terribly efficient but the
actual performance impact is not measurable in a benchmark that spawns
rounds of several thousands instances of /bin/false.  For the time
being, this patch will suffice; we can always revisit it later.

Fixes #887.
2013-10-09 11:18:13 +02:00
Ben Noordhuis
9e4982f5c9 include: remove UV_IO_PRIVATE_FIELDS macro
It's an alias for UV_IO_PRIVATE_PLATFORM_FIELDS.  Remove the macro and
use UV_IO_PRIVATE_PLATFORM_FIELDS directly.
2013-09-08 20:21:24 +02:00
Ben Noordhuis
779b8d81e9 include: make uv_write{2} const correct 2013-09-01 08:25:25 +02:00
Ben Noordhuis
263da51967 include: uv_udp_send{6} now takes sockaddr_in*
Passing or returning structs as values makes life hard for people that
work with libuv through a foreign function interface. Switch to a
pointer-based approach.

Fixes #684.
2013-09-01 08:02:20 +02:00
Ben Noordhuis
5d2434bf71 unix, windows: add thread-local storage API
Uses the pthread_key_{create,delete} and pthread_{get,set}specific
functions on UNIX platforms, Tls{Alloc,Free} and Tls{Get,Set}Value
on Windows.

Fixes #904.
2013-08-25 15:51:07 +02:00
Ben Noordhuis
3d4099ebcb Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	src/version.c
	src/win/fs.c
2013-07-25 20:01:31 +02:00
Ben Noordhuis
ddd7e04fd6 build: switch to autotools
Switch to the build tool everyone loves to hate.  The Makefile has
served us well over the years but it's been acquiring more and more
features that autotools gives us for free, like easy static+shared
library building, sane install targets, and so on.

This commit drops MinGW support.  If there is demand for it, we'll
re-add it.
2013-07-02 01:21:16 +02:00
Ryan Dahl
b47c474cfd Move private headers into include/uv-private 2011-08-31 00:43:55 -07:00
Ryan Dahl
56dcaf9b06 unix: multiplicity 2011-08-31 04:18:55 +02:00
Ryan Dahl
1a4ead53d6 unix: implement uv_queue_work 2011-08-29 22:57:34 -07:00
Ryan Dahl
0e81406bfb unix fs_async_dir works 2011-08-29 22:08:51 -07:00
Ryan Dahl
3be275bad7 Begin implementation of UNIX uv_fs_ functions
Adding this incomplete work now to ease rebase troubles later as it moves
the functions to src/unix/fs.c and introduces src/unix/internal.h.
2011-08-29 14:36:45 -07:00
Ryan Dahl
7cad73aa47 Fix build for UNIX 2011-08-26 11:26:24 -07:00
Igor Zinkovsky
25175c7071 uv_fs & uv_work APIs 2011-08-26 11:00:53 -07:00
Ben Noordhuis
36ce74f2ca Add UDP support to libuv. 2011-08-24 04:55:01 +02:00
Ryan Dahl
b2ed24d86e unix: Remove flock code
solaris doesn't have flock
2011-08-02 07:08:13 +00:00
Ben Noordhuis
8e8af8fd34 uv-unix: use lock file to detect stale UNIX sockets 2011-07-29 03:59:55 +02:00
Ryan Dahl
92bc7b4959 Start uv_spawn()
Unix only at the moment. Lacks test for stdio
2011-07-25 16:19:27 -04:00
Ben Noordhuis
4eff34da43 uv-unix: pipes API implementation
Based on UNIX sockets to avoid the vagaries of FIFOs
in asynchronous mode. Currently unlinks stale sockets
before binding and cleans them up again after shutdown.
2011-07-19 00:58:02 +02:00
Bert Belder
c1bddb9677 Stop g++ from complaining about anonymous struct usage 2011-07-16 00:33:31 +02:00
Ryan Dahl
abe0b1ea61 Better request API
Instead of uv_shutdown, uv_write, uv_connect taking raw uv_req_t we subclass
uv_req_t into uv_shutdown_t, uv_write_t, and uv_connect_t.

uv_req_init is removed.
2011-07-14 10:45:28 -07:00
Igor Zinkovsky
b6a6dae34f Named pipes implementation for Windows 2011-07-09 21:41:04 +02:00
Ryan Dahl
ce8ff3031c src/ and include/ directories
Helps #71 but does not update the MSVC files.
2011-07-07 07:52:57 -07:00