Skip to content

Commit

Permalink
deps: update libuv to version 1.7.4
Browse files Browse the repository at this point in the history
PR-URL: #2817
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
saghul authored and bnoordhuis committed Sep 11, 2015
1 parent 958a94e commit 68dc69a
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 121 deletions.
5 changes: 5 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,8 @@ Zachary Hamm <zsh@imipolexg.org>
Karl Skomski <karl@skomski.com>
Jeremy Whitlock <jwhitlock@apache.org>
Willem Thiart <himself@willemthiart.com>
Ben Trask <bentrask@comcast.net>
Jianghua Yang <jianghua.yjh@alibaba-inc.com>
Colin Snover <github.com@zetafleet.com>
Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Eli Skeggs <skeggse@gmail.com>
2 changes: 1 addition & 1 deletion deps/uv/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ the [Google C/C++ style guide]. Some of the key points, as well as some
additional guidelines, are enumerated below.

* Code that is specific to unix-y platforms should be placed in `src/unix`, and
declarations go into `src/uv-unix.h`.
declarations go into `include/uv-unix.h`.

* Source code that is Windows-specific goes into `src/win`, and related
publicly exported types, functions and macro declarations should generally
Expand Down
31 changes: 31 additions & 0 deletions deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
2015.09.12, Version 1.7.4 (Stable), a7ad4f52189d89cfcba35f78bfc5ff3b1f4105c4

Changes since version 1.7.3:

* doc: uv_read_start and uv_read_cb clarifications (Ben Trask)

* freebsd: obtain true uptime through clock_gettime() (Jianghua Yang)

* win, tty: do not convert \r to \r\n (Colin Snover)

* build,gyp: add DragonFly to the list of OSes (Michael Neumann)

* fs: fix bug in sendfile for DragonFly (Michael Neumann)

* doc: add uv_dlsym() return type (Brian White)

* tests: fix fs tests run w/o full getdents support (Jeremy Whitlock)

* doc: fix typo (Devchandra Meetei Leishangthem)

* doc: fix uv-unix.h location (Sakthipriyan Vairamani)

* unix: fix error check when closing process pipe fd (Ben Noordhuis)

* test,freebsd: fix ipc_listen_xx_write tests (Santiago Gimeno)

* win: fix unsavory rwlock fallback implementation (Bert Belder)

* doc: clarify repeat timer behavior (Eli Skeggs)


2015.08.28, Version 1.7.3 (Stable), 93877b11c8b86e0a6befcda83a54555c1e36e4f0

Changes since version 1.7.2:
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v1.7.3.build{build}
version: v1.7.4.build{build}

