Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v0.10'
Browse files Browse the repository at this point in the history
Conflicts:
	ChangeLog
	src/version.c
  • Loading branch information
bnoordhuis committed May 2, 2013
2 parents c777079 + b3ab332 commit ebdeaed
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 191 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ Ben Kelly <ben@wanderview.com>
Kristian Evensen <kristian.evensen@gmail.com>
Nils Maier <maierman@web.de>
Nicholas Vavilov <vvnicholas@gmail.com>
Miroslav Bajtoš <miro.bajtos@gmail.com>
73 changes: 43 additions & 30 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
2013.04.11, Version 0.11.1 (Unstable), 5c10e82ae0bc99eff86d4b9baff1f1aa0bf84c0a
2013.04.24, Version 0.10.5 (Stable), 6595a7732c52eb4f8e57c88655f72997a8567a67

This is the first versioned release from the current unstable libuv branch.
Changes since version 0.10.4:

Changes since Node.js v0.11.0:
* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis)

* all platforms: nanosecond resolution support for uv_fs_[fl]stat (Timothy J.
Fontaine)
* windows: make timers handle large timeouts (Miroslav Bajtoš)

* all platforms: add netmask to uv_interface_address (Ben Kelly)
* windows: remove superfluous assert statement (Bert Belder)

* unix: make sure the `status` parameter passed to the `uv_getaddrinfo` is 0 or
-1 (Ben Noordhuis)
* unix: silence STATIC_ASSERT compiler warnings (Ben Noordhuis)

* unix: limit the number of iovecs written in a single `writev` syscall to
IOV_MAX (Fedor Indutny)

* unix: add dtrace probes for tick-start and tick-stop (Timothy J. Fontaine)

* mingw-w64: don't call _set_invalid_parameter_handler (Nils Maier)

* windows: fix memory leak in fs__sendfile (Shannen Saez)

* windows: fix edge case bugs in uv_cpu_info (Bert Belder)

* include: no longer ship with / include ngx-queue.h (Ben Noordhuis)

* include: remove UV_VERSION_* macros from uv.h (Ben Noordhuis)

* documentation updates (Kristian Evensen, Ben Kelly, Ben Noordhuis)

* build: fix dtrace-enabled builds (Ben Noordhuis, Timothy J. Fontaine)

* build: gyp disable thin archives (Timothy J. Fontaine)

* build: add support for Visual Studio 2012 (Nicholas Vavilov)
* linux: don't use fopen() in uv_resident_set_memory() (Ben Noordhuis)


2013.04.12, Version 0.10.4 (Stable), 85827e26403ac6dfa331af8ec9916ea7e27bd833
Expand Down Expand Up @@ -71,6 +48,42 @@ Changes since version 0.10.3:
* build: -Wno-dollar-in-identifier-extension is clang only (Ben Noordhuis)


2013.04.11, Version 0.11.1 (Unstable), 5c10e82ae0bc99eff86d4b9baff1f1aa0bf84c0a

This is the first versioned release from the current unstable libuv branch.

Changes since Node.js v0.11.0:

* all platforms: nanosecond resolution support for uv_fs_[fl]stat (Timothy J.
Fontaine)

* all platforms: add netmask to uv_interface_address (Ben Kelly)

* unix: make sure the `status` parameter passed to the `uv_getaddrinfo` is 0 or
-1 (Ben Noordhuis)

* unix: limit the number of iovecs written in a single `writev` syscall to
IOV_MAX (Fedor Indutny)

* unix: add dtrace probes for tick-start and tick-stop (Timothy J. Fontaine)

* mingw-w64: don't call _set_invalid_parameter_handler (Nils Maier)

* windows: fix memory leak in fs__sendfile (Shannen Saez)

* windows: fix edge case bugs in uv_cpu_info (Bert Belder)

* include: no longer ship with / include ngx-queue.h (Ben Noordhuis)

* include: remove UV_VERSION_* macros from uv.h (Ben Noordhuis)

* documentation updates (Kristian Evensen, Ben Kelly, Ben Noordhuis)

* build: fix dtrace-enabled builds (Ben Noordhuis, Timothy J. Fontaine)

* build: gyp disable thin archives (Timothy J. Fontaine)

* build: add support for Visual Studio 2012 (Nicholas Vavilov)
2013.02.04, Version 0.10.3 (Stable), 31ebe23973dd98fd8a24c042b606f37a794e99d0

Changes since version 0.10.2:
Expand Down
1 change: 1 addition & 0 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ TESTS= \
test/test-loop-stop.o \
test/test-multiple-listen.o \
test/test-mutexes.o \
test/test-osx-select.o \
test/test-pass-always.o \
test/test-ping-pong.o \
test/test-pipe-bind-error.o \
Expand Down
6 changes: 2 additions & 4 deletions 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
137 changes: 49 additions & 88 deletions 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
Loading

0 comments on commit ebdeaed

Please sign in to comment.