Skip to content

Commit 8119693

Browse files
saghulFishrock123
authored andcommitted
deps: update libuv to version 1.7.4
PR-URL: #2817 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent cd1297f commit 8119693

19 files changed

+207
-121
lines changed

deps/uv/AUTHORS

+5
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,8 @@ Zachary Hamm <[email protected]>
219219
Karl Skomski <[email protected]>
220220
Jeremy Whitlock <[email protected]>
221221
Willem Thiart <[email protected]>
222+
Ben Trask <[email protected]>
223+
Jianghua Yang <[email protected]>
224+
Colin Snover <[email protected]>
225+
Sakthipriyan Vairamani <[email protected]>
226+
Eli Skeggs <[email protected]>

deps/uv/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ the [Google C/C++ style guide]. Some of the key points, as well as some
4949
additional guidelines, are enumerated below.
5050

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

5454
* Source code that is Windows-specific goes into `src/win`, and related
5555
publicly exported types, functions and macro declarations should generally

deps/uv/ChangeLog

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
2015.09.12, Version 1.7.4 (Stable), a7ad4f52189d89cfcba35f78bfc5ff3b1f4105c4
2+
3+
Changes since version 1.7.3:
4+
5+
* doc: uv_read_start and uv_read_cb clarifications (Ben Trask)
6+
7+
* freebsd: obtain true uptime through clock_gettime() (Jianghua Yang)
8+
9+
* win, tty: do not convert \r to \r\n (Colin Snover)
10+
11+
* build,gyp: add DragonFly to the list of OSes (Michael Neumann)
12+
13+
* fs: fix bug in sendfile for DragonFly (Michael Neumann)
14+
15+
* doc: add uv_dlsym() return type (Brian White)
16+
17+
* tests: fix fs tests run w/o full getdents support (Jeremy Whitlock)
18+
19+
* doc: fix typo (Devchandra Meetei Leishangthem)
20+
21+
* doc: fix uv-unix.h location (Sakthipriyan Vairamani)
22+
23+
* unix: fix error check when closing process pipe fd (Ben Noordhuis)
24+
25+
* test,freebsd: fix ipc_listen_xx_write tests (Santiago Gimeno)
26+
27+
* win: fix unsavory rwlock fallback implementation (Bert Belder)
28+
29+
* doc: clarify repeat timer behavior (Eli Skeggs)
30+
31+
132
2015.08.28, Version 1.7.3 (Stable), 93877b11c8b86e0a6befcda83a54555c1e36e4f0
233

334
Changes since version 1.7.2:

deps/uv/appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: v1.7.3.build{build}
1+
version: v1.7.4.build{build}
22

33
install:
44
- cinst -y nsis

