They're no longer needed, since the Windows-native SRWLock functions are
no longer used.
PR-URL: https://github.com/libuv/libuv/pull/525
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Previously, on Windows Vista and later, we'd use the Windows native
SRWLock APIs. However they turned out to be semantically incompatible
with pthread read-write locks and/or plain buggy. This patch makes sure
that the custom implementation that was previously only used on old
Windows versions is now used everywhere.
This patch fixes a number of issues with the old fallback
implementation. Specifically:
* The reader count would not be incremented when a thread successfully
acquired a read lock while another thread *also* held a read lock.
* `uv_rwlock_tryrdlock()` and `uv_rwlock_trywrlock()` now
consistently return UV_EBUSY when a lock couldn't be acquired.
* Any unexpected errors now cause libuv to abort, with the exception of
`uv_rwlock_init()`.
See also https://github.com/libuv/libuv/issues/515.
PR-URL: https://github.com/libuv/libuv/pull/525
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fold EAGAIN into EBUSY, and make it the only acceptable error.
PR-URL: https://github.com/libuv/libuv/pull/535
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
On AIX, it is correct to include AIX specific include files.
This is similar to all other platforms (ex. darwin, linux).
Signed-off-by: Neil Mushell <nmushell@bloomberg.net>
PR-URL: https://github.com/libuv/libuv/pull/521
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On AIX with the native xlC compiler, the compiler supports sync
compare swap and compare in two flavors:
1 __compare_and_swap
2 __compare_and_swaplp
This differs from the gcc version of this function in name. The
second version of this function supports 8-byte boundary for
a doubleword. Therefore, the macro logic checks:
if (AIX OS AND using xlC compiler)
if (64bit)
__compare_and_swaplp /* 64 bit version */
else
__compare_and_swap
endif
endif
Signed-off-by: Neil Mushell <nmushell@bloomberg.net>
PR-URL: https://github.com/libuv/libuv/pull/521
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Before this patch an uv_mutex_t (backed by a critical section) could be
released by a tread different from the thread that acquired it, which is
not allowed. This is fixed by using a semaphore instead.
Note that the affected code paths were used on Windows XP and Windows
Server 2003 only.
Fixes: https://github.com/libuv/libuv/issues/515
PR-URL: https://github.com/libuv/libuv/pull/516
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In FreeBSD if connect is called and the queue of pending connections(backlog)
is full, the call is automatically rejected with ECONNRESET. In the tests, 100
connections were tried and the backlog of both servers is 12, so the error.
To fix ipc_listen_before_write and ipc_listen_after_write, the backlog of the
server has been increased to 128.
PR-URL: https://github.com/libuv/libuv/pull/504
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv__close() does not set errno, it returns the error. It also never
returns EINTR, it always maps it to EINPROGRESS.
PR-URL: https://github.com/libuv/libuv/pull/512
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
fs_access, fs_async_dir and fs_symlink_dir could fail when the
filesystem where the tests are run does not fully support getting the
file type via getdents. Having getdents support does not imply that the
underlying filesystem fully supports what is necessary for these tests
to have passed prior to this commit. So the failing tests were updated
to check for UV_DIRENT_FILE as it did previously but it will also check for
UV_DIRENT_UNKNOWN as well to handle the filesystems that do not fully support
getting the file type via getdents. For OS X and Windows, which are
known to fully support getting the file type, the tests work as they did
before and will not check for UV_DIRENT_UNKNOWN. We could/should update the
preprocessor directive that chooses "rigorous" or "lax" checks
accordingly when we learn of new environments that should always do the
original "rigorous" checks.
Fixes: https://github.com/libuv/libuv/issues/501
PR-URL: https://github.com/libuv/libuv/pull/508
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The code made an implicit assumption that the 'len` variable passed
to the sendfile(2) syscall is not modified by the operating system
in case of an error other than EAGAIN or EINTR.
The man page leaves this unspecified on FreeBSD, DragonFly and
Darwin, so better check the error code which returns a valid
value in `len` explicitly (only EAGAIN and EINTR).
This fixes the test case for sendfile on DragonFly.
PR-URL: https://github.com/libuv/libuv/pull/466
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
\r is a single carriage return without line feed on all platforms,
including Windows.
PR-URL: https://github.com/libuv/libuv/pull/472
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Commit 0f1bdb6 ("threadpool: send signal only when queue is empty")
introduces a regression where work is not evenly distributed across
the thread pool because the work queue's condition variable is only
signalled when the queue is empty, even when there are waiting workers.
It doesn't turn into outright deadlock because there is always
at least one thread making forward progress but it does degrade
throughput, sometimes massively so.
Signalling whenever there are waiting workers fixes the throughput
issue while still keeping the number of uv_cond_signal() calls low,
which was the motivation for commit 0f1bdb6.
Fixes: https://github.com/libuv/libuv/pull/490
Fixes: https://github.com/libuv/libuv/issues/492
PR-URL: https://github.com/libuv/libuv/pull/493
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
It's an error to do so, so just ignore it. The test would cause an
invalid memory access if the fix is undone.
PR-URL: https://github.com/libuv/libuv/pull/488
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
On Windows we create multiple pipe handles (system handles) which are
attached to pending accept requests. Each of these will take turns in
replacing the reference in handle->handle, so make sure we allow for
that **only** for pipe servers.
PR-URL: https://github.com/libuv/libuv/pull/488
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
On pipe servers handle->handle takes turns between the different server
handles, so after closing all of them just reset the dandling reference.
PR-URL: https://github.com/libuv/libuv/pull/488
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Makes uv_loop_init return an error code instead of aborting.
Currently uv_loop_init aborts if there are insufficient resources
available. As a user I want to be able to check the return code from
uv_loop_init and decide how I respond rather than having my process die.
PR-URL: https://github.com/libuv/libuv/pull/405
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
fs_event_watch_dir and fs_event_watch_dir_recursive could fail randomly
due to the way in which the tests were written. Originally timers were
used to create, remove and recreate the test files but this could lead
to a race condition if the timeout used to delete the test files ran
before all file creation fs events were handled. On top of that, the
file removal timer scheduled another timer to recreate the test files
and that timer's timeout could also lead to the same condition.
The refactoring removed timers for the removal/recreation of the test
files and instead the fs event callback was updated to have the
necessary logic to drive the test file removal. We no longer recreate
the test files since it appears to be unnecessary.
Fixes: https://github.com/libuv/libuv/issues/30
PR-URL: https://github.com/libuv/libuv/pull/480
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
At least on OS X 10.10 "Yosemite", an EPROTOTYPE can occur
when trying to write to a socket that is shutting down.
By retrying the write after EPROTOTYPE, we correctly get EPIPE.
PR-URL: https://github.com/libuv/libuv/pull/482
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
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>
Join the watchdog thread unconditionally on exit. Fixes the following
harmless but noisy memory leak:
576 bytes in 1 blocks are possibly lost in loss record 1 of 2
at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x40121B4: _dl_allocate_tls (in /usr/lib64/ld-2.21.so)
by 0x5AEA045: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.21.so)
by 0x450D3E: process_wait (runner-unix.c:212)
by 0x4067F1: run_test (runner.c:284)
by 0x405EC3: maybe_run_test (run-tests.c:180)
by 0x4058AD: main (run-tests.c:57)
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
For synchronous file operation requests (ones without a callback), there
is no need to make a copy of the arguments because they don't outlive
the scope of the function call.
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The parentheses are unnecessary because what they wrap are not macro
arguments but function arguments that aren't evaluated by the macro.
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>