mirror of https://github.com/lukechilds/node.git
Browse Source
Reviewed-By: Julien Gilli <julien.gilli@joyent.com> PR-URL: https://github.com/joyent/node/pull/9179v0.12.2-release
109 changed files with 2724 additions and 1226 deletions
@ -0,0 +1,178 @@ |
|||
# Makefile for Sphinx documentation
|
|||
#
|
|||
|
|||
# You can set these variables from the command line.
|
|||
SPHINXOPTS = |
|||
SPHINXBUILD = sphinx-build |
|||
PAPER = |
|||
BUILDDIR = build |
|||
SRCDIR = src |
|||
|
|||
# User-friendly check for sphinx-build
|
|||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) |
|||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) |
|||
endif |
|||
|
|||
# Internal variables.
|
|||
PAPEROPT_a4 = -D latex_paper_size=a4 |
|||
PAPEROPT_letter = -D latex_paper_size=letter |
|||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) |
|||
# the i18n builder cannot share the environment and doctrees with the others
|
|||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) |
|||
|
|||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext |
|||
|
|||
help: |
|||
@echo "Please use \`make <target>' where <target> is one of" |
|||
@echo " html to make standalone HTML files" |
|||
@echo " dirhtml to make HTML files named index.html in directories" |
|||
@echo " singlehtml to make a single large HTML file" |
|||
@echo " pickle to make pickle files" |
|||
@echo " json to make JSON files" |
|||
@echo " htmlhelp to make HTML files and a HTML help project" |
|||
@echo " qthelp to make HTML files and a qthelp project" |
|||
@echo " devhelp to make HTML files and a Devhelp project" |
|||
@echo " epub to make an epub" |
|||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" |
|||
@echo " latexpdf to make LaTeX files and run them through pdflatex" |
|||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" |
|||
@echo " text to make text files" |
|||
@echo " man to make manual pages" |
|||
@echo " texinfo to make Texinfo files" |
|||
@echo " info to make Texinfo files and run them through makeinfo" |
|||
@echo " gettext to make PO message catalogs" |
|||
@echo " changes to make an overview of all changed/added/deprecated items" |
|||
@echo " xml to make Docutils-native XML files" |
|||
@echo " pseudoxml to make pseudoxml-XML files for display purposes" |
|||
@echo " linkcheck to check all external links for integrity" |
|||
@echo " doctest to run all doctests embedded in the documentation (if enabled)" |
|||
|
|||
clean: |
|||
rm -rf $(BUILDDIR)/* |
|||
|
|||
html: |
|||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html |
|||
@echo |
|||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." |
|||
|
|||
dirhtml: |
|||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml |
|||
@echo |
|||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." |
|||
|
|||
singlehtml: |
|||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml |
|||
@echo |
|||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." |
|||
|
|||
pickle: |
|||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle |
|||
@echo |
|||
@echo "Build finished; now you can process the pickle files." |
|||
|
|||
json: |
|||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json |
|||
@echo |
|||
@echo "Build finished; now you can process the JSON files." |
|||
|
|||
htmlhelp: |
|||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp |
|||
@echo |
|||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
|||
".hhp project file in $(BUILDDIR)/htmlhelp." |
|||
|
|||
qthelp: |
|||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp |
|||
@echo |
|||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
|||
".qhcp project file in $(BUILDDIR)/qthelp, like this:" |
|||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/libuv.qhcp" |
|||
@echo "To view the help file:" |
|||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/libuv.qhc" |
|||
|
|||
devhelp: |
|||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp |
|||
@echo |
|||
@echo "Build finished." |
|||
@echo "To view the help file:" |
|||
@echo "# mkdir -p $$HOME/.local/share/devhelp/libuv" |
|||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/libuv" |
|||
@echo "# devhelp" |
|||
|
|||
epub: |
|||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub |
|||
@echo |
|||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub." |
|||
|
|||
latex: |
|||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex |
|||
@echo |
|||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." |
|||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
|||
"(use \`make latexpdf' here to do that automatically)." |
|||
|
|||
latexpdf: |
|||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex |
|||
@echo "Running LaTeX files through pdflatex..." |
|||
$(MAKE) -C $(BUILDDIR)/latex all-pdf |
|||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." |
|||
|
|||
latexpdfja: |
|||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex |
|||
@echo "Running LaTeX files through platex and dvipdfmx..." |
|||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja |
|||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." |
|||
|
|||
text: |
|||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text |
|||
@echo |
|||
@echo "Build finished. The text files are in $(BUILDDIR)/text." |
|||
|
|||
man: |
|||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man |
|||
@echo |
|||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man." |
|||
|
|||
texinfo: |
|||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo |
|||
@echo |
|||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." |
|||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
|||
"(use \`make info' here to do that automatically)." |
|||
|
|||
info: |
|||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo |
|||
@echo "Running Texinfo files through makeinfo..." |
|||
make -C $(BUILDDIR)/texinfo info |
|||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." |
|||
|
|||
gettext: |
|||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale |
|||
@echo |
|||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." |
|||
|
|||
changes: |
|||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes |
|||
@echo |
|||
@echo "The overview file is in $(BUILDDIR)/changes." |
|||
|
|||
linkcheck: |
|||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck |
|||
@echo |
|||
@echo "Link check complete; look for any errors in the above output " \
|
|||
"or in $(BUILDDIR)/linkcheck/output.txt." |
|||
|
|||
doctest: |
|||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest |
|||
@echo "Testing of doctests in the sources finished, look at the " \
|
|||
"results in $(BUILDDIR)/doctest/output.txt." |
|||
|
|||
xml: |
|||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml |
|||
@echo |
|||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml." |
|||
|
|||
pseudoxml: |
|||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml |
|||
@echo |
|||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." |
@ -1,66 +0,0 @@ |
|||
dnl Copyright (C) 2009 Sun Microsystems |
|||
dnl This file is free software; Sun Microsystems |
|||
dnl gives unlimited permission to copy and/or distribute it, |
|||
dnl with or without modifications, as long as this notice is preserved. |
|||
|
|||
dnl --------------------------------------------------------------------------- |
|||
dnl Macro: PANDORA_ENABLE_DTRACE |
|||
dnl --------------------------------------------------------------------------- |
|||
AC_DEFUN([PANDORA_ENABLE_DTRACE],[ |
|||
AC_ARG_ENABLE([dtrace], |
|||
[AS_HELP_STRING([--disable-dtrace], |
|||
[enable DTrace USDT probes. @<:@default=yes@:>@])], |
|||
[ac_cv_enable_dtrace="$enableval"], |
|||
[ac_cv_enable_dtrace="yes"]) |
|||
|
|||
AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[ |
|||
AC_CHECK_PROGS([DTRACE], [dtrace]) |
|||
AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace"],[ |
|||
|
|||
AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[ |
|||
cat >conftest.d <<_ACEOF |
|||
provider Example { |
|||
probe increment(int); |
|||
}; |
|||
_ACEOF |
|||
$DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero |
|||
AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes], |
|||
[ac_cv_dtrace_works=no]) |
|||
rm -f conftest.h conftest.d |
|||
]) |
|||
AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[ |
|||
AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) |
|||
AC_CACHE_CHECK([if dtrace should instrument object files], |
|||
[ac_cv_dtrace_needs_objects],[ |
|||
dnl DTrace on MacOSX does not use -G option |
|||
cat >conftest.d <<_ACEOF |
|||
provider Example { |
|||
probe increment(int); |
|||
}; |
|||
_ACEOF |
|||
cat > conftest.c <<_ACEOF |
|||
#include "conftest.h" |
|||
void foo() { |
|||
EXAMPLE_INCREMENT(1); |
|||
} |
|||
_ACEOF |
|||
$DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero |
|||
$CC -c -o conftest.o conftest.c |
|||
$DTRACE -G -o conftest.d.o -s conftest.d conftest.o 2>/dev/zero |
|||
AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes], |
|||
[ac_cv_dtrace_needs_objects=no]) |
|||
rm -f conftest.d.o conftest.d conftest.h conftest.o conftest.c |
|||
]) |
|||
]) |
|||
AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX |
|||
ac_cv_have_dtrace=yes |
|||
])]) |
|||
|
|||
AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"]) |
|||
AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS], |
|||
[test "x$ac_cv_dtrace_needs_objects" = "xyes"]) |
|||
|
|||
]) |
|||
dnl --------------------------------------------------------------------------- |
|||
dnl End Macro: PANDORA_ENABLE_DTRACE |
|||
dnl --------------------------------------------------------------------------- |
@ -0,0 +1,46 @@ |
|||
# Copyright StrongLoop, Inc. 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.
|
|||
|
|||
BUILDTYPE ?= Debug |
|||
BUILDDIR ?= build |
|||
GYP ?= gyp |
|||
V ?= |
|||
|
|||
SOURCES := client.c defs.h getopt.c main.c s5.c s5.h server.c util.c |
|||
|
|||
.PHONY: all clean |
|||
|
|||
all: $(BUILDDIR)/$(BUILDTYPE)/s5-proxy |
|||
|
|||
clean: |
|||
$(RM) $(BUILDDIR) |
|||
|
|||
$(BUILDDIR)/$(BUILDTYPE)/s5-proxy: $(BUILDDIR)/Makefile $(SOURCES) |
|||
$(MAKE) -C $(BUILDDIR) V=$(V) |
|||
|
|||
$(BUILDDIR)/Makefile: ../../common.gypi build.gyp |
|||
$(GYP) \
|
|||
-Duv_library=static_library \
|
|||
-Goutput_dir=. \
|
|||
-I../../common.gypi \
|
|||
-f make \
|
|||
--depth=. \
|
|||
--generator-output=$(BUILDDIR) \
|
|||
build.gyp |
@ -1,25 +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. |
|||
*/ |
|||
|
|||
provider uv { |
|||
probe tick__start(void* loop, int mode); |
|||
probe tick__stop(void* loop, int mode); |
|||
}; |
@ -0,0 +1,38 @@ |
|||
/* Copyright (c) 2014, Ben Noordhuis <info@bnoordhuis.nl>
|
|||
* |
|||
* Permission to use, copy, modify, and/or distribute this software for any |
|||
* purpose with or without fee is hereby granted, provided that the above |
|||
* copyright notice and this permission notice appear in all copies. |
|||
* |
|||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include "uv.h" |
|||
#include "task.h" |
|||
|
|||
static void timer_cb(uv_timer_t* handle) { |
|||
uv_close((uv_handle_t*) handle, NULL); |
|||
} |
|||
|
|||
|
|||
TEST_IMPL(loop_configure) { |
|||
uv_timer_t timer_handle; |
|||
uv_loop_t loop; |
|||
ASSERT(0 == uv_loop_init(&loop)); |
|||
#ifdef _WIN32 |
|||
ASSERT(UV_ENOSYS == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, 0)); |
|||
#else |
|||
ASSERT(0 == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF)); |
|||
#endif |
|||
ASSERT(0 == uv_timer_init(&loop, &timer_handle)); |
|||
ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 10, 0)); |
|||
ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); |
|||
ASSERT(0 == uv_loop_close(&loop)); |
|||
return 0; |
|||
} |
@ -0,0 +1,99 @@ |
|||
/* Copyright (c) 2015, Ben Noordhuis <info@bnoordhuis.nl>
|
|||
* |
|||
* Permission to use, copy, modify, and/or distribute this software for any |
|||
* purpose with or without fee is hereby granted, provided that the above |
|||
* copyright notice and this permission notice appear in all copies. |
|||
* |
|||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include "uv.h" |
|||
#include "task.h" |
|||
|
|||
#ifdef _WIN32 |
|||
|
|||
TEST_IMPL(pipe_set_non_blocking) { |
|||
RETURN_SKIP("Test not implemented on Windows."); |
|||
} |
|||
|
|||
#else /* !_WIN32 */ |
|||
|
|||
#include <errno.h> |
|||
#include <string.h> |
|||
#include <sys/socket.h> |
|||
#include <sys/types.h> |
|||
#include <sys/un.h> |
|||
#include <unistd.h> |
|||
|
|||
struct thread_ctx { |
|||
uv_barrier_t barrier; |
|||
int fd; |
|||
}; |
|||
|
|||
static void thread_main(void* arg) { |
|||
struct thread_ctx* ctx; |
|||
char buf[4096]; |
|||
ssize_t n; |
|||
|
|||
ctx = arg; |
|||
uv_barrier_wait(&ctx->barrier); |
|||
|
|||
do |
|||
n = read(ctx->fd, buf, sizeof(buf)); |
|||
while (n > 0 || (n == -1 && errno == EINTR)); |
|||
|
|||
ASSERT(n == 0); |
|||
} |
|||
|
|||
TEST_IMPL(pipe_set_non_blocking) { |
|||
struct thread_ctx ctx; |
|||
uv_pipe_t pipe_handle; |
|||
uv_thread_t thread; |
|||
size_t nwritten; |
|||
char data[4096]; |
|||
uv_buf_t buf; |
|||
int fd[2]; |
|||
int n; |
|||
|
|||
ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); |
|||
ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fd)); |
|||
ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); |
|||
ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1)); |
|||
|
|||
ctx.fd = fd[1]; |
|||
ASSERT(0 == uv_barrier_init(&ctx.barrier, 2)); |
|||
ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); |
|||
uv_barrier_wait(&ctx.barrier); |
|||
|
|||
buf.len = sizeof(data); |
|||
buf.base = data; |
|||
memset(data, '.', sizeof(data)); |
|||
|
|||
nwritten = 0; |
|||
while (nwritten < 10 << 20) { |
|||
/* The stream is in blocking mode so uv_try_write() should always succeed
|
|||
* with the exact number of bytes that we wanted written. |
|||
*/ |
|||
n = uv_try_write((uv_stream_t*) &pipe_handle, &buf, 1); |
|||
ASSERT(n == sizeof(data)); |
|||
nwritten += n; |
|||
} |
|||
|
|||
uv_close((uv_handle_t*) &pipe_handle, NULL); |
|||
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); |
|||
|
|||
ASSERT(0 == close(fd[1])); /* fd[0] is closed by uv_close(). */ |
|||
ASSERT(0 == uv_thread_join(&thread)); |
|||
uv_barrier_destroy(&ctx.barrier); |
|||
|
|||
MAKE_VALGRIND_HAPPY(); |
|||
return 0; |
|||
} |
|||
|
|||
#endif /* !_WIN32 */ |
@ -0,0 +1,114 @@ |
|||
/* Copyright Bert Belder, and other libuv 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. |
|||
*/ |
|||
|
|||
#ifdef _WIN32 |
|||
|
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
|
|||
#include "uv.h" |
|||
#include "task.h" |
|||
|
|||
#ifdef _MSC_VER /* msvc */ |
|||
# define NO_INLINE __declspec(noinline) |
|||
#else /* gcc */ |
|||
# define NO_INLINE __attribute__ ((noinline)) |
|||
#endif |
|||
|
|||
|
|||
uv_os_sock_t sock; |
|||
uv_poll_t handle; |
|||
|
|||
static int close_cb_called = 0; |
|||
|
|||
|
|||
static void close_cb(uv_handle_t* h) { |
|||
close_cb_called++; |
|||
} |
|||
|
|||
|
|||
static void poll_cb(uv_poll_t* h, int status, int events) { |
|||
ASSERT(0 && "should never get here"); |
|||
} |
|||
|
|||
|
|||
static void NO_INLINE close_socket_and_verify_stack() { |
|||
const uint32_t MARKER = 0xDEADBEEF; |
|||
const int VERIFY_AFTER = 10; /* ms */ |
|||
int r; |
|||
|
|||
volatile uint32_t data[65536]; |
|||
size_t i; |
|||
|
|||
for (i = 0; i < ARRAY_SIZE(data); i++) |
|||
data[i] = MARKER; |
|||
|
|||
r = closesocket(sock); |
|||
ASSERT(r == 0); |
|||
|
|||
uv_sleep(VERIFY_AFTER); |
|||
|
|||
for (i = 0; i < ARRAY_SIZE(data); i++) |
|||
ASSERT(data[i] == MARKER); |
|||
} |
|||
|
|||
|
|||
TEST_IMPL(poll_close_doesnt_corrupt_stack) { |
|||
struct WSAData wsa_data; |
|||
int r; |
|||
unsigned long on; |
|||
struct sockaddr_in addr; |
|||
|
|||
r = WSAStartup(MAKEWORD(2, 2), &wsa_data); |
|||
ASSERT(r == 0); |
|||
|
|||
sock = socket(AF_INET, SOCK_STREAM, 0); |
|||
ASSERT(sock != INVALID_SOCKET); |
|||
on = 1; |
|||
r = ioctlsocket(sock, FIONBIO, &on); |
|||
ASSERT(r == 0); |
|||
|
|||
r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr); |
|||
ASSERT(r == 0); |
|||
|
|||
r = connect(sock, (const struct sockaddr*) &addr, sizeof addr); |
|||
ASSERT(r != 0); |
|||
ASSERT(WSAGetLastError() == WSAEWOULDBLOCK); |
|||
|
|||
r = uv_poll_init_socket(uv_default_loop(), &handle, sock); |
|||
ASSERT(r == 0); |
|||
r = uv_poll_start(&handle, UV_READABLE | UV_WRITABLE, poll_cb); |
|||
ASSERT(r == 0); |
|||
|
|||
uv_close((uv_handle_t*) &handle, close_cb); |
|||
|
|||
close_socket_and_verify_stack(); |
|||
|
|||
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); |
|||
ASSERT(r == 0); |
|||
|
|||
ASSERT(close_cb_called == 1); |
|||
|
|||
MAKE_VALGRIND_HAPPY(); |
|||
return 0; |
|||
} |
|||
|
|||
#endif /* _WIN32 */ |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue