Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Apr 10, 2013
2 parents 1e8fe45 + bad707d commit f78bcfb
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ vgcore.*
/libuv.so
/libuv.dylib

# Generated by dtrace(1) when doing an in-tree build.
/src/unix/uv-dtrace.h

/out/
/build/gyp

Expand Down
10 changes: 10 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
'cflags': [ '-Wall' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
'target_conditions': [
['_type=="static_library"', {
'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
}],
],
'conditions': [
[ 'host_arch != target_arch and target_arch=="ia32"', {
'cflags': [ '-m32' ],
Expand Down Expand Up @@ -192,6 +197,11 @@
}],
],
}],
['OS=="solaris"', {
'cflags': [ '-fno-omit-frame-pointer' ],
# pull in V8's postmortem metadata
'ldflags': [ '-Wl,-z,allextract' ]
}],
],
},
}
28 changes: 26 additions & 2 deletions config-unix.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ RUNNER_SRC=test/runner-unix.c
RUNNER_CFLAGS=$(CFLAGS) -I$(SRCDIR)/test
RUNNER_LDFLAGS=-L"$(CURDIR)" -luv -Xlinker -rpath -Xlinker "$(CURDIR)"

HAVE_DTRACE=
DTRACE_OBJS=
DTRACE_HEADER=

OBJS += src/unix/async.o
OBJS += src/unix/core.o
OBJS += src/unix/dl.o
Expand All @@ -58,11 +62,14 @@ OBJS += src/inet.o
OBJS += src/version.o

ifeq (sunos,$(PLATFORM))
HAVE_DTRACE=1
CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
LDFLAGS+=-lkstat -lnsl -lsendfile -lsocket
# Library dependencies are not transitive.
RUNNER_LDFLAGS += $(LDFLAGS)
OBJS += src/unix/sunos.o
OBJS += src/unix/dtrace.o
DTRACE_OBJS += src/unix/core.o
endif

ifeq (aix,$(PLATFORM))
Expand All @@ -72,6 +79,7 @@ OBJS += src/unix/aix.o
endif

ifeq (darwin,$(PLATFORM))
HAVE_DTRACE=1
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
LDFLAGS += -framework Foundation \
-framework CoreServices \
Expand All @@ -96,6 +104,7 @@ OBJS += src/unix/linux-core.o \
endif

ifeq (freebsd,$(PLATFORM))
HAVE_DTRACE=1
LDFLAGS+=-lkvm
OBJS += src/unix/freebsd.o
OBJS += src/unix/kqueue.o
Expand Down Expand Up @@ -132,6 +141,12 @@ else
RUNNER_LDFLAGS += -pthread
endif

ifeq ($(HAVE_DTRACE), 1)
DTRACE_HEADER = src/unix/uv-dtrace.h
CPPFLAGS += -Isrc/unix
CFLAGS += -DHAVE_DTRACE
endif

libuv.a: $(OBJS)
$(AR) rcs $@ $^

Expand All @@ -152,7 +167,7 @@ src/.buildstamp src/unix/.buildstamp test/.buildstamp:
mkdir -p $(@D)
touch $@

src/unix/%.o src/unix/%.pic.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp
src/unix/%.o src/unix/%.pic.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp $(DTRACE_HEADER)
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

src/%.o src/%.pic.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp
Expand All @@ -162,7 +177,16 @@ test/%.o: test/%.c include/uv.h test/.buildstamp
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

clean-platform:
$(RM) test/run-{tests,benchmarks}.dSYM $(OBJS) $(OBJS:%.o=%.pic.o)
$(RM) test/run-{tests,benchmarks}.dSYM $(OBJS) $(OBJS:%.o=%.pic.o) src/unix/uv-dtrace.h

%.pic.o %.o: %.m
$(OBJC) $(CPPFLAGS) $(CFLAGS) -c $^ -o $@

src/unix/uv-dtrace.h: src/unix/uv-dtrace.d
dtrace -h -xnolibs -s $< -o $@

src/unix/dtrace.o: src/unix/uv-dtrace.d $(DTRACE_OBJS)
dtrace -G -s $^ -o $@

src/unix/dtrace.pic.o: src/unix/uv-dtrace.d $(DTRACE_OBJS:%.o=%.pic.o)
dtrace -G -s $^ -o $@
4 changes: 4 additions & 0 deletions src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) {

r = uv__loop_alive(loop);
while (r != 0 && loop->stop_flag == 0) {
UV_TICK_START(loop, mode);

uv__update_time(loop);
uv__run_timers(loop);
uv__run_idle(loop);
Expand All @@ -314,6 +316,8 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) {
uv__run_closing_handles(loop);
r = uv__loop_alive(loop);

UV_TICK_STOP(loop, mode);

if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT))
break;
}
Expand Down
7 changes: 7 additions & 0 deletions src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,11 @@ static void uv__update_time(uv_loop_t* loop) {
loop->time = uv__hrtime() / 1000000;
}

