Commit Graph

74 Commits

Author SHA1 Message Date
Saúl Ibarra Corretgé
2606ba22a7 unix, win: count null byte on UV_ENOBUFS
If an API function returns UV_ENOBUFS make sure we count the terminating
null, which we need space for. In case of success the null byte is not
included in the count, but the buffer *is* null terminated.

PR-URL: https://github.com/libuv/libuv/pull/690
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-03-03 09:23:10 +01:00
Nándor István Krácser
729d68596c doc: add missing write callback to example
PR-URL: https://github.com/libuv/libuv/pull/734
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-02-25 08:56:54 +01:00
cjihrig
c0fa2e7518 unix,win: add uv_os_tmpdir()
PR-URL: https://github.com/libuv/libuv/pull/672
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-21 09:11:56 +01:00
Yuval Brik
e76b8838e5 fs: add uv_fs_realpath()
Equivalent to realpath(3), returns the full resolved absolute path of a
file or directory.

PR-URL: https://github.com/libuv/libuv/pull/531
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-12-05 11:32:58 +01:00
Petka Antonov
6490c508a9 misc: expose handle print APIs
PR-URL: https://github.com/libuv/libuv/pull/291
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-11-16 09:34:34 +01:00
Andrius Bentkus
e9b5a86aa6 docs: clarify documentation of uv_tcp_init_ex
I think this makes it clear that the flags can't contain any other
information.

PR-URL: https://github.com/libuv/libuv/pull/592
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-29 01:27:04 +01:00
Eli Skeggs
36b79057c5 doc: clarify repeat timer behavior
Signed-off-by: Eli Skeggs <skeggse@gmail.com>

Fixes: https://github.com/libuv/libuv/issues/181
PR-URL: https://github.com/libuv/libuv/pull/520
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-11 09:35:05 +02:00
Devchandra Meetei L
eddff0a675 doc: fix typo
PR-URL: https://github.com/libuv/libuv/pull/509
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-04 09:41:35 +02:00
Brian White
866dc3f98b doc: add uv_dlsym() return type
PR-URL: https://github.com/libuv/libuv/pull/503
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-09-02 09:58:55 +02:00
Ben Trask
9ef523e281 doc: uv_read_start and uv_read_cb clarifications
PR-URL: https://github.com/libuv/libuv/pull/500
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-31 10:04:07 +02:00
Ben Noordhuis
96fc77d5d9 unix,windows: don't assert on unknown error code
Make uv_err_name() and uv_strerror() return a dynamically allocated
string when the error code is not recognized.

It leaks a few bytes of memory but that can't be helped.  Asserting
and aborting is, in my opinion, much less helpful.

Fixes: https://github.com/nodejs/node/issues/63
PR-URL: https://github.com/libuv/libuv/pull/467
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-18 16:10:37 +02:00
Corbin Simpson
fc556acbb4 doc: clarify uv_read_stop() is idempotent
PR-URL: https://github.com/libuv/libuv/pull/478
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-10 09:20:51 +02:00
Saúl Ibarra Corretgé
b3fde348e4 doc: add a note about uv_dirent_t.type
On Linux getting the type is only supported by some filesystems, check
getdents(2).
2015-07-17 09:26:08 +02:00
Yosuke Furukawa
e110c46b81 doc: add missing variable name
PR-URL: https://github.com/libuv/libuv/pull/432
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-07-10 09:22:00 +02:00
Saúl Ibarra Corretgé
188e0e94ac win: add support for recursive file watching
Original patch by @ghostoy, modified by @bpasero and yours truly.

Refs: https://github.com/joyent/libuv/pull/1473
Refs: https://github.com/libuv/libuv/pull/198
PR-URL: https://github.com/libuv/libuv/pull/421
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-07-08 23:40:47 +02:00
Saúl Ibarra Corretgé
c48950ed04 doc: add note about uv_fs_scandir
The '.' and '..' entries are always skipped on Unix systems.

Refs: https://github.com/libuv/libuv/issues/426
PR-URL: https://github.com/libuv/libuv/pull/427
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-07-08 22:39:46 +02:00
Saúl Ibarra Corretgé
ac89bb4d30 docs: add Windows specific note for uv_fs_open 2015-07-07 09:55:52 +02:00
Saúl Ibarra Corretgé
c1fe25f654 doc: add section with version-checking macros and functions 2015-06-29 23:09:14 +02:00
Saúl Ibarra Corretgé
f8f59824c4 unix, win: add ability to create tcp/udp sockets early
Introduce two new APIs:

int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, int flags)
int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, int flags)

The lower 8 bits of the flags field are used for the socket domain.
AF_INET, AF_INET6 and AF_UNSPEC are supported. If AF_UNSPEC is specified
the socket is created lazily, just like uv_{tcp,udp}_init.