deps/uv/common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
}]
130130
]
131131
}],
132-
['OS in "freebsd linux openbsd solaris android"', {
132+
['OS in "freebsd dragonflybsd linux openbsd solaris android"', {
133133
'cflags': [ '-Wall' ],
134134
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
135135
'target_conditions': [

deps/uv/configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
AC_PREREQ(2.57)
16-
AC_INIT([libuv], [1.7.3], [https://github.com/libuv/libuv/issues])
16+
AC_INIT([libuv], [1.7.4], [https://github.com/libuv/libuv/issues])
1717
AC_CONFIG_MACRO_DIR([m4])
1818
m4_include([m4/libuv-extra-automake-flags.m4])
1919
m4_include([m4/as_case.m4])

deps/uv/docs/src/dll.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ API
3434
3535
Close the shared library.
3636
37-
.. c:function:: uv_dlsym(uv_lib_t* lib, const char* name, void** ptr)
37+
.. c:function:: int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr)
3838
3939
Retrieves a data pointer from a dynamic library. It is legal for a symbol
4040
to map to NULL. Returns 0 on success and -1 if the symbol was not found.

deps/uv/docs/src/request.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Data types
2525
Public members
2626
^^^^^^^^^^^^^^
2727

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

deps/uv/docs/src/stream.rst

+11-13
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ Data types
3232
3333
Callback called when data was read on a stream.
3434

35-
`nread` is > 0 if there is data available, 0 if libuv is done reading for
36-
now, or < 0 on error.
35+
`nread` is > 0 if there is data available or < 0 on error. When we've
36+
reached EOF, `nread` will be set to ``UV_EOF``. When `nread` < 0,
37+
the `buf` parameter might not point to a valid buffer; in that case
38+
`buf.len` and `buf.base` are both set to 0.
39+
40+
.. note::
41+
`nread` might be 0, which does *not* indicate an error or EOF. This
42+
is equivalent to ``EAGAIN`` or ``EWOULDBLOCK`` under ``read(2)``.
3743

3844
The callee is responsible for stopping closing the stream when an error happens
3945
by calling :c:func:`uv_read_stop` or :c:func:`uv_close`. Trying to read
@@ -125,17 +131,9 @@ API
125131
126132
.. c:function:: int uv_read_start(uv_stream_t* stream, uv_alloc_cb alloc_cb, uv_read_cb read_cb)
127133
128-
Read data from an incoming stream. The callback will be made several
129-
times until there is no more data to read or :c:func:`uv_read_stop` is called.
130-
When we've reached EOF `nread` will be set to ``UV_EOF``.
131-
132-
When `nread` < 0, the `buf` parameter might not point to a valid buffer;
133-
in that case `buf.len` and `buf.base` are both set to 0.
134-
135-
.. note::
136-
`nread` might also be 0, which does *not* indicate an error or EOF, it happens when
137-
libuv requested a buffer through the alloc callback but then decided that it didn't
138-
need that buffer.
134+
Read data from an incoming stream. The :c:type:`uv_read_cb` callback will
135+
be made several times until there is no more data to read or
136+
:c:func:`uv_read_stop` is called.
139137
140138
.. c:function:: int uv_read_stop(uv_stream_t*)
141139

deps/uv/docs/src/timer.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ API
5454
5555
.. c:function:: void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat)
5656
57-
Set the repeat value in milliseconds.
57+
Set the repeat interval value in milliseconds. The timer will be scheduled
58+
to run on the given interval, regardless of the callback execution
59+
duration, and will follow normal timer semantics in the case of a
60+
time-slice overrun.
61+
62+
For example, if a 50ms repeating timer first runs for 17ms, it will be
63+
scheduled to run again 33ms later. If other tasks consume more than the
64+
33ms following the first timer callback, then the callback will run as soon
65+
as possible.
5866
5967
.. note::
6068
If the repeat value is set from a timer callback it does not immediately take effect.

deps/uv/include/uv-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define UV_VERSION_MAJOR 1
3434
#define UV_VERSION_MINOR 7
35-
#define UV_VERSION_PATCH 3
35+
#define UV_VERSION_PATCH 4
3636
#define UV_VERSION_IS_RELEASE 1
3737
#define UV_VERSION_SUFFIX ""
3838

deps/uv/include/uv-win.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,16 @@ typedef union {
250250
/* windows.h. */
251251
SRWLOCK srwlock_;
252252
struct {
253-
uv_mutex_t read_mutex_;
254-
uv_mutex_t write_mutex_;
253+
union {
254+
CRITICAL_SECTION cs;
255+
/* TODO: remove me in v2.x. */
256+
uv_mutex_t unused;
257+
} read_lock_;
258+
union {
259+
HANDLE sem;
260+
/* TODO: remove me in v2.x. */
261+
uv_mutex_t unused;
262+
} write_lock_;
255263
unsigned int num_readers_;
256264
} fallback_;
257265
} uv_rwlock_t;

deps/uv/src/unix/freebsd.c

+5-9
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,13 @@ int uv_resident_set_memory(size_t* rss) {
240240

241241

242242
int uv_uptime(double* uptime) {
243-
time_t now;
244-
struct timeval info;
245-
size_t size = sizeof(info);
246-
static int which[] = {CTL_KERN, KERN_BOOTTIME};
247-
248-
if (sysctl(which, 2, &info, &size, NULL, 0))
243+
int r;
244+
struct timespec sp;
245+
r = clock_gettime(CLOCK_MONOTONIC, &sp);
246+
if (r)
249247
return -errno;
250248

251-
now = time(NULL);
252-
253-
*uptime = (double)(now - info.tv_sec);
249+
*uptime = sp.tv_sec;
254250
return 0;
255251
}
256252

deps/uv/src/unix/fs.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,14 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
574574
r = sendfile(in_fd, out_fd, req->off, &len, NULL, 0);
575575
#endif
576576

577-
if (r != -1 || len != 0) {
577+
/*
578+
* The man page for sendfile(2) on DragonFly states that `len` contains
579+
* a meaningful value ONLY in case of EAGAIN and EINTR.
580+
* Nothing is said about it's value in case of other errors, so better
581+
* not depend on the potential wrong assumption that is was not modified
582+
* by the syscall.
583+
*/
584+
if (r == 0 || ((errno == EAGAIN || errno == EINTR) && len != 0)) {
578585
req->off += len;
579586
return (ssize_t) len;
580587
}

deps/uv/src/unix/process.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,14 @@ static int uv__process_open_stream(uv_stdio_container_t* container,
226226
int pipefds[2],
227227
int writable) {
228228
int flags;
229+
int err;
229230

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

233-
if (uv__close(pipefds[1]))
234-
if (errno != EINTR && errno != EINPROGRESS)
235-
abort();
234+
err = uv__close(pipefds[1]);
235+
if (err != 0 && err != -EINPROGRESS)
236+
abort();
236237

237238
pipefds[1] = -1;
238239
uv__nonblock(pipefds[0], 1);

deps/uv/src/win/thread.c

+57-35
Original file line numberDiff line numberDiff line change
@@ -396,83 +396,105 @@ static void uv__rwlock_srwlock_wrunlock(uv_rwlock_t* rwlock) {
396396

397397

398398
static int uv__rwlock_fallback_init(uv_rwlock_t* rwlock) {
399-
int err;
400-
401-
err = uv_mutex_init(&rwlock->fallback_.read_mutex_);
402-
if (err)
403-
return err;
399+
/* Initialize the semaphore that acts as the write lock. */
400+
HANDLE handle = CreateSemaphoreW(NULL, 1, 1, NULL);
401+
if (handle == NULL)
402+
return uv_translate_sys_error(GetLastError());
403+
rwlock->fallback_.write_lock_.sem = handle;
404404

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

408+
/* Initialize the reader count. */
411409
rwlock->fallback_.num_readers_ = 0;
412410

413411
return 0;
414412
}
415413

416414

417415
static void uv__rwlock_fallback_destroy(uv_rwlock_t* rwlock) {
418-
uv_mutex_destroy(&rwlock->fallback_.read_mutex_);
419-
uv_mutex_destroy(&rwlock->fallback_.write_mutex_);
416+
DeleteCriticalSection(&rwlock->fallback_.read_lock_.cs);
417+
CloseHandle(rwlock->fallback_.write_lock_.sem);
420418
}
421419

422420

423421
static void uv__rwlock_fallback_rdlock(uv_rwlock_t* rwlock) {
424-
uv_mutex_lock(&rwlock->fallback_.read_mutex_);
425-
426-
if (++rwlock->fallback_.num_readers_ == 1)
427-
uv_mutex_lock(&rwlock->fallback_.write_mutex_);
422+
/* Acquire the lock that protects the reader count. */
423+
EnterCriticalSection(&rwlock->fallback_.read_lock_.cs);
424+
425+
/* Increase the reader count, and lock for write if this is the first
426+
* reader.
427+
*/
428+
if (++rwlock->fallback_.num_readers_ == 1) {
429+
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, INFINITE);
430+
if (r != WAIT_OBJECT_0)
431+
uv_fatal_error(GetLastError(), "WaitForSingleObject");
432+
}
428433

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

432438

433439
static int uv__rwlock_fallback_tryrdlock(uv_rwlock_t* rwlock) {
434440
int err;
435441

436-
err = uv_mutex_trylock(&rwlock->fallback_.read_mutex_);
437-
if (err)
438-
goto out;
442+
if (!TryEnterCriticalSection(&rwlock->fallback_.read_lock_.cs))
443+
return UV_EAGAIN;
439444

440445
err = 0;
441-
if (rwlock->fallback_.num_readers_ == 0)
442-
err = uv_mutex_trylock(&rwlock->fallback_.write_mutex_);
443-
444-
if (err == 0)
445-
rwlock->fallback_.num_readers_++;
446-
447-
uv_mutex_unlock(&rwlock->fallback_.read_mutex_);
446+
if (rwlock->fallback_.num_readers_ == 0) {
447+
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, 0);
448+
if (r == WAIT_OBJECT_0)
449+
rwlock->fallback_.num_readers_++;
450+
else if (r == WAIT_TIMEOUT)
451+
err = UV_EAGAIN;
452+
else if (r == WAIT_FAILED)
453+
err = uv_translate_sys_error(GetLastError());
454+
else
455+
err = UV_EIO;
456+
}
448457

449-
out:
458+
LeaveCriticalSection(&rwlock->fallback_.read_lock_.cs);
450459
return err;
451460
}
452461

453462

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

457-
if (--rwlock->fallback_.num_readers_ == 0)
458-
uv_mutex_unlock(&rwlock->fallback_.write_mutex_);
466+
if (--rwlock->fallback_.num_readers_ == 0) {
467+
if (!ReleaseSemaphore(rwlock->fallback_.write_lock_.sem, 1, NULL))
468+
uv_fatal_error(GetLastError(), "ReleaseSemaphore");
469+
}
459470

460-
uv_mutex_unlock(&rwlock->fallback_.read_mutex_);
471+
LeaveCriticalSection(&rwlock->fallback_.read_lock_.cs);
461472
}
462473

463474

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

468481

469482
static int uv__rwlock_fallback_trywrlock(uv_rwlock_t* rwlock) {
470-
return uv_mutex_trylock(&rwlock->fallback_.write_mutex_);
483+
DWORD r = WaitForSingleObject(rwlock->fallback_.write_lock_.sem, 0);
484+
if (r == WAIT_OBJECT_0)
485+
return 0;
486+
else if (r == WAIT_TIMEOUT)
487+
return UV_EAGAIN;
488+
else if (r == WAIT_FAILED)
489+
return uv_translate_sys_error(GetLastError());
490+
else
491+
return UV_EIO;
471492
}
472493

473494

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

478500

0 commit comments

Comments
 (0)