Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-07-19 20:29:29 +0400
committerisaacs <i@izs.me>2012-07-19 20:32:46 +0400
commit845b9e92d8c12c42777495e7cb9aa1a458a982e2 (patch)
tree0397adf479dd7de602e1acff39be5a4dbba0627e
parentb2648934f013ccdf1a15bb74a5480d5a42a97943 (diff)
uv: Upgrade to 94355e4
-rw-r--r--deps/uv/config-unix.mk4
-rw-r--r--deps/uv/src/unix/darwin.c27
-rw-r--r--deps/uv/src/unix/linux/linux-core.c72
-rw-r--r--deps/uv/src/unix/openbsd.c30
-rw-r--r--deps/uv/src/unix/pipe.c35
-rw-r--r--deps/uv/src/unix/proctitle.c99
-rw-r--r--deps/uv/src/unix/sunos.c18
-rw-r--r--deps/uv/uv.gyp3
8 files changed, 164 insertions, 124 deletions
diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk
index 231d8844343..0581b5114c0 100644
--- a/deps/uv/config-unix.mk
+++ b/deps/uv/config-unix.mk
@@ -128,10 +128,6 @@ else
RUNNER_LINKFLAGS += -pthread
endif
-ifneq (FreeBSD,$(uname_S))
-OBJS += src/unix/proctitle.o
-endif
-
RUNNER_LIBS=
RUNNER_SRC=test/runner-unix.c
diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c
index b3cd01221b6..e6deb3017b3 100644
--- a/deps/uv/src/unix/darwin.c
+++ b/deps/uv/src/unix/darwin.c
@@ -41,6 +41,8 @@
#include <sys/sysctl.h>
#include <unistd.h> /* sysconf */
+static char *process_title;
+
#if TARGET_OS_IPHONE
/* see: http://developer.apple.com/library/mac/#qa/qa1398/_index.html */
uint64_t uv_hrtime() {
@@ -136,6 +138,31 @@ void uv_loadavg(double avg[3]) {
}
+char** uv_setup_args(int argc, char** argv) {
+ process_title = argc ? strdup(argv[0]) : NULL;
+ return argv;
+}
+
+
+uv_err_t uv_set_process_title(const char* title) {
+ /* TODO implement me */
+ return uv__new_artificial_error(UV_ENOSYS);
+}
+
+
+uv_err_t uv_get_process_title(char* buffer, size_t size) {
+ if (process_title) {
+ strncpy(buffer, process_title, size);
+ } else {
+ if (size > 0) {
+ buffer[0] = '\0';
+ }
+ }
+
+ return uv_ok_;
+}
+
+
uv_err_t uv_resident_set_memory(size_t* rss) {
struct task_basic_info t_info;
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
diff --git a/deps/uv/src/unix/linux/linux-core.c b/deps/uv/src/unix/linux/linux-core.c
index 9cde6a1e140..34f48a94b9f 100644
--- a/deps/uv/src/unix/linux/linux-core.c
+++ b/deps/uv/src/unix/linux/linux-core.c
@@ -58,6 +58,11 @@
static char buf[MAXPATHLEN + 1];
+static struct {
+ char *str;
+ size_t len;
+} process_title;
+
/*
* There's probably some way to get time from Linux than gettimeofday(). What
@@ -107,6 +112,73 @@ uint64_t uv_get_total_memory(void) {
}
+char** uv_setup_args(int argc, char** argv) {
+ char **new_argv;
+ char **new_env;
+ size_t size;
+ int envc;
+ char *s;
+ int i;
+
+ for (envc = 0; environ[envc]; envc++);
+
+ s = envc ? environ[envc - 1] : argv[argc - 1];
+
+ process_title.str = argv[0];
+ process_title.len = s + strlen(s) + 1 - argv[0];
+
+ size = process_title.len;
+ size += (argc + 1) * sizeof(char **);
+ size += (envc + 1) * sizeof(char **);
+
+ if ((s = (char *) malloc(size)) == NULL) {
+ process_title.str = NULL;
+ process_title.len = 0;
+ return argv;
+ }
+
+ new_argv = (char **) s;
+ new_env = new_argv + argc + 1;
+ s = (char *) (new_env + envc + 1);
+ memcpy(s, process_title.str, process_title.len);
+
+ for (i = 0; i < argc; i++)
+ new_argv[i] = s + (argv[i] - argv[0]);
+ new_argv[argc] = NULL;
+
+ s += environ[0] - argv[0];
+
+ for (i = 0; i < envc; i++)
+ new_env[i] = s + (environ[i] - environ[0]);
+ new_env[envc] = NULL;
+
+ environ = new_env;
+ return new_argv;
+}
+
+
+uv_err_t uv_set_process_title(const char* title) {
+ /* No need to terminate, last char is always '\0'. */
+ if (process_title.len)
+ strncpy(process_title.str, title, process_title.len - 1);
+
+ return uv_ok_;
+}
+
+
+uv_err_t uv_get_process_title(char* buffer, size_t size) {
+ if (process_title.str) {
+ strncpy(buffer, process_title.str, size);
+ } else {
+ if (size > 0) {
+ buffer[0] = '\0';
+ }
+ }
+
+ return uv_ok_;
+}
+
+
uv_err_t uv_resident_set_memory(size_t* rss) {
FILE* f;
int itmp;
diff --git a/deps/uv/src/unix/openbsd.c b/deps/uv/src/unix/openbsd.c
index 0c5d81628a7..865f8e9e6af 100644
--- a/deps/uv/src/unix/openbsd.c
+++ b/deps/uv/src/unix/openbsd.c
@@ -40,6 +40,9 @@
#define NANOSEC ((uint64_t) 1e9)
+static char *process_title;
+
+
uint64_t uv_hrtime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -134,6 +137,33 @@ uint64_t uv_get_total_memory(void) {
}
+char** uv_setup_args(int argc, char** argv) {
+ process_title = argc ? strdup(argv[0]) : NULL;
+ return argv;
+}
+
+
+uv_err_t uv_set_process_title(const char* title) {
+ if (process_title) free(process_title);
+ process_title = strdup(title);
+ setproctitle(title);
+ return uv_ok_;
+}
+
+
+uv_err_t uv_get_process_title(char* buffer, size_t size) {
+ if (process_title) {
+ strncpy(buffer, process_title, size);
+ } else {
+ if (size > 0) {
+ buffer[0] = '\0';
+ }
+ }
+
+ return uv_ok_;
+}
+
+
uv_err_t uv_resident_set_memory(size_t* rss) {
kvm_t *kd = NULL;
struct kinfo_proc *kinfo = NULL;
diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c
index 317ac67c10f..957e96f8a65 100644
--- a/deps/uv/src/unix/pipe.c
+++ b/deps/uv/src/unix/pipe.c
@@ -170,18 +170,17 @@ void uv_pipe_connect(uv_connect_t* req,
uv_connect_cb cb) {
struct sockaddr_un saddr;
int saved_errno;
- int sockfd;
- int status;
+ int new_sock;
+ int err;
int r;
saved_errno = errno;
- sockfd = -1;
- status = -1;
+ new_sock = (handle->fd == -1);
+ err = -1;
- if ((sockfd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
- uv__set_sys_error(handle->loop, errno);
- goto out;
- }
+ if (new_sock)
+ if ((handle->fd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
+ goto out;
memset(&saddr, 0, sizeof saddr);
uv_strlcpy(saddr.sun_path, name, sizeof(saddr.sun_path));
@@ -191,25 +190,25 @@ void uv_pipe_connect(uv_connect_t* req,
* is either there or not.
*/
do {
- r = connect(sockfd, (struct sockaddr*)&saddr, sizeof saddr);
+ r = connect(handle->fd, (struct sockaddr*)&saddr, sizeof saddr);
}
while (r == -1 && errno == EINTR);
- if (r == -1) {
- status = errno;
- close(sockfd);
+ if (r == -1)
goto out;
- }
- uv__stream_open((uv_stream_t*)handle,
- sockfd,
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ if (new_sock)
+ if (uv__stream_open((uv_stream_t*)handle,
+ handle->fd,
+ UV_STREAM_READABLE | UV_STREAM_WRITABLE))
+ goto out;
+
uv__io_start(handle->loop, &handle->read_watcher);
uv__io_start(handle->loop, &handle->write_watcher);
- status = 0;
+ err = 0;
out:
- handle->delayed_error = status; /* Passed to callback. */
+ handle->delayed_error = err ? errno : 0; /* Passed to callback. */
handle->connect_req = req;
uv__req_init(handle->loop, req, UV_CONNECT);
diff --git a/deps/uv/src/unix/proctitle.c b/deps/uv/src/unix/proctitle.c
deleted file mode 100644
index 9057074a316..00000000000
--- a/deps/uv/src/unix/proctitle.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include "uv.h"
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-/* NOTE: FreeBSD is using it's own implementation of those functions */
-
-static struct {
- char *str;
- size_t len;
-} process_title;
-
-extern char** environ;
-
-
-char** uv_setup_args(int argc, char** argv) {
- char **new_argv;
- char **new_env;
- size_t size;
- int envc;
- char *s;
- int i;
-
- for (envc = 0; environ[envc]; envc++);
-
- s = envc ? environ[envc - 1] : argv[argc - 1];
-
- process_title.str = argv[0];
- process_title.len = s + strlen(s) + 1 - argv[0];
-
- size = process_title.len;
- size += (argc + 1) * sizeof(char **);
- size += (envc + 1) * sizeof(char **);
-
- if ((s = (char *) malloc(size)) == NULL) {
- process_title.str = NULL;
- process_title.len = 0;
- return argv;
- }
-
- new_argv = (char **) s;
- new_env = new_argv + argc + 1;
- s = (char *) (new_env + envc + 1);
- memcpy(s, process_title.str, process_title.len);
-
- for (i = 0; i < argc; i++)
- new_argv[i] = s + (argv[i] - argv[0]);
- new_argv[argc] = NULL;
-
- s += environ[0] - argv[0];
-
- for (i = 0; i < envc; i++)
- new_env[i] = s + (environ[i] - environ[0]);
- new_env[envc] = NULL;
-
- environ = new_env;
- return new_argv;
-}
-
-
-uv_err_t uv_set_process_title(const char* title) {
- /* proctitle doesn't need to be zero terminated, last char is always '\0'.
- * Use strncpy(), it pads the remainder with nul bytes. Avoids garbage output
- * on systems where `ps aux` prints the entire proctitle buffer, not just the
- * characters up to the first '\0'.
- */
- if (process_title.len > 0)
- strncpy(process_title.str, title, process_title.len - 1);
-
- return uv_ok_;
-}
-
-
-uv_err_t uv_get_process_title(char* buffer, size_t size) {
- uv_strlcpy(buffer, process_title.str ? process_title.str : "", size);
- return uv_ok_;
-}
diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c
index 1a439d94f42..b95a89b456a 100644
--- a/deps/uv/src/unix/sunos.c
+++ b/deps/uv/src/unix/sunos.c
@@ -238,6 +238,24 @@ void uv__fs_event_close(uv_fs_event_t* handle) {
#endif /* HAVE_PORTS_FS */
+char** uv_setup_args(int argc, char** argv) {
+ return argv;
+}
+
+
+uv_err_t uv_set_process_title(const char* title) {
+ return uv_ok_;
+}
+
+
+uv_err_t uv_get_process_title(char* buffer, size_t size) {
+ if (size > 0) {
+ buffer[0] = '\0';
+ }
+ return uv_ok_;
+}
+
+
uv_err_t uv_resident_set_memory(size_t* rss) {
psinfo_t psinfo;
uv_err_t err;
diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp
index 1ed3b6bc4b3..96c6b724c62 100644
--- a/deps/uv/uv.gyp
+++ b/deps/uv/uv.gyp
@@ -287,9 +287,6 @@
[ 'OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
'sources': [ 'src/unix/kqueue.c' ],
}],
- [ 'OS!="win" and OS!="freebsd"', {
- 'sources': [ 'src/unix/proctitle.c' ],
- }],
]
},