asyncengine 0.0.1.testing1 → 0.0.2.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -0
- data/Rakefile +38 -0
- data/asyncengine.gemspec +8 -4
- data/ext/asyncengine/ae_call_from_other_thread.c +106 -0
- data/ext/asyncengine/ae_call_from_other_thread.h +12 -0
- data/ext/asyncengine/ae_handle_common.c +193 -48
- data/ext/asyncengine/ae_handle_common.h +40 -13
- data/ext/asyncengine/ae_ip_utils.c +246 -0
- data/ext/asyncengine/ae_ip_utils.h +25 -0
- data/ext/asyncengine/ae_next_tick.c +81 -21
- data/ext/asyncengine/ae_next_tick.h +4 -2
- data/ext/asyncengine/ae_resolver.c +156 -0
- data/ext/asyncengine/ae_resolver.h +10 -0
- data/ext/asyncengine/ae_tcp.c +908 -0
- data/ext/asyncengine/ae_tcp.h +20 -0
- data/ext/asyncengine/ae_timer.c +355 -81
- data/ext/asyncengine/ae_timer.h +11 -4
- data/ext/asyncengine/ae_udp.c +579 -13
- data/ext/asyncengine/ae_udp.h +15 -2
- data/ext/asyncengine/ae_utils.c +192 -0
- data/ext/asyncengine/ae_utils.h +16 -0
- data/ext/asyncengine/asyncengine_ruby.c +469 -26
- data/ext/asyncengine/asyncengine_ruby.h +49 -11
- data/ext/asyncengine/debug.h +68 -0
- data/ext/asyncengine/extconf.rb +26 -2
- data/ext/asyncengine/ip_parser.c +5954 -0
- data/ext/asyncengine/ip_parser.h +16 -0
- data/ext/asyncengine/libuv/AUTHORS +16 -0
- data/ext/asyncengine/libuv/common.gypi +4 -4
- data/ext/asyncengine/libuv/config-mingw.mk +6 -6
- data/ext/asyncengine/libuv/config-unix.mk +13 -13
- data/ext/asyncengine/libuv/gyp_uv +5 -1
- data/ext/asyncengine/libuv/ibc_tests/exec_test.sh +8 -0
- data/ext/asyncengine/libuv/ibc_tests/uv_shutdown_write_issue.c +171 -0
- data/ext/asyncengine/libuv/ibc_tests/uv_tcp_close_while_connecting.c +102 -0
- data/ext/asyncengine/libuv/include/uv-private/ngx-queue.h +3 -1
- data/ext/asyncengine/libuv/include/uv-private/uv-unix.h +103 -50
- data/ext/asyncengine/libuv/include/uv-private/uv-win.h +76 -24
- data/ext/asyncengine/libuv/include/uv.h +353 -88
- data/ext/asyncengine/libuv/src/ares/ares__close_sockets.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares__get_hostent.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares__read_line.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares__timeval.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_cancel.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_data.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_destroy.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_expand_name.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_expand_string.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_fds.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_free_hostent.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_free_string.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_gethostbyaddr.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_gethostbyname.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_getnameinfo.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_getopt.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_getsock.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_init.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_library_init.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_llist.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_mkquery.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_nowarn.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_options.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_a_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_aaaa_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_mx_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_ns_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_ptr_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_srv_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_parse_txt_reply.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_process.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_query.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_search.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_send.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_strcasecmp.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_strdup.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_strerror.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_timeout.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_version.o +0 -0
- data/ext/asyncengine/libuv/src/ares/ares_writev.o +0 -0
- data/ext/asyncengine/libuv/src/ares/bitncmp.o +0 -0
- data/ext/asyncengine/libuv/src/ares/inet_net_pton.o +0 -0
- data/ext/asyncengine/libuv/src/ares/inet_ntop.o +0 -0
- data/ext/asyncengine/libuv/src/cares.c +225 -0
- data/ext/asyncengine/libuv/src/cares.o +0 -0
- data/ext/asyncengine/libuv/src/fs-poll.c +237 -0
- data/ext/asyncengine/libuv/src/fs-poll.o +0 -0
- data/ext/asyncengine/libuv/src/unix/async.c +78 -17
- data/ext/asyncengine/libuv/src/unix/async.o +0 -0
- data/ext/asyncengine/libuv/src/unix/core.c +305 -213
- data/ext/asyncengine/libuv/src/unix/core.o +0 -0
- data/ext/asyncengine/libuv/src/unix/cygwin.c +1 -1
- data/ext/asyncengine/libuv/src/unix/darwin.c +2 -1
- data/ext/asyncengine/libuv/src/unix/dl.c +36 -44
- data/ext/asyncengine/libuv/src/unix/dl.o +0 -0
- data/ext/asyncengine/libuv/src/unix/eio/eio.o +0 -0
- data/ext/asyncengine/libuv/src/unix/error.c +6 -0
- data/ext/asyncengine/libuv/src/unix/error.o +0 -0
- data/ext/asyncengine/libuv/src/unix/ev/ev.c +8 -4
- data/ext/asyncengine/libuv/src/unix/ev/ev.o +0 -0
- data/ext/asyncengine/libuv/src/unix/freebsd.c +1 -1
- data/ext/asyncengine/libuv/src/unix/fs.c +25 -33
- data/ext/asyncengine/libuv/src/unix/fs.o +0 -0
- data/ext/asyncengine/libuv/src/unix/internal.h +50 -31
- data/ext/asyncengine/libuv/src/unix/kqueue.c +2 -7
- data/ext/asyncengine/libuv/src/unix/linux/core.o +0 -0
- data/ext/asyncengine/libuv/src/unix/linux/inotify.c +12 -14
- data/ext/asyncengine/libuv/src/unix/linux/inotify.o +0 -0
- data/ext/asyncengine/libuv/src/unix/linux/{core.c → linux-core.c} +1 -1
- data/ext/asyncengine/libuv/src/unix/linux/linux-core.o +0 -0
- data/ext/asyncengine/libuv/src/unix/linux/syscalls.c +147 -1
- data/ext/asyncengine/libuv/src/unix/linux/syscalls.h +39 -2
- data/ext/asyncengine/libuv/src/unix/linux/syscalls.o +0 -0
- data/ext/asyncengine/libuv/src/unix/loop-watcher.c +63 -0
- data/ext/asyncengine/libuv/src/unix/loop-watcher.o +0 -0
- data/ext/asyncengine/libuv/src/unix/loop.c +29 -6
- data/ext/asyncengine/libuv/src/unix/loop.o +0 -0
- data/ext/asyncengine/libuv/src/unix/netbsd.c +1 -1
- data/ext/asyncengine/libuv/src/unix/openbsd.c +1 -1
- data/ext/asyncengine/libuv/src/unix/pipe.c +31 -36
- data/ext/asyncengine/libuv/src/unix/pipe.o +0 -0
- data/ext/asyncengine/libuv/src/unix/poll.c +116 -0
- data/ext/asyncengine/libuv/src/unix/poll.o +0 -0
- data/ext/asyncengine/libuv/src/unix/process.c +193 -115
- data/ext/asyncengine/libuv/src/unix/process.o +0 -0
- data/ext/asyncengine/libuv/src/unix/stream.c +146 -153
- data/ext/asyncengine/libuv/src/unix/stream.o +0 -0
- data/ext/asyncengine/libuv/src/unix/sunos.c +45 -36
- data/ext/asyncengine/libuv/src/unix/tcp.c +6 -5
- data/ext/asyncengine/libuv/src/unix/tcp.o +0 -0
- data/ext/asyncengine/libuv/src/unix/thread.c +82 -25
- data/ext/asyncengine/libuv/src/unix/thread.o +0 -0
- data/ext/asyncengine/libuv/src/unix/timer.c +69 -58
- data/ext/asyncengine/libuv/src/unix/timer.o +0 -0
- data/ext/asyncengine/libuv/src/unix/tty.c +3 -3
- data/ext/asyncengine/libuv/src/unix/tty.o +0 -0
- data/ext/asyncengine/libuv/src/unix/udp.c +57 -66
- data/ext/asyncengine/libuv/src/unix/udp.o +0 -0
- data/ext/asyncengine/libuv/src/unix/uv-eio.c +33 -50
- data/ext/asyncengine/libuv/src/unix/uv-eio.o +0 -0
- data/ext/asyncengine/libuv/src/uv-common.c +68 -38
- data/ext/asyncengine/libuv/src/uv-common.h +104 -20
- data/ext/asyncengine/libuv/src/uv-common.o +0 -0
- data/ext/asyncengine/libuv/src/win/async.c +20 -17
- data/ext/asyncengine/libuv/src/win/core.c +44 -31
- data/ext/asyncengine/libuv/src/win/dl.c +40 -36
- data/ext/asyncengine/libuv/src/win/error.c +21 -1
- data/ext/asyncengine/libuv/src/win/fs-event.c +19 -21
- data/ext/asyncengine/libuv/src/win/fs.c +541 -189
- data/ext/asyncengine/libuv/src/win/getaddrinfo.c +56 -63
- data/ext/asyncengine/libuv/src/win/handle-inl.h +145 -0
- data/ext/asyncengine/libuv/src/win/handle.c +26 -101
- data/ext/asyncengine/libuv/src/win/internal.h +92 -107
- data/ext/asyncengine/libuv/src/win/loop-watcher.c +6 -14
- data/ext/asyncengine/libuv/src/win/pipe.c +78 -64
- data/ext/asyncengine/libuv/src/win/poll.c +618 -0
- data/ext/asyncengine/libuv/src/win/process-stdio.c +479 -0
- data/ext/asyncengine/libuv/src/win/process.c +147 -274
- data/ext/asyncengine/libuv/src/win/req-inl.h +225 -0
- data/ext/asyncengine/libuv/src/win/req.c +0 -149
- data/ext/asyncengine/libuv/src/{unix/check.c → win/stream-inl.h} +31 -42
- data/ext/asyncengine/libuv/src/win/stream.c +9 -43
- data/ext/asyncengine/libuv/src/win/tcp.c +200 -82
- data/ext/asyncengine/libuv/src/win/thread.c +42 -2
- data/ext/asyncengine/libuv/src/win/threadpool.c +3 -2
- data/ext/asyncengine/libuv/src/win/timer.c +13 -63
- data/ext/asyncengine/libuv/src/win/tty.c +26 -20
- data/ext/asyncengine/libuv/src/win/udp.c +26 -17
- data/ext/asyncengine/libuv/src/win/util.c +312 -167
- data/ext/asyncengine/libuv/src/win/winapi.c +16 -1
- data/ext/asyncengine/libuv/src/win/winapi.h +33 -9
- data/ext/asyncengine/libuv/src/win/winsock.c +88 -1
- data/ext/asyncengine/libuv/src/win/winsock.h +36 -3
- data/ext/asyncengine/libuv/test/benchmark-ares.c +16 -17
- data/ext/asyncengine/libuv/test/benchmark-fs-stat.c +164 -0
- data/ext/asyncengine/libuv/test/benchmark-list.h +9 -0
- data/ext/asyncengine/libuv/{src/unix/prepare.c → test/benchmark-loop-count.c} +42 -33
- data/ext/asyncengine/libuv/test/benchmark-million-timers.c +65 -0
- data/ext/asyncengine/libuv/test/benchmark-pound.c +1 -1
- data/ext/asyncengine/libuv/test/benchmark-sizes.c +2 -0
- data/ext/asyncengine/libuv/test/benchmark-spawn.c +7 -1
- data/ext/asyncengine/libuv/test/benchmark-udp-packet-storm.c +1 -1
- data/ext/asyncengine/libuv/test/echo-server.c +8 -0
- data/ext/asyncengine/libuv/test/run-tests.c +30 -0
- data/ext/asyncengine/libuv/test/runner-unix.c +6 -26
- data/ext/asyncengine/libuv/test/runner-win.c +5 -63
- data/ext/asyncengine/libuv/test/runner.c +10 -1
- data/ext/asyncengine/libuv/test/task.h +0 -8
- data/ext/asyncengine/libuv/test/test-async.c +43 -141
- data/ext/asyncengine/libuv/test/test-callback-order.c +76 -0
- data/ext/asyncengine/libuv/test/test-counters-init.c +2 -3
- data/ext/asyncengine/libuv/test/test-dlerror.c +17 -8
- data/ext/asyncengine/libuv/test/test-fs-event.c +31 -39
- data/ext/asyncengine/libuv/test/test-fs-poll.c +146 -0
- data/ext/asyncengine/libuv/test/test-fs.c +114 -2
- data/ext/asyncengine/libuv/test/test-gethostbyname.c +8 -8
- data/ext/asyncengine/libuv/test/test-hrtime.c +18 -15
- data/ext/asyncengine/libuv/test/test-ipc.c +8 -2
- data/ext/asyncengine/libuv/test/test-list.h +59 -9
- data/ext/asyncengine/libuv/test/test-loop-handles.c +2 -25
- data/ext/asyncengine/libuv/{src/unix/idle.c → test/test-poll-close.c} +37 -39
- data/ext/asyncengine/libuv/test/test-poll.c +573 -0
- data/ext/asyncengine/libuv/test/test-ref.c +79 -63
- data/ext/asyncengine/libuv/test/test-run-once.c +15 -11
- data/ext/asyncengine/libuv/test/test-semaphore.c +111 -0
- data/ext/asyncengine/libuv/test/test-spawn.c +368 -20
- data/ext/asyncengine/libuv/test/test-stdio-over-pipes.c +25 -35
- data/ext/asyncengine/libuv/test/test-tcp-close-while-connecting.c +80 -0
- data/ext/asyncengine/libuv/test/test-tcp-close.c +1 -1
- data/ext/asyncengine/libuv/test/test-tcp-connect-error-after-write.c +95 -0
- data/ext/asyncengine/libuv/test/test-tcp-connect-timeout.c +85 -0
- data/ext/asyncengine/libuv/test/test-tcp-shutdown-after-write.c +131 -0
- data/ext/asyncengine/libuv/test/test-tcp-write-error.c +2 -2
- data/ext/asyncengine/libuv/test/test-tcp-writealot.c +29 -54
- data/ext/asyncengine/libuv/test/test-timer-again.c +1 -1
- data/ext/asyncengine/libuv/test/test-timer.c +23 -1
- data/ext/asyncengine/libuv/test/test-udp-options.c +1 -1
- data/ext/asyncengine/libuv/test/{test-eio-overflow.c → test-walk-handles.c} +31 -44
- data/ext/asyncengine/libuv/uv.gyp +26 -9
- data/ext/asyncengine/rb_utilities.c +54 -0
- data/ext/asyncengine/rb_utilities.h +63 -0
- data/lib/asyncengine.rb +45 -38
- data/lib/asyncengine/asyncengine_ext.so +0 -0
- data/lib/asyncengine/debug.rb +37 -0
- data/lib/asyncengine/handle.rb +9 -0
- data/lib/asyncengine/tcp.rb +28 -0
- data/lib/asyncengine/timer.rb +18 -28
- data/lib/asyncengine/udp.rb +29 -0
- data/lib/asyncengine/utils.rb +32 -0
- data/lib/asyncengine/uv_error.rb +17 -0
- data/lib/asyncengine/version.rb +9 -1
- data/test/ae_test_helper.rb +62 -0
- data/test/test_basic.rb +169 -0
- data/test/test_call_from_other_thread.rb +55 -0
- data/test/test_error.rb +92 -0
- data/test/test_ip_utils.rb +44 -0
- data/test/test_next_tick.rb +37 -0
- data/test/test_resolver.rb +51 -0
- data/test/test_threads.rb +69 -0
- data/test/test_timer.rb +95 -0
- data/test/test_udp.rb +216 -0
- data/test/test_utils.rb +49 -0
- metadata +84 -57
- data/ext/asyncengine/libuv/mkmf.log +0 -24
- data/ext/asyncengine/libuv/src/unix/cares.c +0 -194
- data/ext/asyncengine/libuv/src/unix/cares.o +0 -0
- data/ext/asyncengine/libuv/src/unix/check.o +0 -0
- data/ext/asyncengine/libuv/src/unix/idle.o +0 -0
- data/ext/asyncengine/libuv/src/unix/prepare.o +0 -0
- data/ext/asyncengine/libuv/src/win/cares.c +0 -290
- data/lib/asyncengine/errors.rb +0 -5
- data/lib/asyncengine/next_tick.rb +0 -24
@@ -100,7 +100,7 @@ static void connect_cb(uv_connect_t* req, int status) {
|
|
100
100
|
r = uv_write(&(wr->req), req->handle, &wr->buf, 1, write_cb);
|
101
101
|
ASSERT(r == 0);
|
102
102
|
|
103
|
-
if (req->handle->write_queue_size
|
103
|
+
if (req->handle->write_queue_size >= size * 2) {
|
104
104
|
break;
|
105
105
|
}
|
106
106
|
}
|
@@ -161,7 +161,7 @@ TEST_IMPL(tcp_write_error) {
|
|
161
161
|
ASSERT(r == 0);
|
162
162
|
|
163
163
|
ASSERT(write_cb_called > 0);
|
164
|
-
ASSERT(write_cb_error_called
|
164
|
+
ASSERT(write_cb_error_called >= 1);
|
165
165
|
ASSERT(tcp_client.write_queue_size == 0);
|
166
166
|
|
167
167
|
return 0;
|
@@ -31,32 +31,28 @@
|
|
31
31
|
|
32
32
|
#define TOTAL_BYTES (WRITES * CHUNKS_PER_WRITE * CHUNK_SIZE)
|
33
33
|
|
34
|
-
|
35
34
|
static char* send_buffer;
|
36
35
|
|
37
|
-
|
38
36
|
static int shutdown_cb_called = 0;
|
39
37
|
static int connect_cb_called = 0;
|
40
38
|
static int write_cb_called = 0;
|
41
39
|
static int close_cb_called = 0;
|
42
|
-
static
|
43
|
-
static
|
44
|
-
static
|
40
|
+
static size_t bytes_sent = 0;
|
41
|
+
static size_t bytes_sent_done = 0;
|
42
|
+
static size_t bytes_received_done = 0;
|
43
|
+
|
44
|
+
static uv_connect_t connect_req;
|
45
|
+
static uv_shutdown_t shutdown_req;
|
46
|
+
static uv_write_t write_reqs[WRITES];
|
45
47
|
|
46
48
|
|
47
49
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
48
|
-
|
49
|
-
buf.base = (char*)malloc(size);
|
50
|
-
buf.len = size;
|
51
|
-
return buf;
|
50
|
+
return uv_buf_init(malloc(size), size);
|
52
51
|
}
|
53
52
|
|
54
53
|
|
55
54
|
static void close_cb(uv_handle_t* handle) {
|
56
55
|
ASSERT(handle != NULL);
|
57
|
-
|
58
|
-
free(handle);
|
59
|
-
|
60
56
|
close_cb_called++;
|
61
57
|
}
|
62
58
|
|
@@ -64,7 +60,7 @@ static void close_cb(uv_handle_t* handle) {
|
|
64
60
|
static void shutdown_cb(uv_shutdown_t* req, int status) {
|
65
61
|
uv_tcp_t* tcp;
|
66
62
|
|
67
|
-
ASSERT(req);
|
63
|
+
ASSERT(req == &shutdown_req);
|
68
64
|
ASSERT(status == 0);
|
69
65
|
|
70
66
|
tcp = (uv_tcp_t*)(req->handle);
|
@@ -77,28 +73,21 @@ static void shutdown_cb(uv_shutdown_t* req, int status) {
|
|
77
73
|
|
78
74
|
/* We should have had all the writes called already. */
|
79
75
|
ASSERT(write_cb_called == WRITES);
|
80
|
-
|
81
|
-
free(req);
|
82
76
|
}
|
83
77
|
|
84
78
|
|
85
79
|
static void read_cb(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
|
86
80
|
ASSERT(tcp != NULL);
|
87
81
|
|
88
|
-
if (nread
|
82
|
+
if (nread >= 0) {
|
83
|
+
bytes_received_done += nread;
|
84
|
+
}
|
85
|
+
else {
|
89
86
|
ASSERT(uv_last_error(uv_default_loop()).code == UV_EOF);
|
90
87
|
printf("GOT EOF\n");
|
91
|
-
|
92
|
-
if (buf.base) {
|
93
|
-
free(buf.base);
|
94
|
-
}
|
95
|
-
|
96
88
|
uv_close((uv_handle_t*)tcp, close_cb);
|
97
|
-
return;
|
98
89
|
}
|
99
90
|
|
100
|
-
bytes_received_done += nread;
|
101
|
-
|
102
91
|
free(buf.base);
|
103
92
|
}
|
104
93
|
|
@@ -114,71 +103,55 @@ static void write_cb(uv_write_t* req, int status) {
|
|
114
103
|
|
115
104
|
bytes_sent_done += CHUNKS_PER_WRITE * CHUNK_SIZE;
|
116
105
|
write_cb_called++;
|
117
|
-
|
118
|
-
free(req);
|
119
106
|
}
|
120
107
|
|
121
108
|
|
122
109
|
static void connect_cb(uv_connect_t* req, int status) {
|
123
110
|
uv_buf_t send_bufs[CHUNKS_PER_WRITE];
|
124
|
-
|
125
|
-
uv_write_t* write_req;
|
126
|
-
uv_shutdown_t* shutdown_req;
|
111
|
+
uv_stream_t* stream;
|
127
112
|
int i, j, r;
|
128
113
|
|
129
|
-
ASSERT(req
|
114
|
+
ASSERT(req == &connect_req);
|
130
115
|
ASSERT(status == 0);
|
131
116
|
|
132
|
-
|
133
|
-
|
117
|
+
stream = req->handle;
|
134
118
|
connect_cb_called++;
|
135
|
-
free(req);
|
136
119
|
|
137
120
|
/* Write a lot of data */
|
138
121
|
for (i = 0; i < WRITES; i++) {
|
122
|
+
uv_write_t* write_req = write_reqs + i;
|
123
|
+
|
139
124
|
for (j = 0; j < CHUNKS_PER_WRITE; j++) {
|
140
|
-
send_bufs[j]
|
141
|
-
send_bufs[j].base = send_buffer + bytes_sent;
|
125
|
+
send_bufs[j] = uv_buf_init(send_buffer + bytes_sent, CHUNK_SIZE);
|
142
126
|
bytes_sent += CHUNK_SIZE;
|
143
127
|
}
|
144
128
|
|
145
|
-
|
146
|
-
ASSERT(write_req != NULL);
|
147
|
-
|
148
|
-
r = uv_write(write_req, (uv_stream_t*) tcp, (uv_buf_t*)&send_bufs,
|
149
|
-
CHUNKS_PER_WRITE, write_cb);
|
129
|
+
r = uv_write(write_req, stream, send_bufs, CHUNKS_PER_WRITE, write_cb);
|
150
130
|
ASSERT(r == 0);
|
151
131
|
}
|
152
132
|
|
153
|
-
/* Shutdown on drain.
|
154
|
-
|
155
|
-
ASSERT(shutdown_req != NULL);
|
156
|
-
r = uv_shutdown(shutdown_req, (uv_stream_t*)tcp, shutdown_cb);
|
133
|
+
/* Shutdown on drain. */
|
134
|
+
r = uv_shutdown(&shutdown_req, stream, shutdown_cb);
|
157
135
|
ASSERT(r == 0);
|
158
136
|
|
159
137
|
/* Start reading */
|
160
|
-
r = uv_read_start(
|
138
|
+
r = uv_read_start(stream, alloc_cb, read_cb);
|
161
139
|
ASSERT(r == 0);
|
162
140
|
}
|
163
141
|
|
164
142
|
|
165
143
|
TEST_IMPL(tcp_writealot) {
|
166
144
|
struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
|
167
|
-
uv_tcp_t
|
168
|
-
uv_connect_t* connect_req = malloc(sizeof(uv_connect_t));
|
145
|
+
uv_tcp_t client;
|
169
146
|
int r;
|
170
147
|
|
171
|
-
|
172
|
-
ASSERT(connect_req != NULL);
|
173
|
-
|
174
|
-
send_buffer = (char*)malloc(TOTAL_BYTES + 1);
|
175
|
-
|
148
|
+
send_buffer = malloc(TOTAL_BYTES);
|
176
149
|
ASSERT(send_buffer != NULL);
|
177
150
|
|
178
|
-
r = uv_tcp_init(uv_default_loop(), client);
|
151
|
+
r = uv_tcp_init(uv_default_loop(), &client);
|
179
152
|
ASSERT(r == 0);
|
180
153
|
|
181
|
-
r = uv_tcp_connect(connect_req, client, addr, connect_cb);
|
154
|
+
r = uv_tcp_connect(&connect_req, &client, addr, connect_cb);
|
182
155
|
ASSERT(r == 0);
|
183
156
|
|
184
157
|
uv_run(uv_default_loop());
|
@@ -191,5 +164,7 @@ TEST_IMPL(tcp_writealot) {
|
|
191
164
|
ASSERT(bytes_sent_done == TOTAL_BYTES);
|
192
165
|
ASSERT(bytes_received_done == TOTAL_BYTES);
|
193
166
|
|
167
|
+
free(send_buffer);
|
168
|
+
|
194
169
|
return 0;
|
195
170
|
}
|
@@ -104,7 +104,7 @@ TEST_IMPL(timer_again) {
|
|
104
104
|
r = uv_timer_again(&dummy);
|
105
105
|
ASSERT(r == -1);
|
106
106
|
ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL);
|
107
|
-
uv_unref(
|
107
|
+
uv_unref((uv_handle_t*)&dummy);
|
108
108
|
|
109
109
|
/* Start timer repeat_1. */
|
110
110
|
r = uv_timer_init(uv_default_loop(), &repeat_1);
|
@@ -35,6 +35,7 @@ static void once_close_cb(uv_handle_t* handle) {
|
|
35
35
|
printf("ONCE_CLOSE_CB\n");
|
36
36
|
|
37
37
|
ASSERT(handle != NULL);
|
38
|
+
ASSERT(!uv_is_active(handle));
|
38
39
|
|
39
40
|
once_close_cb_called++;
|
40
41
|
}
|
@@ -45,6 +46,7 @@ static void once_cb(uv_timer_t* handle, int status) {
|
|
45
46
|
|
46
47
|
ASSERT(handle != NULL);
|
47
48
|
ASSERT(status == 0);
|
49
|
+
ASSERT(!uv_is_active((uv_handle_t*)handle));
|
48
50
|
|
49
51
|
once_cb_called++;
|
50
52
|
|
@@ -69,6 +71,7 @@ static void repeat_cb(uv_timer_t* handle, int status) {
|
|
69
71
|
|
70
72
|
ASSERT(handle != NULL);
|
71
73
|
ASSERT(status == 0);
|
74
|
+
ASSERT(uv_is_active((uv_handle_t*)handle));
|
72
75
|
|
73
76
|
repeat_cb_called++;
|
74
77
|
|
@@ -114,7 +117,7 @@ TEST_IMPL(timer) {
|
|
114
117
|
ASSERT(r == 0);
|
115
118
|
r = uv_timer_stop(&never);
|
116
119
|
ASSERT(r == 0);
|
117
|
-
uv_unref(
|
120
|
+
uv_unref((uv_handle_t*)&never);
|
118
121
|
|
119
122
|
uv_run(uv_default_loop());
|
120
123
|
|
@@ -128,3 +131,22 @@ TEST_IMPL(timer) {
|
|
128
131
|
|
129
132
|
return 0;
|
130
133
|
}
|
134
|
+
|
135
|
+
|
136
|
+
TEST_IMPL(timer_start_twice) {
|
137
|
+
uv_timer_t once;
|
138
|
+
int r;
|
139
|
+
|
140
|
+
r = uv_timer_init(uv_default_loop(), &once);
|
141
|
+
ASSERT(r == 0);
|
142
|
+
r = uv_timer_start(&once, never_cb, 86400 * 1000, 0);
|
143
|
+
ASSERT(r == 0);
|
144
|
+
r = uv_timer_start(&once, once_cb, 10, 0);
|
145
|
+
ASSERT(r == 0);
|
146
|
+
r = uv_run(uv_default_loop());
|
147
|
+
ASSERT(r == 0);
|
148
|
+
|
149
|
+
ASSERT(once_cb_called == 1);
|
150
|
+
|
151
|
+
return 0;
|
152
|
+
}
|
@@ -38,7 +38,7 @@ TEST_IMPL(udp_options) {
|
|
38
38
|
r = uv_udp_init(loop, &h);
|
39
39
|
ASSERT(r == 0);
|
40
40
|
|
41
|
-
uv_unref(
|
41
|
+
uv_unref((uv_handle_t*)&h); /* don't keep the loop alive */
|
42
42
|
|
43
43
|
r = uv_udp_bind(&h, uv_ip4_addr("0.0.0.0", TEST_PORT), 0);
|
44
44
|
ASSERT(r == 0);
|
@@ -21,70 +21,57 @@
|
|
21
21
|
|
22
22
|
#include "uv.h"
|
23
23
|
#include "task.h"
|
24
|
+
|
24
25
|
#include <stdio.h>
|
25
26
|
#include <stdlib.h>
|
26
27
|
|
28
|
+
static char magic_cookie[] = "magic cookie";
|
29
|
+
static int seen_timer_handle;
|
30
|
+
static uv_timer_t timer;
|
27
31
|
|
28
|
-
static uv_idle_t idle;
|
29
|
-
|
30
|
-
static const int max_opened = 10000;
|
31
|
-
static const int max_delta = 4000;
|
32
|
-
|
33
|
-
static int opened = 0;
|
34
|
-
static int closed = 0;
|
35
|
-
|
36
|
-
|
37
|
-
void work_cb(uv_work_t* work) {
|
38
|
-
/* continue as fast as possible */
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
void after_work_cb(uv_work_t* work) {
|
43
|
-
free(work);
|
44
|
-
closed++;
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
void make_eio_req(void) {
|
49
|
-
uv_work_t* w;
|
50
|
-
|
51
|
-
opened++;
|
52
32
|
|
53
|
-
|
54
|
-
ASSERT(
|
33
|
+
static void walk_cb(uv_handle_t* handle, void* arg) {
|
34
|
+
ASSERT(arg == (void*)magic_cookie);
|
55
35
|
|
56
|
-
|
36
|
+
if (handle == (uv_handle_t*)&timer) {
|
37
|
+
seen_timer_handle++;
|
38
|
+
} else {
|
39
|
+
ASSERT(0 && "unexpected handle");
|
40
|
+
}
|
57
41
|
}
|
58
42
|
|
59
43
|
|
60
|
-
void
|
61
|
-
ASSERT(
|
62
|
-
|
63
|
-
int i;
|
64
|
-
for (i = 0; i < 30; i++) {
|
65
|
-
make_eio_req();
|
66
|
-
}
|
67
|
-
} else {
|
68
|
-
int r;
|
44
|
+
static void timer_cb(uv_timer_t* handle, int status) {
|
45
|
+
ASSERT(handle == &timer);
|
46
|
+
ASSERT(status == 0);
|
69
47
|
|
70
|
-
|
71
|
-
|
72
|
-
ASSERT(r == 0);
|
73
|
-
}
|
48
|
+
uv_walk(handle->loop, walk_cb, magic_cookie);
|
49
|
+
uv_close((uv_handle_t*)handle, NULL);
|
74
50
|
}
|
75
51
|
|
76
52
|
|
77
|
-
TEST_IMPL(
|
53
|
+
TEST_IMPL(walk_handles) {
|
54
|
+
uv_loop_t* loop;
|
78
55
|
int r;
|
79
56
|
|
80
|
-
|
57
|
+
loop = uv_default_loop();
|
58
|
+
|
59
|
+
r = uv_timer_init(loop, &timer);
|
81
60
|
ASSERT(r == 0);
|
82
61
|
|
83
|
-
r =
|
62
|
+
r = uv_timer_start(&timer, timer_cb, 1, 0);
|
84
63
|
ASSERT(r == 0);
|
85
64
|
|
86
|
-
|
65
|
+
/* Start event loop, expect to see the timer handle in walk_cb. */
|
66
|
+
ASSERT(seen_timer_handle == 0);
|
67
|
+
r = uv_run(loop);
|
87
68
|
ASSERT(r == 0);
|
69
|
+
ASSERT(seen_timer_handle == 1);
|
70
|
+
|
71
|
+
/* Loop is finished, walk_cb should not see our timer handle. */
|
72
|
+
seen_timer_handle = 0;
|
73
|
+
uv_walk(loop, walk_cb, magic_cookie);
|
74
|
+
ASSERT(seen_timer_handle == 0);
|
88
75
|
|
89
76
|
return 0;
|
90
77
|
}
|
@@ -47,6 +47,10 @@
|
|
47
47
|
'include/ares.h',
|
48
48
|
'include/ares_version.h',
|
49
49
|
'include/uv.h',
|
50
|
+
'include/uv-private/ngx-queue.h',
|
51
|
+
'include/uv-private/tree.h',
|
52
|
+
'src/cares.c',
|
53
|
+
'src/fs-poll.c',
|
50
54
|
'src/uv-common.c',
|
51
55
|
'src/uv-common.h',
|
52
56
|
'src/ares/ares_cancel.c',
|
@@ -125,7 +129,6 @@
|
|
125
129
|
'_GNU_SOURCE',
|
126
130
|
],
|
127
131
|
'sources': [
|
128
|
-
'include/uv-private/tree.h',
|
129
132
|
'include/uv-private/uv-win.h',
|
130
133
|
'src/ares/config_win32/ares_config.h',
|
131
134
|
'src/ares/windows_port.c',
|
@@ -133,7 +136,6 @@
|
|
133
136
|
'src/ares/ares_iphlpapi.h',
|
134
137
|
'src/ares/ares_platform.c',
|
135
138
|
'src/win/async.c',
|
136
|
-
'src/win/cares.c',
|
137
139
|
'src/win/core.c',
|
138
140
|
'src/win/dl.c',
|
139
141
|
'src/win/error.c',
|
@@ -141,13 +143,18 @@
|
|
141
143
|
'src/win/fs-event.c',
|
142
144
|
'src/win/getaddrinfo.c',
|
143
145
|
'src/win/handle.c',
|
146
|
+
'src/win/handle-inl.h',
|
144
147
|
'src/win/internal.h',
|
145
148
|
'src/win/loop-watcher.c',
|
146
149
|
'src/win/pipe.c',
|
147
150
|
'src/win/thread.c',
|
151
|
+
'src/win/poll.c',
|
148
152
|
'src/win/process.c',
|
153
|
+
'src/win/process-stdio.c',
|
149
154
|
'src/win/req.c',
|
155
|
+
'src/win/req-inl.h',
|
150
156
|
'src/win/stream.c',
|
157
|
+
'src/win/stream-inl.h',
|
151
158
|
'src/win/tcp.c',
|
152
159
|
'src/win/tty.c',
|
153
160
|
'src/win/threadpool.c',
|
@@ -178,11 +185,8 @@
|
|
178
185
|
'sources': [
|
179
186
|
'include/uv-private/eio.h',
|
180
187
|
'include/uv-private/ev.h',
|
181
|
-
'include/uv-private/ngx-queue.h',
|
182
188
|
'include/uv-private/uv-unix.h',
|
183
189
|
'src/unix/async.c',
|
184
|
-
'src/unix/cares.c',
|
185
|
-
'src/unix/check.c',
|
186
190
|
'src/unix/core.c',
|
187
191
|
'src/unix/dl.c',
|
188
192
|
'src/unix/eio/ecb.h',
|
@@ -194,11 +198,11 @@
|
|
194
198
|
'src/unix/ev/ev_wrap.h',
|
195
199
|
'src/unix/ev/event.h',
|
196
200
|
'src/unix/fs.c',
|
197
|
-
'src/unix/idle.c',
|
198
201
|
'src/unix/internal.h',
|
199
202
|
'src/unix/loop.c',
|
203
|
+
'src/unix/loop-watcher.c',
|
200
204
|
'src/unix/pipe.c',
|
201
|
-
'src/unix/
|
205
|
+
'src/unix/poll.c',
|
202
206
|
'src/unix/process.c',
|
203
207
|
'src/unix/stream.c',
|
204
208
|
'src/unix/tcp.c',
|
@@ -229,7 +233,7 @@
|
|
229
233
|
[ 'OS=="linux"', {
|
230
234
|
'include_dirs': [ 'src/ares/config_linux' ],
|
231
235
|
'sources': [
|
232
|
-
'src/unix/linux/core.c',
|
236
|
+
'src/unix/linux/linux-core.c',
|
233
237
|
'src/unix/linux/inotify.c',
|
234
238
|
'src/unix/linux/syscalls.c',
|
235
239
|
'src/unix/linux/syscalls.h',
|
@@ -302,10 +306,10 @@
|
|
302
306
|
'test/test-async.c',
|
303
307
|
'test/test-error.c',
|
304
308
|
'test/test-callback-stack.c',
|
309
|
+
'test/test-callback-order.c',
|
305
310
|
'test/test-connection-fail.c',
|
306
311
|
'test/test-cwd-and-chdir.c',
|
307
312
|
'test/test-delayed-accept.c',
|
308
|
-
'test/test-eio-overflow.c',
|
309
313
|
'test/test-fail-always.c',
|
310
314
|
'test/test-fs.c',
|
311
315
|
'test/test-fs-event.c',
|
@@ -320,23 +324,33 @@
|
|
320
324
|
'test/test-ipc-send-recv.c',
|
321
325
|
'test/test-list.h',
|
322
326
|
'test/test-loop-handles.c',
|
327
|
+
'test/test-walk-handles.c',
|
323
328
|
'test/test-multiple-listen.c',
|
324
329
|
'test/test-pass-always.c',
|
325
330
|
'test/test-ping-pong.c',
|
326
331
|
'test/test-pipe-bind-error.c',
|
327
332
|
'test/test-pipe-connect-error.c',
|
328
333
|
'test/test-platform-output.c',
|
334
|
+
'test/test-poll.c',
|
335
|
+
'test/test-poll-close.c',
|
329
336
|
'test/test-process-title.c',
|
330
337
|
'test/test-ref.c',
|
338
|
+
'test/test-run-once.c',
|
339
|
+
'test/test-semaphore.c',
|
331
340
|
'test/test-shutdown-close.c',
|
332
341
|
'test/test-shutdown-eof.c',
|
333
342
|
'test/test-spawn.c',
|
343
|
+
'test/test-fs-poll.c',
|
334
344
|
'test/test-stdio-over-pipes.c',
|
335
345
|
'test/test-tcp-bind-error.c',
|
336
346
|
'test/test-tcp-bind6-error.c',
|
337
347
|
'test/test-tcp-close.c',
|
348
|
+
'test/test-tcp-close-while-connecting.c',
|
349
|
+
'test/test-tcp-connect-error-after-write.c',
|
350
|
+
'test/test-tcp-shutdown-after-write.c',
|
338
351
|
'test/test-tcp-flags.c',
|
339
352
|
'test/test-tcp-connect-error.c',
|
353
|
+
'test/test-tcp-connect-timeout.c',
|
340
354
|
'test/test-tcp-connect6-error.c',
|
341
355
|
'test/test-tcp-write-error.c',
|
342
356
|
'test/test-tcp-write-to-half-open-connection.c',
|
@@ -390,8 +404,11 @@
|
|
390
404
|
'dependencies': [ 'uv' ],
|
391
405
|
'sources': [
|
392
406
|
'test/benchmark-ares.c',
|
407
|
+
'test/benchmark-fs-stat.c',
|
393
408
|
'test/benchmark-getaddrinfo.c',
|
394
409
|
'test/benchmark-list.h',
|
410
|
+
'test/benchmark-loop-count.c',
|
411
|
+
'test/benchmark-million-timers.c',
|
395
412
|
'test/benchmark-ping-pongs.c',
|
396
413
|
'test/benchmark-pound.c',
|
397
414
|
'test/benchmark-pump.c',
|