#ifdef HAVE_DTRACE
#include "uv-dtrace.h"
#else
#define UV_TICK_START(arg0, arg1)
#define UV_TICK_STOP(arg0, arg1)
#endif

#endif /* UV_UNIX_INTERNAL_H_ */
5 changes: 5 additions & 0 deletions src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <sys/uio.h>
#include <sys/un.h>
#include <unistd.h>
#include <limits.h> /* IOV_MAX */

#if defined(__APPLE__)
# include <sys/event.h>
Expand Down Expand Up @@ -741,6 +742,10 @@ static void uv__write(uv_stream_t* stream) {
iov = (struct iovec*) &(req->bufs[req->write_index]);
iovcnt = req->bufcnt - req->write_index;

/* Limit iov count to avoid EINVALs from writev() */
if (iovcnt > IOV_MAX)
iovcnt = IOV_MAX;

/*
* Now do the actual writev. Note that we've been updating the pointers
* inside the iov each time we write. So there is no need to offset it.
Expand Down
25 changes: 25 additions & 0 deletions src/unix/uv-dtrace.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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.
*/

provider uv {
probe tick__start(void* loop, int mode);
probe tick__stop(void* loop, int mode);
};
2 changes: 1 addition & 1 deletion src/win/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void uv_init(void) {

/* Tell the CRT to not exit the application when an invalid parameter is */
/* passed. The main issue is that invalid FDs will trigger this behavior. */
#ifdef _WRITE_ABORT_MSG
#if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800
_set_invalid_parameter_handler(uv__crt_invalid_parameter_handler);
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,8 @@ static void fs__sendfile(uv_fs_t* req) {
}
}

free(buf);

SET_REQ_RESULT(req, result);
}

Expand Down
2 changes: 1 addition & 1 deletion src/win/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void uv_console_init() {


int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) {
HANDLE handle = INVALID_HANDLE_VALUE;
HANDLE handle;
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;

handle = (HANDLE) _get_osfhandle(fd);
Expand Down
4 changes: 2 additions & 2 deletions test/test-tcp-writealot.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@


#define WRITES 3
#define CHUNKS_PER_WRITE 3
#define CHUNK_SIZE 10485760 /* 10 MB */
#define CHUNKS_PER_WRITE 4096
#define CHUNK_SIZE 10024 /* 10 kb */

#define TOTAL_BYTES (WRITES * CHUNKS_PER_WRITE * CHUNK_SIZE)

Expand Down
65 changes: 63 additions & 2 deletions uv.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
'variables': {
'uv_use_dtrace%': 'false',
# uv_parent_path is the relative path to libuv in the parent project
# this is only relevant when dtrace is enabled and libuv is a child project
# as it's necessary to correctly locate the object files for post
# processing.
'uv_parent_path': '',
},

'target_defaults': {
'conditions': [
['OS != "win"', {
Expand Down Expand Up @@ -248,7 +257,17 @@
}],
['library=="shared_library"', {
'defines': [ 'BUILDING_UV_SHARED=1' ]
}]
}],
['uv_use_dtrace=="true"', {
'defines': [ 'HAVE_DTRACE=1' ],
'dependencies': [ 'uv_dtrace_header' ],
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
'conditions': [
['OS != "mac"', {
'sources': ['src/unix/dtrace.c' ],
}],
],
}],
]
},

Expand Down Expand Up @@ -426,6 +445,48 @@
'SubSystem': 1, # /subsystem:console
},
},
}
},

{
'target_name': 'uv_dtrace_header',
'type': 'none',
'conditions': [
[ 'uv_use_dtrace=="true"', {
'actions': [
{
'action_name': 'uv_dtrace_header',
'inputs': [ 'src/unix/uv-dtrace.d' ],
'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/uv-dtrace.h' ],
'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
'-o', '<@(_outputs)' ],
},
],
}],
],
},

{
'target_name': 'uv_dtrace_provider',
'type': 'none',
'conditions': [
[ 'uv_use_dtrace=="true" and OS!="mac"', {
'actions': [
{
'action_name': 'uv_dtrace_o',
'inputs': [
'src/unix/uv-dtrace.d',
'<(PRODUCT_DIR)/obj.target/libuv/<(uv_parent_path)/src/unix/core.o',
],
'outputs': [
'<(PRODUCT_DIR)/obj.target/libuv/<(uv_parent_path)/src/unix/dtrace.o',
],
'action': [ 'dtrace', '-G', '-xnolibs', '-s', '<@(_inputs)',
'-o', '<@(_outputs)' ]
}
]
} ]
]
},

]
}

0 comments on commit f78bcfb

Please sign in to comment.