I'm not 100% sure whether the behavior of readlink() with size=0 is
well-defined on Solaris; it can return either 0 or fail with EINVAL.
POSIX is not explicit about the mandated behavior.
This commit adds a little caution and makes it skip the readlink()
call when size=1 and simply writes the terminating zero byte.
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_exepath() should write as much as possible to the output buffer.
In the case of size=1, skip the call to readlink() because it will
fail with EINVAL; just write the terminating zero byte.
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Write as much of the path as possible to the output buffer. Before this
commit, passing in a buffer that was too small to hold the result failed
with a UV_EINVAL error.
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Passing a buffer that was too small to hold the result made it fail
with UV_EPERM because the -1 status code from _NSGetExecutablePath()
was returned unmodified to the caller.
This commit rewrites uv_exepath() to:
1. Not allocate heap memory, and
2. Not clobber the result buffer on error, and
3. Handle _NSGetExecutablePath()'s and realpath()'s idiosyncracies, and
4. Store as much of the path in the output buffer as possible, don't
fail with an error. Makes it behave the same as other platforms.
The result is always zero-terminated.
Fixes: https://github.com/libuv/libuv/issues/103
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Make the behavior of a call to uv_exepath() with a size argument of zero
consistent with the Windows implementation where it returns UV_EINVAL.
PR-URL: https://github.com/libuv/libuv/pull/104
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The fix from commit 269ff0be is wrong in that it sniffs system headers
to determine if preadv() and pwrite() are supported.
It breaks the fs_write_multiple_bufs test on one of my ARM systems;
its glibc has preadv() and pwritev() wrappers but its kernel has no
support for the corresponding system calls.
Simply try the system call and fall back to a normal read or write
loop if not supported. Move the no_preadv and no_pwritev variables
around to squelch two -Wpedantic warnings about mixing declarations
with code.
PR-URL: https://github.com/libuv/libuv/pull/90
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Using a static thread local variable to store the thread handle causes
crashes on Windows XP/2003 when libuv is loaded as a dynamic library.
With this patch, a TLS slot is allocated dynamically.
PR-URL: https://github.com/libuv/libuv/pull/82
Reviewed-By: Bert Belder <bertbelder@gmail.com>
This reverts commit a9e95a33bc.
This seems to cause regressions in the test suite when IPv6 is disabled.
As optimizations go, it's a very minor one so let's not spend too much
effort trying to track down the cause of the regressions but revert the
change before it makes its way into a release.
PR-URL: https://github.com/libuv/libuv/pull/92
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fix spawn_reads_child_path when executed as `test/run-tests` or
`make check`:
1. `make check` builds a dynamic libuv.so or libuv.dyld by default.
2. spawn_reads_child_path spawns a new instance of the test runner
by consulting uv_exepath() and executing the result.
3. `test/run-tests` is normally a shell script that sets up
DYLD_LIBRARY_PATH or LD_LIBRARY_PATH before executing the
real test runner in `test/.libs`.
4. uv_exepath() (corectly) returns the path of the binary in
`test/.libs`. The binary is linked against libuv.so but that
library is not on any of the default linker paths; and if it is,
it's almost certainly the wrong version.
5. Ergo, carry over the value of the (DY)LD_LIBRARY_PATH environment
variable into the environment of the child process so that the
dynamic linker knows where to find the library.
Alternatively, we could link the test runner statically against libuv.a
but that breaks `make check` when configured with `--disable-static`.
Fixes: https://github.com/libuv/libuv/issues/85
PR-URL: https://github.com/libuv/libuv/pull/91
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Only call setsockopt() when the initial bind() fails with EADDRINUSE,
then retry. Saves a system call in what is normally the common case.
PR-URL: https://github.com/libuv/libuv/pull/88
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Introduce a uv_tty_mode_t enum for uv_tty_set_mode(), with backward
compatible values. Add a new mode UV_TTY_MODE_IO, which uses
cfmakeraw() internally.
PR-URL: https://github.com/libuv/libuv/pull/86
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Revisit the fix from commit b705b53. The problem with using sigset_t
and _NSIG is that the size of sigset_t and the value of _NSIG depend
on what headers libuv picks up first, <signal.h> or <asm/signal.h>.
With the former, sizeof(sigset_t) = 128; with the latter, it's 8.
Simply sidestep the issue by calculating the signal mask as a 64 bits
integer, without using sigset_t or _NSIG.
This is a partial cherry-pick of commit 751ac48 from the v1.x branch.
Original PR-URL: https://github.com/libuv/libuv/pull/83
PR-URL: https://github.com/libuv/libuv/pull/84
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Revisit the fix from commit b705b53. The problem with using sigset_t
and _NSIG is that the size of sigset_t and the value of _NSIG depend
on what headers libuv picks up first, <signal.h> or <asm/signal.h>.
With the former, sizeof(sigset_t) = 128; with the latter, it's 8.
Simply sidestep the issue by calculating the signal mask as a 64 bits
integer, without using sigset_t or _NSIG.
PR-URL: https://github.com/libuv/libuv/pull/83
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Changes since version 1.0.2:
* test: test that closing a poll handle doesn't corrupt the stack (Bert
Belder)
* win: fix compilation of tests (Marc Schlaich)
* Revert "win: keep a reference to AFD_POLL_INFO in cancel poll" (Bert
Belder)
* win: avoid stack corruption when closing a poll handle (Bert Belder)
* test: fix test-fs-file-loop on Windows (Bert Belder)
* test: fix test-cwd-and-chdir (Bert Belder)
* doc: indicate what version uv_loop_configure was added on (Saúl Ibarra
Corretgé)
* doc: fix sphinx warning (Saúl Ibarra Corretgé)
* test: skip spawn_setuid_setgid if we get EACCES (Saúl Ibarra Corretgé)
* test: silence some Clang warnings (Saúl Ibarra Corretgé)
* test: relax osx_select_many_fds (Saúl Ibarra Corretgé)
* test: fix compilation warnings when building with Clang (Saúl Ibarra
Corretgé)
* win: fix autotools build of tests (Luis Lavena)
* gitignore: ignore Visual Studio files (Marc Schlaich)
* win: set fallback message if FormatMessage fails (Marc Schlaich)
* win: fall back to default language in uv_dlerror (Marc Schlaich)
* test: improve compatibility for dlerror test (Marc Schlaich)
* test: check dlerror is "no error" in no error case (Marc Schlaich)
* unix: change uv_cwd not to return a trailing slash (Saúl Ibarra
Corretgé)
* test: fix cwd_and_chdir test on Unix (Saúl Ibarra Corretgé)
* test: add uv_cwd output to platform_output test (Saúl Ibarra Corretgé)
* build: fix dragonflybsd autotools build (John Marino)
* win: scandir use 'ls' for formatting long strings (Kenneth Perry)
* build: remove clang and gcc_version gyp defines (Ben Noordhuis)
* unix, windows: don't treat uv_run_mode as a bitmask (Saúl Ibarra
Corretgé)
* unix, windows: fix UV_RUN_ONCE mode if progress was made (Saúl Ibarra
Corretgé)
Changes since version 0.10.30:
* test: test that closing a poll handle doesn't corrupt the stack (Bert
Belder)
* win: fix compilation of tests (Marc Schlaich)
* Revert "win: keep a reference to AFD_POLL_INFO in cancel poll" (Bert
Belder)
* win: avoid stack corruption when closing a poll handle (Bert Belder)
* gitignore: ignore Visual Studio files (Marc Schlaich)
* win: set fallback message if FormatMessage fails (Marc Schlaich)
* win: fall back to default language in uv_dlerror (Marc Schlaich)
* test: improve compatibility for dlerror test (Marc Schlaich)
* test: check dlerror is "no error" in no error case (Marc Schlaich)
* build: link against -pthread (Logan Rosen)
* win: scandir use 'ls' for formatting long strings (Kenneth Perry)
If pending I/O callbacks were ran before polling, do a zero timeout
poll.
PR-URL: https://github.com/libuv/libuv/pull/58
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The modes are not meant to be combined, and doing so may hide problems
in the future.
PR-URL: https://github.com/libuv/libuv/pull/58
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The clang and gcc_version defines were used to:
1. Conditionally enable -fvisibility=hidden, a switch introduced in
gcc 4.0. Because 4.2 is the minimum supported version, we can
make it unconditional. People that want to build with older
versions, can use '-Dvisibility='.
2. To conditionally enable -Wno-dollar-in-identifier-extension,
an Apple extension that suppressed warnings about sigils in
dtrace probe names. Dtrace probes were removed in cb514002.
PR-URL: https://github.com/libuv/libuv/pull/76
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Please see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773341 for
more information. Libuv uses some of pthread's symbols, but it doesn't
link against it, which causes underlinking issues, especially in Ubuntu
where we use ld --as-needed. The issue also shows up as warnings in
Debian's build logs.
PR-URL: https://github.com/libuv/libuv/pull/73
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fixes multiple definition linker errors due to what seems to be multiple
inclusions of src/unix/freebsd.c and src/unix/kqueue.c.
Fixes#72, refs joyent/libuv#1576.
PR-URL: https://github.com/libuv/libuv/issues/72
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
There is no need to check for a trailing slash, uv_cwd ensures it.
PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This aligns the behavior with the Windows implementation.
PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Check uv_dlerror() doesn't return "no_error", in order to make the test
less dependent on the exact error message the platform produces when
loading a dynamic library fails.
PR-URL: https://github.com/libuv/libuv/pull/59
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
FormatMessage can fail, e.g. with ERROR_MUI_FILE_NOT_FOUND. In this case
no error message was set and uv_dlerror wrongly returned "no error".
With this patch the fallback error message "error: <errorno>" is
generated when FormatMessage fails.
PR-URL: https://github.com/libuv/libuv/pull/59
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Add missing test file to match GYP definition and solve undefined
reference.
PR-URL: https://github.com/libuv/libuv/pull/69
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
PR-URL: https://github.com/libuv/libuv/pull/67
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1502 is not enough, since there are other fds which are in use
internally.
PR-URL: https://github.com/libuv/libuv/pull/67
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
More often than not, users run the test suite from /root, which means
the 'nobody' user won't be able to access the test runner and the test
will fail because we drop privileges to that user. Just skip it then.
PR-URL: https://github.com/libuv/libuv/pull/66
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The test used to call uv_cwd() twice, in this fashion:
char buf[PATH_MAX];
size_t size = sizeof buf;
uv_cwd(buf, &size);
uv_cwd(buf, &size);
The `size` variable is supposed to contain the buffer size (including
terminating null) on input, and it is also used as an out parameter for
returning the actual length of the working directory (not including the
terminating null). This makes the second uv_cwd() call fail with
UV_ENOBUFS.
PR-URL: https://github.com/libuv/libuv/pull/54
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
* Check whether uv_fs_symlink() succeeds.
* Bail out early if we're on an old version of windows, or if we're not
able to create symlinks because we're not elevated.
PR-URL: https://github.com/libuv/libuv/pull/55
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>