Some Windows notes:

getsockname fails with WSAEINVAL if the socket is not bound. This could
potentially be improved by detecting the socket family and filling
the sockaddr_in/6 struct manually.

bind returns WSAEFAULT if we try to bind a socket to the wrong family.
Unix returns EINVAL.

PR-URL: https://github.com/libuv/libuv/pull/400
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-19 09:37:19 +02:00
cjihrig
a0c8815294 win: add XP support to uv_os_homedir()
The previous Windows implementation used SHGetKnownFolderPath(),
which is only supported on Vista and up. This commit switches to
GetUserProfileDirectoryW(), which returns the same information,
but is supported back to Windows 2000, and is not deprecated.

PR-URL: https://github.com/libuv/libuv/pull/375
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-06-03 00:26:56 +02:00
Saúl Ibarra Corretgé
bddd6a8489 core: add ability to customize memory allocator
This patch is composed by the work done in
https://github.com/libuv/libuv/pull/231 and
https://github.com/libuv/libuv/pull/287 plus some changes by yours
truly.

Thanks @beevik and @mattsta for their work on this!

PR-URL: https://github.com/libuv/libuv/pull/368
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-02 12:05:20 +02:00
cjihrig
a62c2d5928 unix,win: add uv_os_homedir()
PR-URL: https://github.com/libuv/libuv/pull/350
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-21 17:31:35 +02:00
Igor Soarez
ccf90a1ea5 doc: fix typo in tcp.rst
PR-URL: https://github.com/libuv/libuv/pull/355
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-19 11:27:46 +02:00
Ben Noordhuis
7639dd510e doc: fix uv_run(UV_RUN_DEFAULT) description
Saying uv_run() always returns zero is incorrect in the presence of
calls to uv_stop().

PR-URL: https://github.com/libuv/libuv/pull/337
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-01 01:20:39 +02:00
Saúl Ibarra Corretgé
1f711e4d6d Revert "memory: add uv_replace_allocator"
This reverts commit c272f1f1bc.

The concept will come back to libuv, but it needs some more work.
2015-04-29 09:37:02 +02:00
Daryl Haresign
706362083e docs: add some missing words
PR-URL: https://github.com/libuv/libuv/pull/332
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-04-28 22:36:33 +02:00
Corey Farrell
e2e218b760 doc: document uv_buf_t members
PR-URL: https://github.com/libuv/libuv/pull/307
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-04-07 17:13:01 +02:00
Saúl Ibarra Corretgé
db39a6ce71 doc: clarify what uv_*_open accepts
Fixes: https://github.com/libuv/libuv/issues/281
PR-URL: https://github.com/libuv/libuv/pull/284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-03-23 10:55:38 +01:00
Ben Noordhuis
fc9e66e555 unix: reject non-tty fds in uv_tty_init()
Reject file descriptors that correspond to regular files or char/block
devices.  Such file descriptors are incompatible with epoll and trigger
a run-time assert.

Fixes: https://github.com/libuv/libuv/issues/255
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-11 16:45:51 +01:00
Ben Noordhuis
868700952b doc: fix long lines in tty.rst
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-11 16:45:24 +01:00
Brett Vickers
c272f1f1bc memory: add uv_replace_allocator
With uv_replace_allocator, it's possible to override the default
memory allocator's malloc and free calls with functions of the user's
choosing. This allows libuv to interoperate with projects requiring a
custom memory allocator.

Internally, all calls to malloc and free have been replaced with
uv__malloc and uv__free, respectively. The uv__malloc and uv__free
functions call malloc and free unless they have been overridden by a
previous call to uv_replace_allocator.

As part of this change, the special aligned memory allocations
performed in src/win/fs-event.c have been replaced with standard
allocations. The 4-byte alignment being requested in this file was
unnecessary, since standard allocators already guarantee at least an
8-byte alignment.

PR-URL: https://github.com/libuv/libuv/pull/231
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-03-05 20:02:16 +01:00
Saúl Ibarra Corretgé
8ef34592a9 doc: document uv_getnameinfo_t.{host|service}
Fixes: https://github.com/libuv/libuv/issues/182
PR-URL: https://github.com/libuv/libuv/pull/233
Reviewed-By: Tim Caswell <tim@creationix.com>
2015-03-02 16:53:57 +01:00
Saúl Ibarra Corretgé
3b0998c935 doc: link system and library calls to man pages
PR-URL: https://github.com/libuv/libuv/pull/236
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-03-02 14:20:51 +01:00
Saúl Ibarra Corretgé
5ba687f422 doc: add Sphinx plugin for generating links to man pages
PR-URL: https://github.com/libuv/libuv/pull/236
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-03-02 14:20:02 +01:00
Andrius Bentkus
901824ba77 doc: clarify that the thread pool primites are not thread safe
PR-URL: https://github.com/libuv/libuv/pull/227
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-02-26 11:35:01 +01:00
Saúl Ibarra Corretgé
7a3af176bd doc: adjust next version to 1.4.1 2015-02-24 20:44:02 +01:00
Ben Noordhuis
ff0316813d unix,windows: make uv_thread_create() return errno
Before this commit, UNIX returned -1 on failure.  Windows sometimes
returned a UV_E* error code and sometimes a bogus status code, courtesy
of errno values not mapping to UV_E* error codes on that platform.

