uv: upgrade to e7758e1
This commit is contained in:
parent
03e689fae4
commit
f0c629a36b
6
deps/uv/include/uv-private/uv-win.h
vendored
6
deps/uv/include/uv-private/uv-win.h
vendored
@ -23,6 +23,7 @@
|
|||||||
# define _WIN32_WINNT 0x0502
|
# define _WIN32_WINNT 0x0502
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <process.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <mswsock.h>
|
#include <mswsock.h>
|
||||||
@ -102,6 +103,9 @@
|
|||||||
LPOVERLAPPED lpOverlapped,
|
LPOVERLAPPED lpOverlapped,
|
||||||
LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
||||||
DWORD dwFlags);
|
DWORD dwFlags);
|
||||||
|
|
||||||
|
typedef PVOID RTL_SRWLOCK;
|
||||||
|
typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (WSAAPI* LPFN_WSARECV)
|
typedef int (WSAAPI* LPFN_WSARECV)
|
||||||
@ -144,7 +148,7 @@ typedef CRITICAL_SECTION uv_mutex_t;
|
|||||||
typedef union {
|
typedef union {
|
||||||
/* srwlock_ has type SRWLOCK, but not all toolchains define this type in */
|
/* srwlock_ has type SRWLOCK, but not all toolchains define this type in */
|
||||||
/* windows.h. */
|
/* windows.h. */
|
||||||
void* srwlock_;
|
SRWLOCK srwlock_;
|
||||||
struct {
|
struct {
|
||||||
uv_mutex_t read_mutex_;
|
uv_mutex_t read_mutex_;
|
||||||
uv_mutex_t write_mutex_;
|
uv_mutex_t write_mutex_;
|
||||||
|
8
deps/uv/include/uv.h
vendored
8
deps/uv/include/uv.h
vendored
@ -784,13 +784,6 @@ struct uv_pipe_s {
|
|||||||
*/
|
*/
|
||||||
UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
|
UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
|
||||||
|
|
||||||
/*
|
|
||||||
* Connects two initialized pipes on different loops.
|
|
||||||
* Data written to one pipe will appear on the other side.
|
|
||||||
* This function is thread-safe.
|
|
||||||
*/
|
|
||||||
UV_EXTERN uv_err_t uv_pipe_pair(uv_pipe_t* a, uv_pipe_t* b);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Opens an existing file descriptor or HANDLE as a pipe.
|
* Opens an existing file descriptor or HANDLE as a pipe.
|
||||||
*/
|
*/
|
||||||
@ -1356,7 +1349,6 @@ UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
|
|||||||
UV_EXTERN int uv_thread_create(uv_thread_t *tid,
|
UV_EXTERN int uv_thread_create(uv_thread_t *tid,
|
||||||
void (*entry)(void *arg), void *arg);
|
void (*entry)(void *arg), void *arg);
|
||||||
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
|
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
|
||||||
UV_EXTERN uv_thread_t uv_thread_self(void);
|
|
||||||
|
|
||||||
/* the presence of these unions force similar struct layout */
|
/* the presence of these unions force similar struct layout */
|
||||||
union uv_any_handle {
|
union uv_any_handle {
|
||||||
|
2
deps/uv/src/unix/core.c
vendored
2
deps/uv/src/unix/core.c
vendored
@ -221,7 +221,7 @@ int uv_run(uv_loop_t* loop) {
|
|||||||
|
|
||||||
|
|
||||||
int uv_run_once(uv_loop_t* loop) {
|
int uv_run_once(uv_loop_t* loop) {
|
||||||
ev_run(loop->ev, EVRUN_NOWAIT);
|
ev_run(loop->ev, EVRUN_ONCE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
deps/uv/src/unix/pipe.c
vendored
36
deps/uv/src/unix/pipe.c
vendored
@ -30,10 +30,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
static uv_once_t uv__pipe_pair_lock_guard = UV_ONCE_INIT;
|
|
||||||
static uv_mutex_t uv__pipe_pair_lock;
|
|
||||||
|
|
||||||
|
|
||||||
int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
|
int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
|
||||||
uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE);
|
uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE);
|
||||||
loop->counters.pipe_init++;
|
loop->counters.pipe_init++;
|
||||||
@ -43,38 +39,6 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void uv__pipe_pair_lock_init() {
|
|
||||||
uv_mutex_init(&uv__pipe_pair_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uv_err_t uv_pipe_pair(uv_pipe_t* a, uv_pipe_t* b) {
|
|
||||||
int fds[2];
|
|
||||||
int r;
|
|
||||||
uv_err_t err;
|
|
||||||
|
|
||||||
/* Make sure that the mutex is only initialized once. */
|
|
||||||
uv_once(&uv__pipe_pair_lock_guard, uv__pipe_pair_lock_init);
|
|
||||||
|
|
||||||
uv_mutex_lock(&uv__pipe_pair_lock);
|
|
||||||
|
|
||||||
r = uv__make_socketpair(fds, UV__F_NONBLOCK | UV__F_IPC);
|
|
||||||
|
|
||||||
if (r) {
|
|
||||||
err = uv__new_sys_error(errno);
|
|
||||||
} else {
|
|
||||||
uv_pipe_open(a, fds[0]);
|
|
||||||
uv_pipe_open(b, fds[1]);
|
|
||||||
err = uv_ok_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_mutex_unlock(&uv__pipe_pair_lock);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
|
int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
|
||||||
struct sockaddr_un saddr;
|
struct sockaddr_un saddr;
|
||||||
const char* pipe_fname;
|
const char* pipe_fname;
|
||||||
|
4
deps/uv/src/unix/thread.c
vendored
4
deps/uv/src/unix/thread.c
vendored
@ -47,10 +47,6 @@ int uv_thread_join(uv_thread_t *tid) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_thread_t uv_thread_self(void) {
|
|
||||||
return pthread_self();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int uv_mutex_init(uv_mutex_t* mutex) {
|
int uv_mutex_init(uv_mutex_t* mutex) {
|
||||||
if (pthread_mutex_init(mutex, NULL))
|
if (pthread_mutex_init(mutex, NULL))
|
||||||
|
5
deps/uv/src/unix/uv-eio.c
vendored
5
deps/uv/src/unix/uv-eio.c
vendored
@ -98,11 +98,6 @@ static void uv_eio_done_poll(eio_channel *channel) {
|
|||||||
|
|
||||||
static void uv__eio_init(void) {
|
static void uv__eio_init(void) {
|
||||||
eio_init(uv_eio_want_poll, uv_eio_done_poll);
|
eio_init(uv_eio_want_poll, uv_eio_done_poll);
|
||||||
/*
|
|
||||||
* Don't handle more than 10 reqs on each eio_poll(). This is to avoid
|
|
||||||
* race conditions. See Node's test/simple/test-eio-race.js
|
|
||||||
*/
|
|
||||||
eio_set_max_poll_reqs(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uv_once_t uv__eio_init_once_guard = UV_ONCE_INIT;
|
static uv_once_t uv__eio_init_once_guard = UV_ONCE_INIT;
|
||||||
|
6
deps/uv/src/win/pipe.c
vendored
6
deps/uv/src/win/pipe.c
vendored
@ -91,12 +91,6 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uv_err_t uv_pipe_pair(uv_pipe_t* a, uv_pipe_t* b) {
|
|
||||||
/* Implement me */
|
|
||||||
return uv__new_artificial_error(UV_ENOSYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void uv_pipe_connection_init(uv_pipe_t* handle) {
|
static void uv_pipe_connection_init(uv_pipe_t* handle) {
|
||||||
uv_connection_init((uv_stream_t*) handle);
|
uv_connection_init((uv_stream_t*) handle);
|
||||||
handle->read_req.data = handle;
|
handle->read_req.data = handle;
|
||||||
|
5
deps/uv/src/win/thread.c
vendored
5
deps/uv/src/win/thread.c
vendored
@ -113,11 +113,6 @@ int uv_thread_join(uv_thread_t *tid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uv_thread_t uv_thread_self(void) {
|
|
||||||
return GetCurrentThreadId();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int uv_mutex_init(uv_mutex_t* mutex) {
|
int uv_mutex_init(uv_mutex_t* mutex) {
|
||||||
InitializeCriticalSection(mutex);
|
InitializeCriticalSection(mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
5
deps/uv/src/win/winapi.h
vendored
5
deps/uv/src/win/winapi.h
vendored
@ -4337,11 +4337,6 @@ typedef NTSTATUS (NTAPI *sNtSetInformationFile)
|
|||||||
} OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY;
|
} OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
typedef PVOID RTL_SRWLOCK;
|
|
||||||
typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* from wincon.h */
|
/* from wincon.h */
|
||||||
#ifndef ENABLE_INSERT_MODE
|
#ifndef ENABLE_INSERT_MODE
|
||||||
# define ENABLE_INSERT_MODE 0x20
|
# define ENABLE_INSERT_MODE 0x20
|
||||||
|
88
deps/uv/test/test-eio-overflow.c
vendored
Normal file
88
deps/uv/test/test-eio-overflow.c
vendored
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/* 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 "task.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
static uv_idle_t idle;
|
||||||
|
|
||||||
|
static const int max_opened = 10000;
|
||||||
|
static const int max_delta = 4000;
|
||||||
|
|
||||||
|
static int opened = 0;
|
||||||
|
static int closed = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void work_cb(uv_work_t* work) {
|
||||||
|
/* continue as fast as possible */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void after_work_cb(uv_work_t* work) {
|
||||||
|
free(work);
|
||||||
|
closed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void make_eio_req(void) {
|
||||||
|
opened++;
|
||||||
|
|
||||||
|
uv_work_t* w = (uv_work_t*) malloc(sizeof(*w));
|
||||||
|
ASSERT(w != NULL);
|
||||||
|
|
||||||
|
uv_queue_work(uv_default_loop(), w, work_cb, after_work_cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void idle_cb(uv_idle_t* idle, int status) {
|
||||||
|
ASSERT(opened - closed < max_delta);
|
||||||
|
if (opened <= max_opened) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 30; i++) {
|
||||||
|
make_eio_req();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = uv_idle_stop(idle);
|
||||||
|
uv_unref(uv_default_loop());
|
||||||
|
ASSERT(r == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_IMPL(eio_overflow) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = uv_idle_init(uv_default_loop(), &idle);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
|
r = uv_idle_start(&idle, idle_cb);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
|
r = uv_run(uv_default_loop());
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
7
deps/uv/test/test-list.h
vendored
7
deps/uv/test/test-list.h
vendored
@ -29,7 +29,6 @@ TEST_DECLARE (tcp_ping_pong_v6)
|
|||||||
TEST_DECLARE (tcp_ref)
|
TEST_DECLARE (tcp_ref)
|
||||||
TEST_DECLARE (tcp_ref2)
|
TEST_DECLARE (tcp_ref2)
|
||||||
TEST_DECLARE (pipe_ping_pong)
|
TEST_DECLARE (pipe_ping_pong)
|
||||||
TEST_DECLARE (pipe_pair)
|
|
||||||
TEST_DECLARE (delayed_accept)
|
TEST_DECLARE (delayed_accept)
|
||||||
TEST_DECLARE (multiple_listen)
|
TEST_DECLARE (multiple_listen)
|
||||||
TEST_DECLARE (tcp_writealot)
|
TEST_DECLARE (tcp_writealot)
|
||||||
@ -123,10 +122,10 @@ TEST_DECLARE (fs_open_dir)
|
|||||||
TEST_DECLARE (fs_rename_to_existing_file)
|
TEST_DECLARE (fs_rename_to_existing_file)
|
||||||
TEST_DECLARE (threadpool_queue_work_simple)
|
TEST_DECLARE (threadpool_queue_work_simple)
|
||||||
TEST_DECLARE (threadpool_multiple_event_loops)
|
TEST_DECLARE (threadpool_multiple_event_loops)
|
||||||
|
TEST_DECLARE (eio_overflow)
|
||||||
TEST_DECLARE (thread_mutex)
|
TEST_DECLARE (thread_mutex)
|
||||||
TEST_DECLARE (thread_rwlock)
|
TEST_DECLARE (thread_rwlock)
|
||||||
TEST_DECLARE (thread_create)
|
TEST_DECLARE (thread_create)
|
||||||
TEST_DECLARE (thread_self)
|
|
||||||
TEST_DECLARE (strlcpy)
|
TEST_DECLARE (strlcpy)
|
||||||
TEST_DECLARE (strlcat)
|
TEST_DECLARE (strlcat)
|
||||||
TEST_DECLARE (counters_init)
|
TEST_DECLARE (counters_init)
|
||||||
@ -166,8 +165,6 @@ TASK_LIST_START
|
|||||||
TEST_ENTRY (pipe_ping_pong)
|
TEST_ENTRY (pipe_ping_pong)
|
||||||
TEST_HELPER (pipe_ping_pong, pipe_echo_server)
|
TEST_HELPER (pipe_ping_pong, pipe_echo_server)
|
||||||
|
|
||||||
TEST_ENTRY (pipe_pair)
|
|
||||||
|
|
||||||
TEST_ENTRY (delayed_accept)
|
TEST_ENTRY (delayed_accept)
|
||||||
TEST_ENTRY (multiple_listen)
|
TEST_ENTRY (multiple_listen)
|
||||||
|
|
||||||
@ -294,10 +291,10 @@ TASK_LIST_START
|
|||||||
TEST_ENTRY (fs_rename_to_existing_file)
|
TEST_ENTRY (fs_rename_to_existing_file)
|
||||||
TEST_ENTRY (threadpool_queue_work_simple)
|
TEST_ENTRY (threadpool_queue_work_simple)
|
||||||
TEST_ENTRY (threadpool_multiple_event_loops)
|
TEST_ENTRY (threadpool_multiple_event_loops)
|
||||||
|
TEST_ENTRY (eio_overflow)
|
||||||
TEST_ENTRY (thread_mutex)
|
TEST_ENTRY (thread_mutex)
|
||||||
TEST_ENTRY (thread_rwlock)
|
TEST_ENTRY (thread_rwlock)
|
||||||
TEST_ENTRY (thread_create)
|
TEST_ENTRY (thread_create)
|
||||||
TEST_ENTRY (thread_self)
|
|
||||||
TEST_ENTRY (strlcpy)
|
TEST_ENTRY (strlcpy)
|
||||||
TEST_ENTRY (strlcat)
|
TEST_ENTRY (strlcat)
|
||||||
TEST_ENTRY (counters_init)
|
TEST_ENTRY (counters_init)
|
||||||
|
137
deps/uv/test/test-pipe-pair.c
vendored
137
deps/uv/test/test-pipe-pair.c
vendored
@ -1,137 +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 "task.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define PING "PING"
|
|
||||||
|
|
||||||
static uv_pipe_t a;
|
|
||||||
static uv_pipe_t b;
|
|
||||||
static uv_write_t req;
|
|
||||||
static uv_buf_t buf;
|
|
||||||
static enum {
|
|
||||||
STATE_MAIN_START,
|
|
||||||
STATE_THREAD_START,
|
|
||||||
STATE_MAIN_CLOSE,
|
|
||||||
STATE_THREAD_CLOSE,
|
|
||||||
} state;
|
|
||||||
|
|
||||||
|
|
||||||
static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
|
|
||||||
ASSERT(state == STATE_MAIN_CLOSE);
|
|
||||||
state = STATE_THREAD_CLOSE;
|
|
||||||
|
|
||||||
ASSERT((uv_pipe_t*)stream == &b);
|
|
||||||
|
|
||||||
ASSERT(nread < 0);
|
|
||||||
ASSERT(uv_last_error(stream->loop).code == UV_EOF);
|
|
||||||
|
|
||||||
free(buf.base);
|
|
||||||
|
|
||||||
uv_close((uv_handle_t*)stream, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void main_thread_read_cb(uv_stream_t* stream, ssize_t nread,
|
|
||||||
uv_buf_t buf) {
|
|
||||||
ASSERT(state == STATE_THREAD_START);
|
|
||||||
state = STATE_MAIN_CLOSE;
|
|
||||||
|
|
||||||
ASSERT((uv_pipe_t*)stream == &a);
|
|
||||||
ASSERT(stream->loop == uv_default_loop());
|
|
||||||
|
|
||||||
if (nread > 0) {
|
|
||||||
ASSERT(strcmp(buf.base, PING) == 0);
|
|
||||||
uv_close((uv_handle_t*)stream, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(buf.base);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
|
||||||
uv_buf_t buf;
|
|
||||||
buf.base = (char*)malloc(size);
|
|
||||||
buf.len = size;
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void start(void* data) {
|
|
||||||
uv_loop_t* loop;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
ASSERT(state == STATE_MAIN_START);
|
|
||||||
state = STATE_THREAD_START;
|
|
||||||
|
|
||||||
loop = data;
|
|
||||||
|
|
||||||
buf = uv_buf_init(PING, strlen(PING));
|
|
||||||
|
|
||||||
if (uv_write(&req, (uv_stream_t*)&b, &buf, 1, NULL)) {
|
|
||||||
FATAL("uv_write failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_read_start((uv_stream_t*)&b, alloc_cb, pinger_read_cb);
|
|
||||||
|
|
||||||
uv_run(loop);
|
|
||||||
|
|
||||||
ASSERT(state == STATE_THREAD_CLOSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TEST_IMPL(pipe_pair) {
|
|
||||||
int r;
|
|
||||||
uv_err_t err;
|
|
||||||
uv_thread_t tid;
|
|
||||||
uv_loop_t* loop;
|
|
||||||
|
|
||||||
state = STATE_MAIN_START;
|
|
||||||
|
|
||||||
r = uv_pipe_init(uv_default_loop(), &a, 1);
|
|
||||||
ASSERT(r == 0);
|
|
||||||
|
|
||||||
loop = uv_loop_new();
|
|
||||||
ASSERT(loop);
|
|
||||||
|
|
||||||
r = uv_pipe_init(loop, &b, 1);
|
|
||||||
ASSERT(r == 0);
|
|
||||||
|
|
||||||
err = uv_pipe_pair(&a, &b);
|
|
||||||
ASSERT(err.code == UV_OK);
|
|
||||||
|
|
||||||
r = uv_thread_create(&tid, start, loop);
|
|
||||||
ASSERT(r == 0);
|
|
||||||
|
|
||||||
uv_read_start((uv_stream_t*)&a, alloc_cb, main_thread_read_cb);
|
|
||||||
|
|
||||||
uv_run(uv_default_loop());
|
|
||||||
uv_thread_join(&tid);
|
|
||||||
|
|
||||||
ASSERT(state == STATE_THREAD_CLOSE);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
16
deps/uv/test/test-thread.c
vendored
16
deps/uv/test/test-thread.c
vendored
@ -59,8 +59,6 @@ static volatile int thread_called;
|
|||||||
static void getaddrinfo_do(struct getaddrinfo_req* req) {
|
static void getaddrinfo_do(struct getaddrinfo_req* req) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
ASSERT(req->thread_id == uv_thread_self());
|
|
||||||
|
|
||||||
r = uv_getaddrinfo(req->loop,
|
r = uv_getaddrinfo(req->loop,
|
||||||
&req->handle,
|
&req->handle,
|
||||||
getaddrinfo_cb,
|
getaddrinfo_cb,
|
||||||
@ -89,8 +87,6 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* handle,
|
|||||||
static void fs_do(struct fs_req* req) {
|
static void fs_do(struct fs_req* req) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
ASSERT(req->thread_id == uv_thread_self());
|
|
||||||
|
|
||||||
r = uv_fs_stat(req->loop, &req->handle, ".", fs_cb);
|
r = uv_fs_stat(req->loop, &req->handle, ".", fs_cb);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
}
|
}
|
||||||
@ -107,19 +103,15 @@ static void fs_cb(uv_fs_t* handle) {
|
|||||||
static void do_work(void* arg) {
|
static void do_work(void* arg) {
|
||||||
struct getaddrinfo_req getaddrinfo_reqs[16];
|
struct getaddrinfo_req getaddrinfo_reqs[16];
|
||||||
struct fs_req fs_reqs[16];
|
struct fs_req fs_reqs[16];
|
||||||
uv_thread_t self;
|
|
||||||
uv_loop_t* loop;
|
uv_loop_t* loop;
|
||||||
size_t i;
|
size_t i;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
self = uv_thread_self();
|
|
||||||
|
|
||||||
loop = uv_loop_new();
|
loop = uv_loop_new();
|
||||||
ASSERT(loop != NULL);
|
ASSERT(loop != NULL);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(getaddrinfo_reqs); i++) {
|
for (i = 0; i < ARRAY_SIZE(getaddrinfo_reqs); i++) {
|
||||||
struct getaddrinfo_req* req = getaddrinfo_reqs + i;
|
struct getaddrinfo_req* req = getaddrinfo_reqs + i;
|
||||||
req->thread_id = self;
|
|
||||||
req->counter = 16;
|
req->counter = 16;
|
||||||
req->loop = loop;
|
req->loop = loop;
|
||||||
getaddrinfo_do(req);
|
getaddrinfo_do(req);
|
||||||
@ -127,7 +119,6 @@ static void do_work(void* arg) {
|
|||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(fs_reqs); i++) {
|
for (i = 0; i < ARRAY_SIZE(fs_reqs); i++) {
|
||||||
struct fs_req* req = fs_reqs + i;
|
struct fs_req* req = fs_reqs + i;
|
||||||
req->thread_id = self;
|
|
||||||
req->counter = 16;
|
req->counter = 16;
|
||||||
req->loop = loop;
|
req->loop = loop;
|
||||||
fs_do(req);
|
fs_do(req);
|
||||||
@ -162,13 +153,6 @@ TEST_IMPL(thread_create) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_IMPL(thread_self) {
|
|
||||||
uv_thread_t tid;
|
|
||||||
tid = uv_thread_self();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Hilariously bad test name. Run a lot of tasks in the thread pool and verify
|
/* Hilariously bad test name. Run a lot of tasks in the thread pool and verify
|
||||||
* that each "finished" callback is run in its originating thread.
|
* that each "finished" callback is run in its originating thread.
|
||||||
*/
|
*/
|
||||||
|
2
deps/uv/uv.gyp
vendored
2
deps/uv/uv.gyp
vendored
@ -284,6 +284,7 @@
|
|||||||
'test/test-connection-fail.c',
|
'test/test-connection-fail.c',
|
||||||
'test/test-cwd-and-chdir.c',
|
'test/test-cwd-and-chdir.c',
|
||||||
'test/test-delayed-accept.c',
|
'test/test-delayed-accept.c',
|
||||||
|
'test/test-eio-overflow.c',
|
||||||
'test/test-fail-always.c',
|
'test/test-fail-always.c',
|
||||||
'test/test-fs.c',
|
'test/test-fs.c',
|
||||||
'test/test-fs-event.c',
|
'test/test-fs-event.c',
|
||||||
@ -302,7 +303,6 @@
|
|||||||
'test/test-ping-pong.c',
|
'test/test-ping-pong.c',
|
||||||
'test/test-pipe-bind-error.c',
|
'test/test-pipe-bind-error.c',
|
||||||
'test/test-pipe-connect-error.c',
|
'test/test-pipe-connect-error.c',
|
||||||
'test/test-pipe-pair.c',
|
|
||||||
'test/test-platform-output.c',
|
'test/test-platform-output.c',
|
||||||
'test/test-process-title.c',
|
'test/test-process-title.c',
|
||||||
'test/test-ref.c',
|
'test/test-ref.c',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user