Skip to content

Commit ff99cd5

Browse files
committed
uv: Upgrade to 0.10.5
1 parent c777473 commit ff99cd5

8 files changed

Lines changed: 87 additions & 104 deletions

File tree

deps/uv/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ Marc Schlaich <marc.schlaich@googlemail.com>
8181
Brian Mazza <louseman@gmail.com>
8282
Nils Maier <maierman@web.de>
8383
Nicholas Vavilov <vvnicholas@gmail.com>
84+
Miroslav Bajtoš <miro.bajtos@gmail.com>

deps/uv/ChangeLog

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
2013.04.12, Version 0.10.4 (Stable)
1+
2013.04.24, Version 0.10.5 (Stable)
2+
3+
Changes since version 0.10.4:
4+
5+
* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis)
6+
7+
* windows: make timers handle large timeouts (Miroslav Bajtoš)
8+
9+
* windows: remove superfluous assert statement (Bert Belder)
10+
11+
* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis)
12+
13+
* linux: don't use fopen() in uv_resident_set_memory() (Ben Noordhuis)
14+
15+
16+
2013.04.12, Version 0.10.4 (Stable), 85827e26403ac6dfa331af8ec9916ea7e27bd833
217

318
Changes since version 0.10.3:
419

@@ -33,7 +48,7 @@ Changes since version 0.10.3:
3348
* build: -Wno-dollar-in-identifier-extension is clang only (Ben Noordhuis)
3449

3550

36-
2013.02.04, Version 0.10.3 (Stable)
51+
2013.02.04, Version 0.10.3 (Stable), 31ebe23973dd98fd8a24c042b606f37a794e99d0
3752

3853
Changes since version 0.10.2:
3954

@@ -50,7 +65,7 @@ Changes since version 0.10.2:
5065
* unix: don't clear flags after closing UDP handle (Saúl Ibarra Corretgé)
5166

5267

53-
2013.03.25, Version 0.10.2 (Stable)
68+
2013.03.25, Version 0.10.2 (Stable), 0f36a00568f3e7608f97f6c6cdb081f4800a50c9
5469

5570
This is the first officially versioned release of libuv. Starting now
5671
libuv will make releases independently of Node.js.

deps/uv/src/unix/core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->base) ==
7171
sizeof(((struct iovec*) 0)->iov_base));
7272
STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->len) ==
7373
sizeof(((struct iovec*) 0)->iov_len));
74-
STATIC_ASSERT((uintptr_t) &((uv_buf_t*) 0)->base ==
75-
(uintptr_t) &((struct iovec*) 0)->iov_base);
76-
STATIC_ASSERT((uintptr_t) &((uv_buf_t*) 0)->len ==
77-
(uintptr_t) &((struct iovec*) 0)->iov_len);
74+
STATIC_ASSERT(offsetof(uv_buf_t, base) == offsetof(struct iovec, iov_base));
75+
STATIC_ASSERT(offsetof(uv_buf_t, len) == offsetof(struct iovec, iov_len));
7876

7977

8078
uint64_t uv_hrtime(void) {

deps/uv/src/unix/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#endif
4747

4848
#define STATIC_ASSERT(expr) \
49-
void uv__static_assert(int static_assert_failed[0 - !(expr)])
49+
void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)])
5050

5151
#define ACCESS_ONCE(type, var) \
5252
(*(volatile type*) &(var))

deps/uv/src/unix/linux-core.c