PR-URL: https://github.com/libuv/libuv/pull/204
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-02-17 22:25:01 +01:00
Ben Noordhuis
b36d4ff930 unix: implement uv_stream_set_blocking()
Commit 393c1c5 ("unix: set non-block mode in uv_{pipe,tcp,udp}_open")
causes a regression in the io.js cluster module.

The io.js documentation states that `worker.send()` and `process.send()`
are synchronous but they no longer were after upgrading to libuv v1.2.1.

The reason they are synchronous is because of backpressure - or rather,
lack of backpressure: a slow consumer eventually causes a fast producer
to run out of memory because the backlog of pending messages in the
producer can grow unchecked.

Ergo, implement uv_stream_set_blocking() on UNIX platforms to let io.js
enable the old blocking behavior for pipes again.

Refs: https://github.com/iojs/io.js/issues/760
PR-URL: https://github.com/libuv/libuv/pull/187
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-02-09 13:28:52 +01:00
Andrius Bentkus
39a0936fec win, unix: add pipe_peername implementation
PR-URL: https://github.com/libuv/libuv/pull/166
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-28 21:40:32 +01:00
Andrius Bentkus
2bfa2e5e22 style: rename buf to buffer and len to size for consistency
PR-URL: https://github.com/libuv/libuv/pull/159
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-27 11:31:16 +01:00
Andrius Bentkus
1e59ab1d49 fs, pipe: no trailing terminator in exact sized buffers
uv_fs_poll_getpath, uv_pipe_getsockname, uv_fs_event_getpath used
to return the trailing null terminator, even though the functions
returned the size.

Fixes: https://github.com/libuv/libuv/issues/155
PR-URL: https://github.com/libuv/libuv/pull/159
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-27 11:31:16 +01: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é
737cd1fb4f doc: clarify uv_default_loop
Indicate that it can (and should) also be closed, currently it's not
"special" in any way.

PR-URL: https://github.com/libuv/libuv/pull/147
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 09:12:25 +01:00
Alex Mo
ea5f1f98e0 doc: explain how the threadpool is allocated
Add an explanation about how libuv implements the threadpool and why.
This is so users know what behavior they should expect when they make
use of threads.

Related issue: https://github.com/libuv/libuv/issues/145

PR-URL: https://github.com/libuv/libuv/pull/146
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 01:16:04 +01:00
Saúl Ibarra Corretgé
7a19a48df8 doc: clarify which flags are supported in uv_fs_event_start
PR-URL: https://github.com/libuv/libuv/pull/135
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-17 09:16:32 +01:00
Saúl Ibarra Corretgé
b30a3e677b unix, windows: set non-block mode in uv_poll_init
libuv requires that the socket/fd is in non-blocking mode, so do it
internally so the user doesn't need to write platform specific code to
do so.

This also makes the API consistent with uv_{tcp,udp,pipe}_open, since
it's not required to pass the fd in non-blocking mode there either.

PR-URL: https://github.com/libuv/libuv/pull/136
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-16 10:41:00 +01:00
Ben Noordhuis
393c1c59a2 unix: set non-block mode in uv_{pipe,tcp,udp}_open
The contract specifies that the file descriptor should already be in
non-blocking mode before passing it to libuv.

However, node users don't really have an opportunity to do so, never
mind the fact that the call to uv_pipe_open() or uv_tcp_open() is an
implementation detail that most users won't be aware of.

Let's be nice and set the non-blocking flag explicitly.  It's a cheap
operation anyway.

Fixes: https://github.com/libuv/libuv/issues/124

PR: https://github.com/libuv/libuv/pull/134
Reviewed-by: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-14 19:46:54 +01:00
Saúl Ibarra Corretgé
c9c00cdc0d doc: clarify how uv_async_send behaves
Closes #29

PR-URL: https://github.com/libuv/libuv/pull/122
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-07 14:01:16 +01:00
Saúl Ibarra Corretgé
85d6624768 doc: clarify the behavior of uv_tty_init
Closes #120

PR-URL: https://github.com/libuv/libuv/pull/121
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-07 13:58:55 +01:00
Saúl Ibarra Corretgé
36f90342a3 doc: updated version reference for TTY mode changes 2015-01-05 20:21:57 +01:00