install:
- cinst -y nsis
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
}]
]
}],
['OS in "freebsd linux openbsd solaris android"', {
['OS in "freebsd dragonflybsd linux openbsd solaris android"', {
'cflags': [ '-Wall' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
'target_conditions': [
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

AC_PREREQ(2.57)
AC_INIT([libuv], [1.7.3], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.7.4], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4])
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/docs/src/dll.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ API
Close the shared library.
.. c:function:: uv_dlsym(uv_lib_t* lib, const char* name, void** ptr)
.. c:function:: int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr)
Retrieves a data pointer from a dynamic library. It is legal for a symbol
to map to NULL. Returns 0 on success and -1 if the symbol was not found.
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/docs/src/request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Data types
Public members
^^^^^^^^^^^^^^

.. c:member:: void* uv_request_t.data
.. c:member:: void* uv_req_t.data
Space for user-defined arbitrary data. libuv does not use this field.

Expand Down
24 changes: 11 additions & 13 deletions deps/uv/docs/src/stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ Data types
Callback called when data was read on a stream.

`nread` is > 0 if there is data available, 0 if libuv is done reading for
now, or < 0 on error.
`nread` is > 0 if there is data available or < 0 on error. When we've
reached EOF, `nread` will be set to ``UV_EOF``. When `nread` < 0,
the `buf` parameter might not point to a valid buffer; in that case
`buf.len` and `buf.base` are both set to 0.

.. note::
`nread` might be 0, which does *not* indicate an error or EOF. This
is equivalent to ``EAGAIN`` or ``EWOULDBLOCK`` under ``read(2)``.

The callee is responsible for stopping closing the stream when an error happens
by calling :c:func:`uv_read_stop` or :c:func:`uv_close`. Trying to read
Expand Down Expand Up @@ -125,17 +131,9 @@ API
.. c:function:: int uv_read_start(uv_stream_t* stream, uv_alloc_cb alloc_cb, uv_read_cb read_cb)
Read data from an incoming stream. The callback will be made several
times until there is no more data to read or :c:func:`uv_read_stop` is called.
When we've reached EOF `nread` will be set to ``UV_EOF``.
When `nread` < 0, the `buf` parameter might not point to a valid buffer;
in that case `buf.len` and `buf.base` are both set to 0.

.. note::
`nread` might also be 0, which does *not* indicate an error or EOF, it happens when
libuv requested a buffer through the alloc callback but then decided that it didn't
need that buffer.
Read data from an incoming stream. The :c:type:`uv_read_cb` callback will
be made several times until there is no more data to read or
:c:func:`uv_read_stop` is called.
.. c:function:: int uv_read_stop(uv_stream_t*)
Expand Down
10 changes: 9 additions & 1 deletion deps/uv/docs/src/timer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ API
.. c:function:: void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat)
Set the repeat value in milliseconds.
Set the repeat interval value in milliseconds. The timer will be scheduled
to run on the given interval, regardless of the callback execution
duration, and will follow normal timer semantics in the case of a
time-slice overrun.
For example, if a 50ms repeating timer first runs for 17ms, it will be
scheduled to run again 33ms later. If other tasks consume more than the
33ms following the first timer callback, then the callback will run as soon
as possible.
.. note::
If the repeat value is set from a timer callback it does not immediately take effect.
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/include/uv-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 7
#define UV_VERSION_PATCH 3
#define UV_VERSION_PATCH 4
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""

Expand Down
12 changes: 10 additions & 2 deletions deps/uv/include/uv-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,16 @@ typedef union {
/* windows.h. */
SRWLOCK srwlock_;
struct {
uv_mutex_t read_mutex_;
uv_mutex_t write_mutex_;
union {
CRITICAL_SECTION cs;
/* TODO: remove me in v2.x. */
uv_mutex_t unused;
} read_lock_;
union {
HANDLE sem;
/* TODO: remove me in v2.x. */
uv_mutex_t unused;
} write_lock_;
unsigned int num_readers_;
} fallback_;
} uv_rwlock_t;
Expand Down
14 changes: 5 additions & 9 deletions deps/uv/src/unix/freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,13 @@ int uv_resident_set_memory(size_t* rss) {


int uv_uptime(double* uptime) {
time_t now;
struct timeval info;
size_t size = sizeof(info);
static int which[] = {CTL_KERN, KERN_BOOTTIME};

if (sysctl(which, 2, &info, &size, NULL, 0))
int r;
struct timespec sp;
r = clock_gettime(CLOCK_MONOTONIC, &sp);
if (r)
return -errno;

now = time(NULL);

*uptime = (double)(now - info.tv_sec);
*uptime = sp.tv_sec;
return 0;
}

Expand Down
9 changes: 8 additions & 1 deletion deps/uv/src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,14 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
r = sendfile(in_fd, out_fd, req->off, &len, NULL, 0);
#endif

if (r != -1 || len != 0) {
/*
* The man page for sendfile(2) on DragonFly states that `len` contains
* a meaningful value ONLY in case of EAGAIN and EINTR.
* Nothing is said about it's value in case of other errors, so better
* not depend on the potential wrong assumption that is was not modified
* by the syscall.
*/
if (r == 0 || ((errno == EAGAIN || errno == EINTR) && len != 0)) {
req->off += len;
return (ssize_t) len;
}
Expand Down
7 changes: 4 additions & 3 deletions deps/uv/src/unix/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,14 @@ static int uv__process_open_stream(uv_stdio_container_t* container,
int pipefds[2],
int writable) {
int flags;
int err;

if (!(container->flags & UV_CREATE_PIPE) || pipefds[0] < 0)
return 0;

if (uv__close(pipefds[1]))
if (errno != EINTR && errno != EINPROGRESS)
abort();
err = uv__close(pipefds[1]);
if (err != 0 && err != -EINPROGRESS)
abort();

pipefds[1] = -1;
uv__nonblock(pipefds[0], 1);
Expand Down
92 changes: 57 additions & 35 deletions deps/uv/src/win/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,83 +396,105 @@ static void uv__rwlock_srwlock_wrunlock(uv_rwlock_t* rwlock) {


static int uv__rwlock_fallback_init(uv_rwlock_t* rwlock) {
int err;

err = uv_mutex_init(&rwlock->fallback_.read_mutex_);
if (err)
return err;
/* Initialize the semaphore that acts as the write lock. */
HANDLE handle = CreateSemaphoreW(NULL, 1, 1, NULL);
if (handle == NULL)
return uv_translate_sys_error(GetLastError());
rwlock->fallback_.write_lock_.sem = handle;

err = uv_mutex_init(&rwlock->fallback_.write_mutex_);
if (err) {
uv_mutex_destroy(&rwlock->fallback_.read_mutex_);
return err;
}
/* Initialize the critical section protecting the reader count. */
InitializeCriticalSection(&rwlock->fallback_.read_lock_.cs);

/* Initialize the reader count. */
rwlock->fallback_.num_readers_ = 0;

return 0;
}


static void uv__rwlock_fallback_destroy(uv_rwlock_t* rwlock) {
uv_mutex_destroy(&rwlock->fallback_.read_mutex_);
uv_mutex_destroy(&rwlock->fallback_.write_mutex_);
DeleteCriticalSection(&rwlock->fallback_.read_lock_.cs);
CloseHandle(rwlock->fallback_.write_lock_.sem);
}


static void uv__rwlock_fallback_rdlock(uv_rwlock_t* rwlock) {
uv_mutex_lock(&rwlock->fallback_.read_mutex_);

if (++rwlock->fallback_.num_readers_ == 1)
uv_mutex_lock(&rwlock->fallback_.write_mutex_);
/* Acquire the lock that protects the reader count. */
EnterCriticalSection(&rwlock->fallback_.read_lock_.cs);

/* Increase the reader count, and lock for write if this is the first
* reader.
*/
if (++rwlock->fallback_.num_readers_ == 1) {
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, INFINITE);
if (r != WAIT_OBJECT_0)
uv_fatal_error(GetLastError(), "WaitForSingleObject");
}

uv_mutex_unlock(&rwlock->fallback_.read_mutex_);
/* Release the lock that protects the reader count. */
LeaveCriticalSection(&rwlock->fallback_.read_lock_.cs);
}


static int uv__rwlock_fallback_tryrdlock(uv_rwlock_t* rwlock) {
int err;

err = uv_mutex_trylock(&rwlock->fallback_.read_mutex_);
if (err)
goto out;
if (!TryEnterCriticalSection(&rwlock->fallback_.read_lock_.cs))
return UV_EAGAIN;

err = 0;
if (rwlock->fallback_.num_readers_ == 0)
err = uv_mutex_trylock(&rwlock->fallback_.write_mutex_);

if (err == 0)
rwlock->fallback_.num_readers_++;

uv_mutex_unlock(&rwlock->fallback_.read_mutex_);
if (rwlock->fallback_.num_readers_ == 0) {
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, 0);
if (r == WAIT_OBJECT_0)
rwlock->fallback_.num_readers_++;
else if (r == WAIT_TIMEOUT)
err = UV_EAGAIN;
else if (r == WAIT_FAILED)
err = uv_translate_sys_error(GetLastError());
else
err = UV_EIO;
}

out:
LeaveCriticalSection(&rwlock->fallback_.read_lock_.cs);
return err;
}


static void uv__rwlock_fallback_rdunlock(uv_rwlock_t* rwlock) {
uv_mutex_lock(&rwlock->fallback_.read_mutex_);
EnterCriticalSection(&rwlock->fallback_.read_lock_.cs);

if (--rwlock->fallback_.num_readers_ == 0)
uv_mutex_unlock(&rwlock->fallback_.write_mutex_);
if (--rwlock->fallback_.num_readers_ == 0) {
if (!ReleaseSemaphore(rwlock->fallback_.write_lock_.sem, 1, NULL))
uv_fatal_error(GetLastError(), "ReleaseSemaphore");
}

uv_mutex_unlock(&rwlock->fallback_.read_mutex_);
LeaveCriticalSection(&rwlock->fallback_.read_lock_.cs);
}


static void uv__rwlock_fallback_wrlock(uv_rwlock_t* rwlock) {
uv_mutex_lock(&rwlock->fallback_.write_mutex_);
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, INFINITE);
if (r != WAIT_OBJECT_0)
uv_fatal_error(GetLastError(), "WaitForSingleObject");
}


static int uv__rwlock_fallback_trywrlock(uv_rwlock_t* rwlock) {
return uv_mutex_trylock(&rwlock->fallback_.write_mutex_);
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, 0);
if (r == WAIT_OBJECT_0)
return 0;
else if (r == WAIT_TIMEOUT)
return UV_EAGAIN;
else if (r == WAIT_FAILED)
return uv_translate_sys_error(GetLastError());
else
return UV_EIO;
}


static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock) {
uv_mutex_unlock(&rwlock->fallback_.write_mutex_);
if (!ReleaseSemaphore(rwlock->fallback_.write_lock_.sem, 1, NULL))
uv_fatal_error(GetLastError(), "ReleaseSemaphore");
}


Expand Down
Loading

0 comments on commit 68dc69a

Please sign in to comment.