Lines changed: 49 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -284,98 +284,59 @@ uint64_t uv_get_total_memory(void) {
284284

285285

286286
uv_err_t uv_resident_set_memory(size_t* rss) {
287-
FILE* f;
288-
int itmp;
289-
char ctmp;
290-
unsigned int utmp;
291-
size_t page_size = getpagesize();
292-
char *cbuf;
293-
int foundExeEnd;
294-
char buf[PATH_MAX + 1];
295-
296-
f = fopen("/proc/self/stat", "r");
297-
if (!f) return uv__new_sys_error(errno);
298-
299-
/* PID */
300-
if (fscanf(f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
301-
/* Exec file */
302-
cbuf = buf;
303-
foundExeEnd = 0;
304-
if (fscanf (f, "%c", cbuf++) == 0) goto error;
305-
while (1) {
306-
if (fscanf(f, "%c", cbuf) == 0) goto error;
307-
if (*cbuf == ')') {
308-
foundExeEnd = 1;
309-
} else if (foundExeEnd && *cbuf == ' ') {
310-
*cbuf = 0;
311-
break;
312-
}
287+
char buf[1024];
288+
const char* s;
289+
ssize_t n;
290+
long val;
291+
int fd;
292+
int i;
293+
294+
do
295+
fd = open("/proc/self/stat", O_RDONLY);
296+
while (fd == -1 && errno == EINTR);
297+
298+
if (fd == -1)
299+
return uv__new_sys_error(errno);
300+
301+
do
302+
n = read(fd, buf, sizeof(buf) - 1);
303+
while (n == -1 && errno == EINTR);
304+
305+
SAVE_ERRNO(close(fd));
306+
if (n == -1)
307+
return uv__new_sys_error(errno);
308+
buf[n] = '\0';
309+
310+
s = strchr(buf, ' ');
311+
if (s == NULL)
312+
goto err;
313313

314-
cbuf++;
314+
s += 1;
315+
if (*s != '(')
316+
goto err;
317+
318+
s = strchr(s, ')');
319+
if (s == NULL)
320+
goto err;
321+
322+
for (i = 1; i <= 22; i++) {
323+
s = strchr(s + 1, ' ');
324+
if (s == NULL)
325+
goto err;
315326
}
316-
/* State */
317-
if (fscanf (f, "%c ", &ctmp) == 0) goto error; /* coverity[secure_coding] */
318-
/* Parent process */
319-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
320-
/* Process group */
321-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
322-
/* Session id */
323-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
324-
/* TTY */
325-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
326-
/* TTY owner process group */
327-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
328-
/* Flags */
329-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
330-
/* Minor faults (no memory page) */
331-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
332-
/* Minor faults, children */
333-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
334-
/* Major faults (memory page faults) */
335-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
336-
/* Major faults, children */
337-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
338-
/* utime */
339-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
340-
/* stime */
341-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
342-
/* utime, children */
343-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
344-
/* stime, children */
345-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
346-
/* jiffies remaining in current time slice */
347-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
348-
/* 'nice' value */
349-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
350-
/* jiffies until next timeout */
351-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
352-
/* jiffies until next SIGALRM */
353-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
354-
/* start time (jiffies since system boot) */
355-
if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */
356-
357-
/* Virtual memory size */
358-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
359-
360-
/* Resident set size */
361-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
362-
*rss = (size_t) utmp * page_size;
363-
364-
/* rlim */
365-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
366-
/* Start of text */
367-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
368-
/* End of text */
369-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
370-
/* Start of stack */
371-
if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */
372-
373-
fclose (f);
327+
328+
errno = 0;
329+
val = strtol(s, NULL, 10);
330+
if (errno != 0)
331+
goto err;
332+
if (val < 0)
333+
goto err;
334+
335+
*rss = val * getpagesize();
374336
return uv_ok_;
375337

376-
error:
377-
fclose (f);
378-
return uv__new_sys_error(errno);
338+
err:
339+
return uv__new_artificial_error(UV_EINVAL);
379340
}
380341

381342

deps/uv/src/version.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define UV_VERSION_MAJOR 0
3434
#define UV_VERSION_MINOR 10
35-
#define UV_VERSION_PATCH 4
35+
#define UV_VERSION_PATCH 5
3636
#define UV_VERSION_IS_RELEASE 1
3737

3838

deps/uv/src/win/core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ static void uv_poll(uv_loop_t* loop, int block) {
205205
if (overlapped) {
206206
/* Package was dequeued */
207207
req = uv_overlapped_to_req(overlapped);
208-
209208
uv_insert_pending_req(loop, req);
210-
211209
} else if (GetLastError() != WAIT_TIMEOUT) {
212210
/* Serious error */
213211
uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus");
@@ -229,14 +227,13 @@ static void uv_poll_ex(uv_loop_t* loop, int block) {
229227
timeout = 0;
230228
}
231229

232-
assert(pGetQueuedCompletionStatusEx);
233-
234230
success = pGetQueuedCompletionStatusEx(loop->iocp,
235231
overlappeds,
236232
ARRAY_SIZE(overlappeds),
237233
&count,
238234
timeout,
239235
FALSE);
236+
240237
if (success) {
241238
for (i = 0; i < count; i++) {
242239
/* Package was dequeued */

deps/uv/src/win/timer.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) {
8787
}
8888

8989

90+
static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) {
91+
uint64_t clamped_timeout;
92+
93+
clamped_timeout = loop_time + timeout;
94+
if (clamped_timeout < timeout)
95+
clamped_timeout = (uint64_t) -1;
96+
97+
return clamped_timeout;
98+
}
99+
100+
90101
int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout,
91102
uint64_t repeat) {
92103
uv_loop_t* loop = handle->loop;
@@ -97,7 +108,7 @@ int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout,
97108
}
98109

99110
handle->timer_cb = timer_cb;
100-
handle->due = loop->time + timeout;
111+
handle->due = get_clamped_due_time(loop->time, timeout);
101112
handle->repeat = repeat;
102113
handle->flags |= UV_HANDLE_ACTIVE;
103114
uv__handle_start(handle);
@@ -143,7 +154,7 @@ int uv_timer_again(uv_timer_t* handle) {
143154
}
144155

145156
if (handle->repeat) {
146-
handle->due = loop->time + handle->repeat;
157+
handle->due = get_clamped_due_time(loop->time, handle->repeat);
147158

148159
if (RB_INSERT(uv_timer_tree_s, &loop->timers, handle) != NULL) {
149160
uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT");
@@ -212,7 +223,7 @@ void uv_process_timers(uv_loop_t* loop) {
212223

213224
if (timer->repeat != 0) {
214225
/* If it is a repeating timer, reschedule with repeat timeout. */
215-
timer->due += timer->repeat;
226+
timer->due = get_clamped_due_time(timer->due, timer->repeat);
216227
if (timer->due < loop->time) {
217228
timer->due = loop->time;
218229
}

0 commit comments

Comments
 (0)