diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 70ee0ea34f..bfffbbbac7 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -81,3 +81,4 @@ Marc Schlaich Brian Mazza Nils Maier Nicholas Vavilov +Miroslav Bajtoš diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index eaa002902f..257d05c041 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,4 +1,19 @@ -2013.04.12, Version 0.10.4 (Stable) +2013.04.24, Version 0.10.5 (Stable) + +Changes since version 0.10.4: + +* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis) + +* windows: make timers handle large timeouts (Miroslav Bajtoš) + +* windows: remove superfluous assert statement (Bert Belder) + +* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis) + +* linux: don't use fopen() in uv_resident_set_memory() (Ben Noordhuis) + + +2013.04.12, Version 0.10.4 (Stable), 85827e26403ac6dfa331af8ec9916ea7e27bd833 Changes since version 0.10.3: @@ -33,7 +48,7 @@ Changes since version 0.10.3: * build: -Wno-dollar-in-identifier-extension is clang only (Ben Noordhuis) -2013.02.04, Version 0.10.3 (Stable) +2013.02.04, Version 0.10.3 (Stable), 31ebe23973dd98fd8a24c042b606f37a794e99d0 Changes since version 0.10.2: @@ -50,7 +65,7 @@ Changes since version 0.10.2: * unix: don't clear flags after closing UDP handle (Saúl Ibarra Corretgé) -2013.03.25, Version 0.10.2 (Stable) +2013.03.25, Version 0.10.2 (Stable), 0f36a00568f3e7608f97f6c6cdb081f4800a50c9 This is the first officially versioned release of libuv. Starting now libuv will make releases independently of Node.js. diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index b8bae48a57..7ab9bd6c7d 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -71,10 +71,8 @@ STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->base) == sizeof(((struct iovec*) 0)->iov_base)); STATIC_ASSERT(sizeof(&((uv_buf_t*) 0)->len) == sizeof(((struct iovec*) 0)->iov_len)); -STATIC_ASSERT((uintptr_t) &((uv_buf_t*) 0)->base == - (uintptr_t) &((struct iovec*) 0)->iov_base); -STATIC_ASSERT((uintptr_t) &((uv_buf_t*) 0)->len == - (uintptr_t) &((struct iovec*) 0)->iov_len); +STATIC_ASSERT(offsetof(uv_buf_t, base) == offsetof(struct iovec, iov_base)); +STATIC_ASSERT(offsetof(uv_buf_t, len) == offsetof(struct iovec, iov_len)); uint64_t uv_hrtime(void) { diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 899c972b08..61cb1ec1f0 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -46,7 +46,7 @@ #endif #define STATIC_ASSERT(expr) \ - void uv__static_assert(int static_assert_failed[0 - !(expr)]) + void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)]) #define ACCESS_ONCE(type, var) \ (*(volatile type*) &(var)) diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c index daab6f196a..35374b17dc 100644 --- a/deps/uv/src/unix/linux-core.c +++ b/deps/uv/src/unix/linux-core.c @@ -284,98 +284,59 @@ uint64_t uv_get_total_memory(void) { uv_err_t uv_resident_set_memory(size_t* rss) { - FILE* f; - int itmp; - char ctmp; - unsigned int utmp; - size_t page_size = getpagesize(); - char *cbuf; - int foundExeEnd; - char buf[PATH_MAX + 1]; - - f = fopen("/proc/self/stat", "r"); - if (!f) return uv__new_sys_error(errno); - - /* PID */ - if (fscanf(f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* Exec file */ - cbuf = buf; - foundExeEnd = 0; - if (fscanf (f, "%c", cbuf++) == 0) goto error; - while (1) { - if (fscanf(f, "%c", cbuf) == 0) goto error; - if (*cbuf == ')') { - foundExeEnd = 1; - } else if (foundExeEnd && *cbuf == ' ') { - *cbuf = 0; - break; - } + char buf[1024]; + const char* s; + ssize_t n; + long val; + int fd; + int i; + + do + fd = open("/proc/self/stat", O_RDONLY); + while (fd == -1 && errno == EINTR); + + if (fd == -1) + return uv__new_sys_error(errno); + + do + n = read(fd, buf, sizeof(buf) - 1); + while (n == -1 && errno == EINTR); + + SAVE_ERRNO(close(fd)); + if (n == -1) + return uv__new_sys_error(errno); + buf[n] = '\0'; + + s = strchr(buf, ' '); + if (s == NULL) + goto err; - cbuf++; + s += 1; + if (*s != '(') + goto err; + + s = strchr(s, ')'); + if (s == NULL) + goto err; + + for (i = 1; i <= 22; i++) { + s = strchr(s + 1, ' '); + if (s == NULL) + goto err; } - /* State */ - if (fscanf (f, "%c ", &ctmp) == 0) goto error; /* coverity[secure_coding] */ - /* Parent process */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* Process group */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* Session id */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* TTY */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* TTY owner process group */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* Flags */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* Minor faults (no memory page) */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* Minor faults, children */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* Major faults (memory page faults) */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* Major faults, children */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* utime */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* stime */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* utime, children */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* stime, children */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* jiffies remaining in current time slice */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* 'nice' value */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - /* jiffies until next timeout */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* jiffies until next SIGALRM */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* start time (jiffies since system boot) */ - if (fscanf (f, "%d ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - - /* Virtual memory size */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - - /* Resident set size */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - *rss = (size_t) utmp * page_size; - - /* rlim */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* Start of text */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* End of text */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - /* Start of stack */ - if (fscanf (f, "%u ", &utmp) == 0) goto error; /* coverity[secure_coding] */ - - fclose (f); + + errno = 0; + val = strtol(s, NULL, 10); + if (errno != 0) + goto err; + if (val < 0) + goto err; + + *rss = val * getpagesize(); return uv_ok_; -error: - fclose (f); - return uv__new_sys_error(errno); +err: + return uv__new_artificial_error(UV_EINVAL); } diff --git a/deps/uv/src/version.c b/deps/uv/src/version.c index 3388c71bd4..3291d47eeb 100644 --- a/deps/uv/src/version.c +++ b/deps/uv/src/version.c @@ -32,7 +32,7 @@ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 10 -#define UV_VERSION_PATCH 4 +#define UV_VERSION_PATCH 5 #define UV_VERSION_IS_RELEASE 1 diff --git a/deps/uv/src/win/core.c b/deps/uv/src/win/core.c index 9680c7e508..62d6bf8fbb 100644 --- a/deps/uv/src/win/core.c +++ b/deps/uv/src/win/core.c @@ -205,9 +205,7 @@ static void uv_poll(uv_loop_t* loop, int block) { if (overlapped) { /* Package was dequeued */ req = uv_overlapped_to_req(overlapped); - uv_insert_pending_req(loop, req); - } else if (GetLastError() != WAIT_TIMEOUT) { /* Serious error */ uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus"); @@ -229,14 +227,13 @@ static void uv_poll_ex(uv_loop_t* loop, int block) { timeout = 0; } - assert(pGetQueuedCompletionStatusEx); - success = pGetQueuedCompletionStatusEx(loop->iocp, overlappeds, ARRAY_SIZE(overlappeds), &count, timeout, FALSE); + if (success) { for (i = 0; i < count; i++) { /* Package was dequeued */ diff --git a/deps/uv/src/win/timer.c b/deps/uv/src/win/timer.c index 0c055da941..7fd105713d 100644 --- a/deps/uv/src/win/timer.c +++ b/deps/uv/src/win/timer.c @@ -87,6 +87,17 @@ void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) { } +static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) { + uint64_t clamped_timeout; + + clamped_timeout = loop_time + timeout; + if (clamped_timeout < timeout) + clamped_timeout = (uint64_t) -1; + + return clamped_timeout; +} + + int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout, uint64_t repeat) { 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, } handle->timer_cb = timer_cb; - handle->due = loop->time + timeout; + handle->due = get_clamped_due_time(loop->time, timeout); handle->repeat = repeat; handle->flags |= UV_HANDLE_ACTIVE; uv__handle_start(handle); @@ -143,7 +154,7 @@ int uv_timer_again(uv_timer_t* handle) { } if (handle->repeat) { - handle->due = loop->time + handle->repeat; + handle->due = get_clamped_due_time(loop->time, handle->repeat); if (RB_INSERT(uv_timer_tree_s, &loop->timers, handle) != NULL) { uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT"); @@ -212,7 +223,7 @@ void uv_process_timers(uv_loop_t* loop) { if (timer->repeat != 0) { /* If it is a repeating timer, reschedule with repeat timeout. */ - timer->due += timer->repeat; + timer->due = get_clamped_due_time(timer->due, timer->repeat); if (timer->due < loop->time) { timer->due = loop->time; }