deps: upgrade libuv to e89aced
This commit is contained in:
parent
74c08403d8
commit
de9ee2a483
8
deps/uv/common.gypi
vendored
8
deps/uv/common.gypi
vendored
@ -172,6 +172,14 @@
|
|||||||
'-Wno-unused-parameter',
|
'-Wno-unused-parameter',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'conditions': [
|
||||||
|
['target_arch=="ia32"', {
|
||||||
|
'xcode_settings': {'ARCHS': ['i386']},
|
||||||
|
}],
|
||||||
|
['target_arch=="x64"', {
|
||||||
|
'xcode_settings': {'ARCHS': ['x86_64']},
|
||||||
|
}],
|
||||||
|
],
|
||||||
'target_conditions': [
|
'target_conditions': [
|
||||||
['_type!="static_library"', {
|
['_type!="static_library"', {
|
||||||
'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
|
'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
|
||||||
|
13
deps/uv/config-unix.mk
vendored
13
deps/uv/config-unix.mk
vendored
@ -70,11 +70,16 @@ endif
|
|||||||
|
|
||||||
ifeq (darwin,$(OS))
|
ifeq (darwin,$(OS))
|
||||||
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
|
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
|
||||||
LDFLAGS+=-framework CoreServices -dynamiclib -install_name "@rpath/libuv.dylib"
|
LDFLAGS += -framework Foundation \
|
||||||
|
-framework CoreServices \
|
||||||
|
-framework ApplicationServices \
|
||||||
|
-dynamiclib -install_name "@rpath/libuv.dylib"
|
||||||
SOEXT = dylib
|
SOEXT = dylib
|
||||||
OBJS += src/unix/darwin.o
|
OBJS += src/unix/darwin.o
|
||||||
OBJS += src/unix/kqueue.o
|
OBJS += src/unix/kqueue.o
|
||||||
OBJS += src/unix/fsevents.o
|
OBJS += src/unix/fsevents.o
|
||||||
|
OBJS += src/unix/proctitle.o
|
||||||
|
OBJS += src/unix/darwin-proctitle.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (linux,$(OS))
|
ifeq (linux,$(OS))
|
||||||
@ -83,7 +88,8 @@ LDFLAGS+=-ldl -lrt
|
|||||||
RUNNER_CFLAGS += -D_GNU_SOURCE
|
RUNNER_CFLAGS += -D_GNU_SOURCE
|
||||||
OBJS += src/unix/linux-core.o \
|
OBJS += src/unix/linux-core.o \
|
||||||
src/unix/linux-inotify.o \
|
src/unix/linux-inotify.o \
|
||||||
src/unix/linux-syscalls.o
|
src/unix/linux-syscalls.o \
|
||||||
|
src/unix/proctitle.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (freebsd,$(OS))
|
ifeq (freebsd,$(OS))
|
||||||
@ -156,3 +162,6 @@ clean-platform:
|
|||||||
|
|
||||||
distclean-platform:
|
distclean-platform:
|
||||||
-rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
|
-rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
|
||||||
|
|
||||||
|
%.pic.o %.o: %.m
|
||||||
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $^ -o $@
|
||||||
|
22
deps/uv/src/unix/core.c
vendored
22
deps/uv/src/unix/core.c
vendored
@ -603,14 +603,6 @@ void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Note that uv__io_start() and uv__io_stop() can't simply remove the watcher
|
|
||||||
* from the queue when the new event mask equals the old one. The event ports
|
|
||||||
* backend operates exclusively in single-shot mode and needs to rearm all fds
|
|
||||||
* before each call to port_getn(). It's up to the individual backends to
|
|
||||||
* filter out superfluous event mask modifications.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
||||||
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
|
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
|
||||||
assert(0 != events);
|
assert(0 != events);
|
||||||
@ -620,6 +612,20 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|||||||
w->pevents |= events;
|
w->pevents |= events;
|
||||||
maybe_resize(loop, w->fd + 1);
|
maybe_resize(loop, w->fd + 1);
|
||||||
|
|
||||||
|
#if !defined(__sun)
|
||||||
|
/* The event ports backend needs to rearm all file descriptors on each and
|
||||||
|
* every tick of the event loop but the other backends allow us to
|
||||||
|
* short-circuit here if the event mask is unchanged.
|
||||||
|
*/
|
||||||
|
if (w->events == w->pevents) {
|
||||||
|
if (w->events == 0 && !ngx_queue_empty(&w->watcher_queue)) {
|
||||||
|
ngx_queue_remove(&w->watcher_queue);
|
||||||
|
ngx_queue_init(&w->watcher_queue);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ngx_queue_empty(&w->watcher_queue))
|
if (ngx_queue_empty(&w->watcher_queue))
|
||||||
ngx_queue_insert_tail(&loop->watcher_queue, &w->watcher_queue);
|
ngx_queue_insert_tail(&loop->watcher_queue, &w->watcher_queue);
|
||||||
|
|
||||||
|
78
deps/uv/src/unix/darwin-proctitle.m
vendored
Normal file
78
deps/uv/src/unix/darwin-proctitle.m
vendored
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/* 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 <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
|
int uv__set_process_title(const char* title) {
|
||||||
|
typedef CFTypeRef (*LSGetCurrentApplicationASNType)(void);
|
||||||
|
typedef OSStatus (*LSSetApplicationInformationItemType)(int,
|
||||||
|
CFTypeRef,
|
||||||
|
CFStringRef,
|
||||||
|
CFStringRef,
|
||||||
|
CFDictionaryRef*);
|
||||||
|
CFBundleRef launch_services_bundle;
|
||||||
|
LSGetCurrentApplicationASNType ls_get_current_application_asn;
|
||||||
|
LSSetApplicationInformationItemType ls_set_application_information_item;
|
||||||
|
CFStringRef* display_name_key;
|
||||||
|
ProcessSerialNumber psn;
|
||||||
|
CFTypeRef asn;
|
||||||
|
CFStringRef display_name;
|
||||||
|
OSStatus err;
|
||||||
|
|
||||||
|
launch_services_bundle =
|
||||||
|
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices"));
|
||||||
|
|
||||||
|
if (launch_services_bundle == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ls_get_current_application_asn =
|
||||||
|
CFBundleGetFunctionPointerForName(launch_services_bundle,
|
||||||
|
CFSTR("_LSGetCurrentApplicationASN"));
|
||||||
|
|
||||||
|
if (ls_get_current_application_asn == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ls_set_application_information_item =
|
||||||
|
CFBundleGetFunctionPointerForName(launch_services_bundle,
|
||||||
|
CFSTR("_LSSetApplicationInformationItem"));
|
||||||
|
|
||||||
|
if (ls_set_application_information_item == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
display_name_key = CFBundleGetDataPointerForName(launch_services_bundle,
|
||||||
|
CFSTR("_kLSDisplayNameKey"));
|
||||||
|
|
||||||
|
if (display_name_key == NULL || *display_name_key == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Force the process manager to initialize. */
|
||||||
|
GetCurrentProcess(&psn);
|
||||||
|
|
||||||
|
display_name = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8);
|
||||||
|
asn = ls_get_current_application_asn();
|
||||||
|
err = ls_set_application_information_item(-2, /* Magic value. */
|
||||||
|
asn,
|
||||||
|
*display_name_key,
|
||||||
|
display_name,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return (err == noErr) ? 0 : -1;
|
||||||
|
}
|
27
deps/uv/src/unix/darwin.c
vendored
27
deps/uv/src/unix/darwin.c
vendored
@ -37,8 +37,6 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <unistd.h> /* sysconf */
|
#include <unistd.h> /* sysconf */
|
||||||
|
|
||||||
static char *process_title;
|
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
void uv__cf_loop_runner(void* arg);
|
void uv__cf_loop_runner(void* arg);
|
||||||
void uv__cf_loop_cb(void* arg);
|
void uv__cf_loop_cb(void* arg);
|
||||||
@ -254,31 +252,6 @@ 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) {
|
uv_err_t uv_resident_set_memory(size_t* rss) {
|
||||||
struct task_basic_info t_info;
|
struct task_basic_info t_info;
|
||||||
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
|
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
|
||||||
|
6
deps/uv/src/unix/kqueue.c
vendored
6
deps/uv/src/unix/kqueue.c
vendored
@ -84,12 +84,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||||||
assert(w->fd >= 0);
|
assert(w->fd >= 0);
|
||||||
assert(w->fd < (int) loop->nwatchers);
|
assert(w->fd < (int) loop->nwatchers);
|
||||||
|
|
||||||
/* Filter out no-op changes. This is for compatibility with the event ports
|
|
||||||
* backend, see uv__io_start().
|
|
||||||
*/
|
|
||||||
if (w->events == w->pevents)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((w->events & UV__POLLIN) == 0 && (w->pevents & UV__POLLIN) != 0) {
|
if ((w->events & UV__POLLIN) == 0 && (w->pevents & UV__POLLIN) != 0) {
|
||||||
filter = EVFILT_READ;
|
filter = EVFILT_READ;
|
||||||
fflags = 0;
|
fflags = 0;
|
||||||
|
98
deps/uv/src/unix/linux-core.c
vendored
98
deps/uv/src/unix/linux-core.c
vendored
@ -57,25 +57,12 @@
|
|||||||
# define CLOCK_BOOTTIME 7
|
# define CLOCK_BOOTTIME 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void* args_mem;
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
char *str;
|
|
||||||
size_t len;
|
|
||||||
} process_title;
|
|
||||||
|
|
||||||
static void read_models(unsigned int numcpus, uv_cpu_info_t* ci);
|
static void read_models(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||||
static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci);
|
static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||||
static void read_times(unsigned int numcpus, uv_cpu_info_t* ci);
|
static void read_times(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||||
static unsigned long read_cpufreq(unsigned int cpunum);
|
static unsigned long read_cpufreq(unsigned int cpunum);
|
||||||
|
|
||||||
|
|
||||||
__attribute__((destructor))
|
|
||||||
static void free_args_mem(void) {
|
|
||||||
free(args_mem); /* keep valgrind happy */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@ -140,12 +127,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||||||
assert(w->fd >= 0);
|
assert(w->fd >= 0);
|
||||||
assert(w->fd < (int) loop->nwatchers);
|
assert(w->fd < (int) loop->nwatchers);
|
||||||
|
|
||||||
/* Filter out no-op changes. This is for compatibility with the event ports
|
|
||||||
* backend, see the comment in uv__io_start().
|
|
||||||
*/
|
|
||||||
if (w->events == w->pevents)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
e.events = w->pevents;
|
e.events = w->pevents;
|
||||||
e.data = w->fd;
|
e.data = w->fd;
|
||||||
|
|
||||||
@ -302,78 +283,6 @@ 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 (NULL == (s = malloc(size))) {
|
|
||||||
process_title.str = NULL;
|
|
||||||
process_title.len = 0;
|
|
||||||
return argv;
|
|
||||||
}
|
|
||||||
args_mem = s;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#if defined(PR_SET_NAME)
|
|
||||||
prctl(PR_SET_NAME, title);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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) {
|
uv_err_t uv_resident_set_memory(size_t* rss) {
|
||||||
FILE* f;
|
FILE* f;
|
||||||
int itmp;
|
int itmp;
|
||||||
@ -793,3 +702,10 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses,
|
|||||||
|
|
||||||
free(addresses);
|
free(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uv__set_process_title(const char* title) {
|
||||||
|
#if defined(PR_SET_NAME)
|
||||||
|
prctl(PR_SET_NAME, title); /* Only copies first 16 characters. */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
7
deps/uv/src/unix/pipe.c
vendored
7
deps/uv/src/unix/pipe.c
vendored
@ -183,9 +183,6 @@ void uv_pipe_connect(uv_connect_t* req,
|
|||||||
uv_strlcpy(saddr.sun_path, name, sizeof(saddr.sun_path));
|
uv_strlcpy(saddr.sun_path, name, sizeof(saddr.sun_path));
|
||||||
saddr.sun_family = AF_UNIX;
|
saddr.sun_family = AF_UNIX;
|
||||||
|
|
||||||
/* We don't check for EINPROGRESS. Think about it: the socket
|
|
||||||
* is either there or not.
|
|
||||||
*/
|
|
||||||
do {
|
do {
|
||||||
r = connect(uv__stream_fd(handle),
|
r = connect(uv__stream_fd(handle),
|
||||||
(struct sockaddr*)&saddr, sizeof saddr);
|
(struct sockaddr*)&saddr, sizeof saddr);
|
||||||
@ -193,6 +190,7 @@ void uv_pipe_connect(uv_connect_t* req,
|
|||||||
while (r == -1 && errno == EINTR);
|
while (r == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
|
if (errno != EINPROGRESS)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (new_sock)
|
if (new_sock)
|
||||||
@ -213,7 +211,8 @@ out:
|
|||||||
req->cb = cb;
|
req->cb = cb;
|
||||||
ngx_queue_init(&req->queue);
|
ngx_queue_init(&req->queue);
|
||||||
|
|
||||||
/* Run callback on next tick. */
|
/* Force callback to run on next tick in case of error. */
|
||||||
|
if (err != 0)
|
||||||
uv__io_feed(handle->loop, &handle->io_watcher);
|
uv__io_feed(handle->loop, &handle->io_watcher);
|
||||||
|
|
||||||
/* Mimic the Windows pipe implementation, always
|
/* Mimic the Windows pipe implementation, always
|
||||||
|
2
deps/uv/src/unix/process.c
vendored
2
deps/uv/src/unix/process.c
vendored
@ -89,6 +89,8 @@ static void uv__chld(uv_signal_t* handle, int signum) {
|
|||||||
if (process == NULL)
|
if (process == NULL)
|
||||||
continue; /* XXX bug? abort? */
|
continue; /* XXX bug? abort? */
|
||||||
|
|
||||||
|
uv__handle_stop(process);
|
||||||
|
|
||||||
if (process->exit_cb == NULL)
|
if (process->exit_cb == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
126
deps/uv/src/unix/proctitle.c
vendored
Normal file
126
deps/uv/src/unix/proctitle.c
vendored
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/* 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>
|
||||||
|
|
||||||
|
extern void uv__set_process_title(const char* title);
|
||||||
|
|
||||||
|
static void* args_mem;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
char* str;
|
||||||
|
int len;
|
||||||
|
} process_title;
|
||||||
|
|
||||||
|
|
||||||
|
char** uv_setup_args(int argc, char** argv) {
|
||||||
|
char** new_argv;
|
||||||
|
char** new_env;
|
||||||
|
size_t size;
|
||||||
|
int envc;
|
||||||
|
char* s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
char*** _NSGetArgv(void);
|
||||||
|
char*** _NSGetEnviron(void);
|
||||||
|
char** environ = *_NSGetEnviron();
|
||||||
|
#else
|
||||||
|
extern char** environ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (envc = 0; environ[envc]; envc++);
|
||||||
|
|
||||||
|
if (envc == 0)
|
||||||
|
s = argv[argc - 1];
|
||||||
|
else
|
||||||
|
s = environ[envc - 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**);
|
||||||
|
s = args_mem = malloc(size);
|
||||||
|
|
||||||
|
if (s == 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;
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
*_NSGetArgv() = new_argv;
|
||||||
|
*_NSGetEnviron() = new_env;
|
||||||
|
#else
|
||||||
|
environ = new_env;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return new_argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uv_err_t uv_set_process_title(const char* title) {
|
||||||
|
if (process_title.len == 0)
|
||||||
|
return uv_ok_;
|
||||||
|
|
||||||
|
/* No need to terminate, last char is always '\0'. */
|
||||||
|
strncpy(process_title.str, title, process_title.len - 1);
|
||||||
|
uv__set_process_title(title);
|
||||||
|
|
||||||
|
return uv_ok_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uv_err_t uv_get_process_title(char* buffer, size_t size) {
|
||||||
|
if (process_title.len > 0)
|
||||||
|
strncpy(buffer, process_title.str, size);
|
||||||
|
else if (size > 0)
|
||||||
|
buffer[0] = '\0';
|
||||||
|
|
||||||
|
return uv_ok_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__attribute__((destructor))
|
||||||
|
static void free_args_mem(void) {
|
||||||
|
free(args_mem); /* Keep valgrind happy. */
|
||||||
|
args_mem = NULL;
|
||||||
|
}
|
25
deps/uv/src/unix/stream.c
vendored
25
deps/uv/src/unix/stream.c
vendored
@ -1188,21 +1188,20 @@ int uv_write2(uv_write_t* req,
|
|||||||
int empty_queue;
|
int empty_queue;
|
||||||
|
|
||||||
assert(bufcnt > 0);
|
assert(bufcnt > 0);
|
||||||
|
assert((stream->type == UV_TCP ||
|
||||||
assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
|
stream->type == UV_NAMED_PIPE ||
|
||||||
stream->type == UV_TTY) &&
|
stream->type == UV_TTY) &&
|
||||||
"uv_write (unix) does not yet support other types of streams");
|
"uv_write (unix) does not yet support other types of streams");
|
||||||
|
|
||||||
if (uv__stream_fd(stream) < 0) {
|
if (uv__stream_fd(stream) < 0)
|
||||||
uv__set_sys_error(stream->loop, EBADF);
|
return uv__set_artificial_error(stream->loop, UV_EBADF);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (send_handle) {
|
if (send_handle) {
|
||||||
if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc) {
|
if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc)
|
||||||
uv__set_sys_error(stream->loop, EOPNOTSUPP);
|
return uv__set_artificial_error(stream->loop, UV_EINVAL);
|
||||||
return -1;
|
|
||||||
}
|
if (uv__stream_fd(send_handle) < 0)
|
||||||
|
return uv__set_artificial_error(stream->loop, UV_EBADF);
|
||||||
}
|
}
|
||||||
|
|
||||||
empty_queue = (stream->write_queue_size == 0);
|
empty_queue = (stream->write_queue_size == 0);
|
||||||
@ -1268,10 +1267,8 @@ static int uv__read_start_common(uv_stream_t* stream,
|
|||||||
assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
|
assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
|
||||||
stream->type == UV_TTY);
|
stream->type == UV_TTY);
|
||||||
|
|
||||||
if (stream->flags & UV_CLOSING) {
|
if (stream->flags & UV_CLOSING)
|
||||||
uv__set_sys_error(stream->loop, EINVAL);
|
return uv__set_sys_error(stream->loop, EINVAL);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The UV_STREAM_READING flag is irrelevant of the state of the tcp - it just
|
/* The UV_STREAM_READING flag is irrelevant of the state of the tcp - it just
|
||||||
* expresses the desired state of the user.
|
* expresses the desired state of the user.
|
||||||
|
2
deps/uv/test/run-benchmarks.c
vendored
2
deps/uv/test/run-benchmarks.c
vendored
@ -60,5 +60,5 @@ static int maybe_run_test(int argc, char **argv) {
|
|||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
return run_test(argv[1], BENCHMARK_TIMEOUT, 1);
|
return run_test(argv[1], BENCHMARK_TIMEOUT, 1, 1);
|
||||||
}
|
}
|
||||||
|
2
deps/uv/test/run-tests.c
vendored
2
deps/uv/test/run-tests.c
vendored
@ -155,5 +155,5 @@ static int maybe_run_test(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return run_test(argv[1], TEST_TIMEOUT, 0);
|
return run_test(argv[1], TEST_TIMEOUT, 0, 1);
|
||||||
}
|
}
|
||||||
|
18
deps/uv/test/runner-unix.c
vendored
18
deps/uv/test/runner-unix.c
vendored
@ -42,6 +42,7 @@
|
|||||||
/* Do platform-specific initialization. */
|
/* Do platform-specific initialization. */
|
||||||
void platform_init(int argc, char **argv) {
|
void platform_init(int argc, char **argv) {
|
||||||
const char* var = getenv("UV_RUN_AS_ROOT");
|
const char* var = getenv("UV_RUN_AS_ROOT");
|
||||||
|
const char* tap = getenv("UV_TAP_OUTPUT");
|
||||||
|
|
||||||
/* Running the tests as root is not smart - don't do it. */
|
/* Running the tests as root is not smart - don't do it. */
|
||||||
if (getuid() == 0 && (var == NULL || atoi(var) <= 0)) {
|
if (getuid() == 0 && (var == NULL || atoi(var) <= 0)) {
|
||||||
@ -49,6 +50,8 @@ void platform_init(int argc, char **argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tap_output = (tap != NULL && atoi(tap) > 0);
|
||||||
|
|
||||||
/* Disable stdio output buffering. */
|
/* Disable stdio output buffering. */
|
||||||
setvbuf(stdout, NULL, _IONBF, 0);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
setvbuf(stderr, NULL, _IONBF, 0);
|
setvbuf(stderr, NULL, _IONBF, 0);
|
||||||
@ -261,19 +264,26 @@ int process_copy_output(process_info_t *p, int fd) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t nread, nwritten;
|
ssize_t nwritten;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
while ((nread = read(fileno(p->stdout_file), buf, 1024)) > 0) {
|
/* TODO: what if the line is longer than buf */
|
||||||
nwritten = write(fd, buf, nread);
|
while (fgets(buf, sizeof(buf), p->stdout_file) != NULL) {
|
||||||
/* TODO: what if write doesn't write the whole buffer... */
|
/* TODO: what if write doesn't write the whole buffer... */
|
||||||
|
nwritten = 0;
|
||||||
|
|
||||||
|
if (tap_output)
|
||||||
|
nwritten += write(fd, "#", 1);
|
||||||
|
|
||||||
|
nwritten += write(fd, buf, strlen(buf));
|
||||||
|
|
||||||
if (nwritten < 0) {
|
if (nwritten < 0) {
|
||||||
perror("write");
|
perror("write");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nread < 0) {
|
if (ferror(p->stdout_file)) {
|
||||||
perror("read");
|
perror("read");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
30
deps/uv/test/runner.c
vendored
30
deps/uv/test/runner.c
vendored
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
char executable_path[PATHMAX] = { '\0' };
|
char executable_path[PATHMAX] = { '\0' };
|
||||||
|
|
||||||
|
int tap_output = 0;
|
||||||
|
|
||||||
|
|
||||||
static void log_progress(int total, int passed, int failed, const char* name) {
|
static void log_progress(int total, int passed, int failed, const char* name) {
|
||||||
if (total == 0)
|
if (total == 0)
|
||||||
@ -76,7 +78,7 @@ const char* fmt(double d) {
|
|||||||
|
|
||||||
|
|
||||||
int run_tests(int timeout, int benchmark_output) {
|
int run_tests(int timeout, int benchmark_output) {
|
||||||
int total, passed, failed;
|
int total, passed, failed, current;
|
||||||
task_entry_t* task;
|
task_entry_t* task;
|
||||||
|
|
||||||
/* Count the number of tests. */
|
/* Count the number of tests. */
|
||||||
@ -87,29 +89,35 @@ int run_tests(int timeout, int benchmark_output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tap_output) {
|
||||||
|
LOGF("1..%d\n", total);
|
||||||
|
}
|
||||||
|
|
||||||
/* Run all tests. */
|
/* Run all tests. */
|
||||||
passed = 0;
|
passed = 0;
|
||||||
failed = 0;
|
failed = 0;
|
||||||
|
current = 1;
|
||||||
for (task = TASKS; task->main; task++) {
|
for (task = TASKS; task->main; task++) {
|
||||||
if (task->is_helper) {
|
if (task->is_helper) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rewind_cursor();
|
rewind_cursor();
|
||||||
if (!benchmark_output) {
|
if (!benchmark_output && !tap_output) {
|
||||||
log_progress(total, passed, failed, task->task_name);
|
log_progress(total, passed, failed, task->task_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_test(task->task_name, timeout, benchmark_output) == 0) {
|
if (run_test(task->task_name, timeout, benchmark_output, current) == 0) {
|
||||||
passed++;
|
passed++;
|
||||||
} else {
|
} else {
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
|
current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rewind_cursor();
|
rewind_cursor();
|
||||||
|
|
||||||
if (!benchmark_output) {
|
if (!benchmark_output && !tap_output) {
|
||||||
log_progress(total, passed, failed, "Done.\n");
|
log_progress(total, passed, failed, "Done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +125,10 @@ int run_tests(int timeout, int benchmark_output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int run_test(const char* test, int timeout, int benchmark_output) {
|
int run_test(const char* test,
|
||||||
|
int timeout,
|
||||||
|
int benchmark_output,
|
||||||
|
int test_count) {
|
||||||
char errmsg[1024] = "no error";
|
char errmsg[1024] = "no error";
|
||||||
process_info_t processes[1024];
|
process_info_t processes[1024];
|
||||||
process_info_t *main_proc;
|
process_info_t *main_proc;
|
||||||
@ -243,7 +254,9 @@ out:
|
|||||||
|
|
||||||
/* Show error and output from processes if the test failed. */
|
/* Show error and output from processes if the test failed. */
|
||||||
if (status != 0 || task->show_output) {
|
if (status != 0 || task->show_output) {
|
||||||
if (status != 0) {
|
if (tap_output) {
|
||||||
|
LOGF("not ok %d - %s\n#", test_count, test);
|
||||||
|
} else if (status != 0) {
|
||||||
LOGF("\n`%s` failed: %s\n", test, errmsg);
|
LOGF("\n`%s` failed: %s\n", test, errmsg);
|
||||||
} else {
|
} else {
|
||||||
LOGF("\n");
|
LOGF("\n");
|
||||||
@ -267,7 +280,10 @@ out:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tap_output) {
|
||||||
LOG("=============================================================\n");
|
LOG("=============================================================\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* In benchmark mode show concise output from the main process. */
|
/* In benchmark mode show concise output from the main process. */
|
||||||
} else if (benchmark_output) {
|
} else if (benchmark_output) {
|
||||||
@ -286,6 +302,8 @@ out:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (tap_output) {
|
||||||
|
LOGF("ok %d - %s\n", test_count, test);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up all process handles. */
|
/* Clean up all process handles. */
|
||||||
|
8
deps/uv/test/runner.h
vendored
8
deps/uv/test/runner.h
vendored
@ -102,7 +102,10 @@ int run_tests(int timeout, int benchmark_output);
|
|||||||
/*
|
/*
|
||||||
* Run a single test. Starts up any helpers.
|
* Run a single test. Starts up any helpers.
|
||||||
*/
|
*/
|
||||||
int run_test(const char* test, int timeout, int benchmark_output);
|
int run_test(const char* test,
|
||||||
|
int timeout,
|
||||||
|
int benchmark_output,
|
||||||
|
int test_count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run a test part, i.e. the test or one of its helpers.
|
* Run a test part, i.e. the test or one of its helpers.
|
||||||
@ -156,4 +159,7 @@ void process_cleanup(process_info_t *p);
|
|||||||
/* Move the console cursor one line up and back to the first column. */
|
/* Move the console cursor one line up and back to the first column. */
|
||||||
void rewind_cursor(void);
|
void rewind_cursor(void);
|
||||||
|
|
||||||
|
/* trigger output as tap */
|
||||||
|
extern int tap_output;
|
||||||
|
|
||||||
#endif /* RUNNER_H_ */
|
#endif /* RUNNER_H_ */
|
||||||
|
2
deps/uv/test/test-list.h
vendored
2
deps/uv/test/test-list.h
vendored
@ -152,6 +152,7 @@ TEST_DECLARE (spawn_preserve_env)
|
|||||||
TEST_DECLARE (spawn_setuid_fails)
|
TEST_DECLARE (spawn_setuid_fails)
|
||||||
TEST_DECLARE (spawn_setgid_fails)
|
TEST_DECLARE (spawn_setgid_fails)
|
||||||
TEST_DECLARE (spawn_stdout_to_file)
|
TEST_DECLARE (spawn_stdout_to_file)
|
||||||
|
TEST_DECLARE (spawn_auto_unref)
|
||||||
TEST_DECLARE (fs_poll)
|
TEST_DECLARE (fs_poll)
|
||||||
TEST_DECLARE (kill)
|
TEST_DECLARE (kill)
|
||||||
TEST_DECLARE (fs_file_noent)
|
TEST_DECLARE (fs_file_noent)
|
||||||
@ -413,6 +414,7 @@ TASK_LIST_START
|
|||||||
TEST_ENTRY (spawn_setuid_fails)
|
TEST_ENTRY (spawn_setuid_fails)
|
||||||
TEST_ENTRY (spawn_setgid_fails)
|
TEST_ENTRY (spawn_setgid_fails)
|
||||||
TEST_ENTRY (spawn_stdout_to_file)
|
TEST_ENTRY (spawn_stdout_to_file)
|
||||||
|
TEST_ENTRY (spawn_auto_unref)
|
||||||
TEST_ENTRY (fs_poll)
|
TEST_ENTRY (fs_poll)
|
||||||
TEST_ENTRY (kill)
|
TEST_ENTRY (kill)
|
||||||
|
|
||||||
|
13
deps/uv/test/test-spawn.c
vendored
13
deps/uv/test/test-spawn.c
vendored
@ -923,3 +923,16 @@ TEST_IMPL(spawn_setgid_fails) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
TEST_IMPL(spawn_auto_unref) {
|
||||||
|
init_process_options("spawn_helper1", NULL);
|
||||||
|
ASSERT(0 == uv_spawn(uv_default_loop(), &process, options));
|
||||||
|
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
||||||
|
ASSERT(0 == uv_is_closing((uv_handle_t*) &process));
|
||||||
|
uv_close((uv_handle_t*) &process, NULL);
|
||||||
|
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
||||||
|
ASSERT(0 != uv_is_closing((uv_handle_t*) &process));
|
||||||
|
MAKE_VALGRIND_HAPPY();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
11
deps/uv/uv.gyp
vendored
11
deps/uv/uv.gyp
vendored
@ -157,11 +157,20 @@
|
|||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
|
[ 'OS=="linux" or OS=="mac"', {
|
||||||
|
'sources': [ 'src/unix/proctitle.c' ],
|
||||||
|
}],
|
||||||
[ 'OS=="mac"', {
|
[ 'OS=="mac"', {
|
||||||
'sources': [ 'src/unix/darwin.c', 'src/unix/fsevents.c' ],
|
'sources': [
|
||||||
|
'src/unix/darwin.c',
|
||||||
|
'src/unix/fsevents.c',
|
||||||
|
'src/unix/darwin-proctitle.m',
|
||||||
|
],
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
|
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
|
||||||
'$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
|
'$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
|
||||||
|
'$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'defines': [
|
'defines': [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user