Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
uv: Upgrade to 0.10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 23, 2013
1 parent c777473 commit ff99cd5
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 104 deletions.
1 change: 1 addition & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ Marc Schlaich <marc.schlaich@googlemail.com>
Brian Mazza <louseman@gmail.com>
Nils Maier <maierman@web.de>
Nicholas Vavilov <vvnicholas@gmail.com>
Miroslav Bajtoš <miro.bajtos@gmail.com>
21 changes: 18 additions & 3 deletions deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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:

Expand All @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions deps/uv/src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
137 changes: 49 additions & 88 deletions deps/uv/src/unix/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 1 addition & 4 deletions deps/uv/src/win/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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 */
Expand Down
17 changes: 14 additions & 3 deletions deps/uv/src/win/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ff99cd5

Please sign in to comment.