noderb 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/noderb_extension/extconf.rb +4 -2
- data/ext/noderb_extension/libuv/AUTHORS +2 -0
- data/ext/noderb_extension/libuv/Makefile +1 -1
- data/ext/noderb_extension/libuv/common.gypi +51 -51
- data/ext/noderb_extension/libuv/config-mingw.mk +3 -9
- data/ext/noderb_extension/libuv/config-unix.mk +10 -1
- data/ext/noderb_extension/libuv/include/uv-private/uv-unix.h +3 -2
- data/ext/noderb_extension/libuv/include/uv-private/uv-win.h +7 -6
- data/ext/noderb_extension/libuv/include/uv.h +47 -13
- data/ext/noderb_extension/libuv/src/ares/config_netbsd/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/unix/core.c +20 -65
- data/ext/noderb_extension/libuv/src/unix/darwin.c +1 -0
- data/ext/noderb_extension/libuv/src/unix/eio/config_netbsd.h +81 -0
- data/ext/noderb_extension/libuv/src/unix/error.c +9 -1
- data/ext/noderb_extension/libuv/src/unix/ev/config_netbsd.h +120 -0
- data/ext/noderb_extension/libuv/src/unix/fs.c +151 -21
- data/ext/noderb_extension/libuv/src/unix/internal.h +30 -0
- data/ext/noderb_extension/libuv/src/unix/netbsd.c +68 -0
- data/ext/noderb_extension/libuv/src/unix/pipe.c +20 -30
- data/ext/noderb_extension/libuv/src/unix/process.c +13 -0
- data/ext/noderb_extension/libuv/src/unix/stream.c +105 -63
- data/ext/noderb_extension/libuv/src/unix/tcp.c +75 -21
- data/ext/noderb_extension/libuv/src/unix/tty.c +69 -0
- data/ext/noderb_extension/libuv/src/unix/udp.c +31 -0
- data/ext/noderb_extension/libuv/src/uv-common.c +2 -0
- data/ext/noderb_extension/libuv/src/uv-common.h +0 -6
- data/ext/noderb_extension/libuv/src/win/cares.c +7 -7
- data/ext/noderb_extension/libuv/src/win/core.c +25 -17
- data/ext/noderb_extension/libuv/src/win/error.c +7 -0
- data/ext/noderb_extension/libuv/src/win/fs.c +587 -92
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +3 -1
- data/ext/noderb_extension/libuv/src/win/handle.c +0 -17
- data/ext/noderb_extension/libuv/src/win/internal.h +15 -5
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +1 -1
- data/ext/noderb_extension/libuv/src/win/pipe.c +6 -0
- data/ext/noderb_extension/libuv/src/win/process.c +90 -43
- data/ext/noderb_extension/libuv/src/win/tcp.c +37 -4
- data/ext/noderb_extension/libuv/src/win/threads.c +81 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +15 -15
- data/ext/noderb_extension/libuv/src/win/tty.c +37 -0
- data/ext/noderb_extension/libuv/src/win/udp.c +8 -2
- data/ext/noderb_extension/libuv/src/win/winapi.c +12 -0
- data/ext/noderb_extension/libuv/src/win/winapi.h +1146 -1015
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +0 -1
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +0 -1
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +0 -1
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +0 -1
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +4 -6
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +0 -1
- data/ext/noderb_extension/libuv/test/benchmark-udp-packet-storm.c +0 -1
- data/ext/noderb_extension/libuv/test/dns-server.c +2 -2
- data/ext/noderb_extension/libuv/test/echo-server.c +4 -5
- data/ext/noderb_extension/libuv/test/run-tests.c +0 -2
- data/ext/noderb_extension/libuv/test/test-async.c +0 -2
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +0 -2
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +3 -5
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +2 -3
- data/ext/noderb_extension/libuv/test/test-fs.c +578 -42
- data/ext/noderb_extension/libuv/test/test-get-currentexe.c +12 -2
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +10 -5
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +0 -2
- data/ext/noderb_extension/libuv/test/test-getsockname.c +92 -72
- data/ext/noderb_extension/libuv/test/test-idle.c +0 -3
- data/ext/noderb_extension/libuv/test/test-list.h +13 -0
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +0 -3
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +13 -19
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +0 -12
- data/ext/noderb_extension/libuv/test/test-ref.c +0 -7
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +3 -3
- data/ext/noderb_extension/libuv/test/test-spawn.c +2 -11
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +0 -19
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +0 -15
- data/ext/noderb_extension/libuv/test/test-tcp-close.c +129 -0
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +0 -3
- data/ext/noderb_extension/libuv/test/test-threadpool.c +0 -2
- data/ext/noderb_extension/libuv/test/test-timer-again.c +0 -3
- data/ext/noderb_extension/libuv/test/test-timer.c +0 -2
- data/ext/noderb_extension/libuv/test/test-udp-dgram-too-big.c +0 -2
- data/ext/noderb_extension/libuv/test/test-udp-ipv6.c +0 -2
- data/ext/noderb_extension/libuv/test/test-udp-send-and-recv.c +0 -2
- data/ext/noderb_extension/libuv/uv.gyp +18 -2
- data/ext/noderb_extension/noderb_fs.c +1 -2
- data/lib/noderb/version.rb +1 -1
- metadata +10 -2
|
@@ -43,7 +43,7 @@ typedef struct {
|
|
|
43
43
|
union {
|
|
44
44
|
uv_tcp_t tcp;
|
|
45
45
|
uv_pipe_t pipe;
|
|
46
|
-
};
|
|
46
|
+
} stream;
|
|
47
47
|
uv_connect_t connect_req;
|
|
48
48
|
char read_buffer[BUFSIZE];
|
|
49
49
|
} pinger_t;
|
|
@@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) {
|
|
|
85
85
|
|
|
86
86
|
req = malloc(sizeof(uv_write_t));
|
|
87
87
|
|
|
88
|
-
if (uv_write(req, (uv_stream_t*)&pinger->tcp, &buf, 1, pinger_after_write)) {
|
|
88
|
+
if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
|
|
89
89
|
FATAL("uv_write failed");
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -108,7 +108,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
|
|
|
108
108
|
free(buf.base);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
|
|
111
|
+
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
|
|
112
112
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
@@ -123,7 +123,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
|
|
|
123
123
|
if (pinger->pongs < NUM_PINGS) {
|
|
124
124
|
pinger_write_ping(pinger);
|
|
125
125
|
} else {
|
|
126
|
-
uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
|
|
126
|
+
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -155,13 +155,13 @@ static void tcp_pinger_v6_new() {
|
|
|
155
155
|
pinger->pongs = 0;
|
|
156
156
|
|
|
157
157
|
/* Try to connec to the server and do NUM_PINGS ping-pongs. */
|
|
158
|
-
r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
|
|
159
|
-
pinger->tcp.data = pinger;
|
|
158
|
+
r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
|
|
159
|
+
pinger->stream.tcp.data = pinger;
|
|
160
160
|
ASSERT(!r);
|
|
161
161
|
|
|
162
162
|
/* We are never doing multiple reads/connects at a time anyway. */
|
|
163
163
|
/* so these handles can be pre-initialized. */
|
|
164
|
-
r = uv_tcp_connect6(&pinger->connect_req, &pinger->tcp, server_addr,
|
|
164
|
+
r = uv_tcp_connect6(&pinger->connect_req, &pinger->stream.tcp, server_addr,
|
|
165
165
|
pinger_on_connect);
|
|
166
166
|
ASSERT(!r);
|
|
167
167
|
|
|
@@ -180,13 +180,13 @@ static void tcp_pinger_new() {
|
|
|
180
180
|
pinger->pongs = 0;
|
|
181
181
|
|
|
182
182
|
/* Try to connec to the server and do NUM_PINGS ping-pongs. */
|
|
183
|
-
r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
|
|
184
|
-
pinger->tcp.data = pinger;
|
|
183
|
+
r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
|
|
184
|
+
pinger->stream.tcp.data = pinger;
|
|
185
185
|
ASSERT(!r);
|
|
186
186
|
|
|
187
187
|
/* We are never doing multiple reads/connects at a time anyway. */
|
|
188
188
|
/* so these handles can be pre-initialized. */
|
|
189
|
-
r = uv_tcp_connect(&pinger->connect_req, &pinger->tcp, server_addr,
|
|
189
|
+
r = uv_tcp_connect(&pinger->connect_req, &pinger->stream.tcp, server_addr,
|
|
190
190
|
pinger_on_connect);
|
|
191
191
|
ASSERT(!r);
|
|
192
192
|
|
|
@@ -204,14 +204,14 @@ static void pipe_pinger_new() {
|
|
|
204
204
|
pinger->pongs = 0;
|
|
205
205
|
|
|
206
206
|
/* Try to connec to the server and do NUM_PINGS ping-pongs. */
|
|
207
|
-
r = uv_pipe_init(uv_default_loop(), &pinger->pipe);
|
|
208
|
-
pinger->pipe.data = pinger;
|
|
207
|
+
r = uv_pipe_init(uv_default_loop(), &pinger->stream.pipe);
|
|
208
|
+
pinger->stream.pipe.data = pinger;
|
|
209
209
|
ASSERT(!r);
|
|
210
210
|
|
|
211
211
|
/* We are never doing multiple reads/connects at a time anyway. */
|
|
212
212
|
/* so these handles can be pre-initialized. */
|
|
213
213
|
|
|
214
|
-
r = uv_pipe_connect(&pinger->connect_req, &pinger->pipe, TEST_PIPENAME,
|
|
214
|
+
r = uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
|
|
215
215
|
pinger_on_connect);
|
|
216
216
|
ASSERT(!r);
|
|
217
217
|
|
|
@@ -221,8 +221,6 @@ static void pipe_pinger_new() {
|
|
|
221
221
|
|
|
222
222
|
|
|
223
223
|
TEST_IMPL(tcp_ping_pong) {
|
|
224
|
-
uv_init();
|
|
225
|
-
|
|
226
224
|
tcp_pinger_new();
|
|
227
225
|
uv_run(uv_default_loop());
|
|
228
226
|
|
|
@@ -233,8 +231,6 @@ TEST_IMPL(tcp_ping_pong) {
|
|
|
233
231
|
|
|
234
232
|
|
|
235
233
|
TEST_IMPL(tcp_ping_pong_v6) {
|
|
236
|
-
uv_init();
|
|
237
|
-
|
|
238
234
|
tcp_pinger_v6_new();
|
|
239
235
|
uv_run(uv_default_loop());
|
|
240
236
|
|
|
@@ -245,8 +241,6 @@ TEST_IMPL(tcp_ping_pong_v6) {
|
|
|
245
241
|
|
|
246
242
|
|
|
247
243
|
TEST_IMPL(pipe_ping_pong) {
|
|
248
|
-
uv_init();
|
|
249
|
-
|
|
250
244
|
pipe_pinger_new();
|
|
251
245
|
uv_run(uv_default_loop());
|
|
252
246
|
|
|
@@ -45,9 +45,6 @@ TEST_IMPL(pipe_bind_error_addrinuse) {
|
|
|
45
45
|
uv_pipe_t server1, server2;
|
|
46
46
|
int r;
|
|
47
47
|
|
|
48
|
-
uv_init();
|
|
49
|
-
|
|
50
|
-
|
|
51
48
|
r = uv_pipe_init(uv_default_loop(), &server1);
|
|
52
49
|
ASSERT(r == 0);
|
|
53
50
|
r = uv_pipe_bind(&server1, TEST_PIPENAME);
|
|
@@ -82,9 +79,6 @@ TEST_IMPL(pipe_bind_error_addrnotavail) {
|
|
|
82
79
|
uv_pipe_t server;
|
|
83
80
|
int r;
|
|
84
81
|
|
|
85
|
-
uv_init();
|
|
86
|
-
|
|
87
|
-
|
|
88
82
|
r = uv_pipe_init(uv_default_loop(), &server);
|
|
89
83
|
ASSERT(r == 0);
|
|
90
84
|
r = uv_pipe_bind(&server, BAD_PIPENAME);
|
|
@@ -106,9 +100,6 @@ TEST_IMPL(pipe_bind_error_inval) {
|
|
|
106
100
|
uv_pipe_t server;
|
|
107
101
|
int r;
|
|
108
102
|
|
|
109
|
-
uv_init();
|
|
110
|
-
|
|
111
|
-
|
|
112
103
|
r = uv_pipe_init(uv_default_loop(), &server);
|
|
113
104
|
ASSERT(r == 0);
|
|
114
105
|
r = uv_pipe_bind(&server, TEST_PIPENAME);
|
|
@@ -132,9 +123,6 @@ TEST_IMPL(pipe_listen_without_bind) {
|
|
|
132
123
|
uv_pipe_t server;
|
|
133
124
|
int r;
|
|
134
125
|
|
|
135
|
-
uv_init();
|
|
136
|
-
|
|
137
|
-
|
|
138
126
|
r = uv_pipe_init(uv_default_loop(), &server);
|
|
139
127
|
ASSERT(r == 0);
|
|
140
128
|
r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL);
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
TEST_IMPL(ref) {
|
|
27
|
-
uv_init();
|
|
28
27
|
uv_run(uv_default_loop());
|
|
29
28
|
return 0;
|
|
30
29
|
}
|
|
@@ -32,7 +31,6 @@ TEST_IMPL(ref) {
|
|
|
32
31
|
|
|
33
32
|
TEST_IMPL(idle_ref) {
|
|
34
33
|
uv_idle_t h;
|
|
35
|
-
uv_init();
|
|
36
34
|
uv_idle_init(uv_default_loop(), &h);
|
|
37
35
|
uv_idle_start(&h, NULL);
|
|
38
36
|
uv_unref(uv_default_loop());
|
|
@@ -43,7 +41,6 @@ TEST_IMPL(idle_ref) {
|
|
|
43
41
|
|
|
44
42
|
TEST_IMPL(async_ref) {
|
|
45
43
|
uv_async_t h;
|
|
46
|
-
uv_init();
|
|
47
44
|
uv_async_init(uv_default_loop(), &h, NULL);
|
|
48
45
|
uv_unref(uv_default_loop());
|
|
49
46
|
uv_run(uv_default_loop());
|
|
@@ -53,7 +50,6 @@ TEST_IMPL(async_ref) {
|
|
|
53
50
|
|
|
54
51
|
TEST_IMPL(prepare_ref) {
|
|
55
52
|
uv_prepare_t h;
|
|
56
|
-
uv_init();
|
|
57
53
|
uv_prepare_init(uv_default_loop(), &h);
|
|
58
54
|
uv_prepare_start(&h, NULL);
|
|
59
55
|
uv_unref(uv_default_loop());
|
|
@@ -64,7 +60,6 @@ TEST_IMPL(prepare_ref) {
|
|
|
64
60
|
|
|
65
61
|
TEST_IMPL(check_ref) {
|
|
66
62
|
uv_check_t h;
|
|
67
|
-
uv_init();
|
|
68
63
|
uv_check_init(uv_default_loop(), &h);
|
|
69
64
|
uv_check_start(&h, NULL);
|
|
70
65
|
uv_unref(uv_default_loop());
|
|
@@ -83,8 +78,6 @@ static void prepare_cb(uv_prepare_t* handle, int status) {
|
|
|
83
78
|
|
|
84
79
|
TEST_IMPL(unref_in_prepare_cb) {
|
|
85
80
|
uv_prepare_t h;
|
|
86
|
-
uv_init();
|
|
87
|
-
|
|
88
81
|
uv_prepare_init(uv_default_loop(), &h);
|
|
89
82
|
uv_prepare_start(&h, prepare_cb);
|
|
90
83
|
uv_run(uv_default_loop());
|
|
@@ -153,12 +153,12 @@ TEST_IMPL(shutdown_eof) {
|
|
|
153
153
|
struct sockaddr_in server_addr;
|
|
154
154
|
int r;
|
|
155
155
|
|
|
156
|
-
uv_init();
|
|
157
|
-
|
|
158
156
|
qbuf.base = "Q";
|
|
159
157
|
qbuf.len = 1;
|
|
160
158
|
|
|
161
|
-
uv_timer_init(uv_default_loop(), &timer);
|
|
159
|
+
r = uv_timer_init(uv_default_loop(), &timer);
|
|
160
|
+
ASSERT(r == 0);
|
|
161
|
+
|
|
162
162
|
uv_timer_start(&timer, timer_cb, 100, 0);
|
|
163
163
|
|
|
164
164
|
server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
|
|
@@ -23,12 +23,13 @@
|
|
|
23
23
|
#include "task.h"
|
|
24
24
|
#include <stdio.h>
|
|
25
25
|
#include <stdlib.h>
|
|
26
|
+
#include <string.h>
|
|
26
27
|
|
|
27
28
|
static int close_cb_called;
|
|
28
29
|
static int exit_cb_called;
|
|
29
30
|
static uv_process_t process;
|
|
30
31
|
static uv_timer_t timer;
|
|
31
|
-
static uv_process_options_t options
|
|
32
|
+
static uv_process_options_t options;
|
|
32
33
|
static char exepath[1024];
|
|
33
34
|
static size_t exepath_size = 1024;
|
|
34
35
|
static char* args[3];
|
|
@@ -116,8 +117,6 @@ static void timer_cb(uv_timer_t* handle, int status) {
|
|
|
116
117
|
TEST_IMPL(spawn_exit_code) {
|
|
117
118
|
int r;
|
|
118
119
|
|
|
119
|
-
uv_init();
|
|
120
|
-
|
|
121
120
|
init_process_options("spawn_helper1", exit_cb);
|
|
122
121
|
|
|
123
122
|
r = uv_spawn(uv_default_loop(), &process, options);
|
|
@@ -137,8 +136,6 @@ TEST_IMPL(spawn_stdout) {
|
|
|
137
136
|
int r;
|
|
138
137
|
uv_pipe_t out;
|
|
139
138
|
|
|
140
|
-
uv_init();
|
|
141
|
-
|
|
142
139
|
init_process_options("spawn_helper2", exit_cb);
|
|
143
140
|
|
|
144
141
|
uv_pipe_init(uv_default_loop(), &out);
|
|
@@ -170,8 +167,6 @@ int r;
|
|
|
170
167
|
uv_buf_t buf;
|
|
171
168
|
char buffer[] = "hello-from-spawn_stdin";
|
|
172
169
|
|
|
173
|
-
uv_init();
|
|
174
|
-
|
|
175
170
|
init_process_options("spawn_helper3", exit_cb);
|
|
176
171
|
|
|
177
172
|
uv_pipe_init(uv_default_loop(), &out);
|
|
@@ -204,8 +199,6 @@ int r;
|
|
|
204
199
|
TEST_IMPL(spawn_and_kill) {
|
|
205
200
|
int r;
|
|
206
201
|
|
|
207
|
-
uv_init();
|
|
208
|
-
|
|
209
202
|
init_process_options("spawn_helper4", kill_cb);
|
|
210
203
|
|
|
211
204
|
r = uv_spawn(uv_default_loop(), &process, options);
|
|
@@ -234,8 +227,6 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
|
|
|
234
227
|
char name[64];
|
|
235
228
|
HANDLE pipe_handle;
|
|
236
229
|
|
|
237
|
-
uv_init();
|
|
238
|
-
|
|
239
230
|
init_process_options("spawn_helper2", exit_cb);
|
|
240
231
|
|
|
241
232
|
uv_pipe_init(uv_default_loop(), &out);
|
|
@@ -39,9 +39,6 @@ TEST_IMPL(tcp_bind_error_addrinuse) {
|
|
|
39
39
|
uv_tcp_t server1, server2;
|
|
40
40
|
int r;
|
|
41
41
|
|
|
42
|
-
uv_init();
|
|
43
|
-
|
|
44
|
-
|
|
45
42
|
r = uv_tcp_init(uv_default_loop(), &server1);
|
|
46
43
|
ASSERT(r == 0);
|
|
47
44
|
r = uv_tcp_bind(&server1, addr);
|
|
@@ -75,9 +72,6 @@ TEST_IMPL(tcp_bind_error_addrnotavail_1) {
|
|
|
75
72
|
uv_tcp_t server;
|
|
76
73
|
int r;
|
|
77
74
|
|
|
78
|
-
uv_init();
|
|
79
|
-
|
|
80
|
-
|
|
81
75
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
82
76
|
ASSERT(r == 0);
|
|
83
77
|
r = uv_tcp_bind(&server, addr);
|
|
@@ -102,8 +96,6 @@ TEST_IMPL(tcp_bind_error_addrnotavail_2) {
|
|
|
102
96
|
uv_tcp_t server;
|
|
103
97
|
int r;
|
|
104
98
|
|
|
105
|
-
uv_init();
|
|
106
|
-
|
|
107
99
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
108
100
|
ASSERT(r == 0);
|
|
109
101
|
r = uv_tcp_bind(&server, addr);
|
|
@@ -128,9 +120,6 @@ TEST_IMPL(tcp_bind_error_fault) {
|
|
|
128
120
|
|
|
129
121
|
garbage_addr = (struct sockaddr_in*) &garbage;
|
|
130
122
|
|
|
131
|
-
uv_init();
|
|
132
|
-
|
|
133
|
-
|
|
134
123
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
135
124
|
ASSERT(r == 0);
|
|
136
125
|
r = uv_tcp_bind(&server, *garbage_addr);
|
|
@@ -155,9 +144,6 @@ TEST_IMPL(tcp_bind_error_inval) {
|
|
|
155
144
|
uv_tcp_t server;
|
|
156
145
|
int r;
|
|
157
146
|
|
|
158
|
-
uv_init();
|
|
159
|
-
|
|
160
|
-
|
|
161
147
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
162
148
|
ASSERT(r == 0);
|
|
163
149
|
r = uv_tcp_bind(&server, addr1);
|
|
@@ -183,9 +169,6 @@ TEST_IMPL(tcp_bind_localhost_ok) {
|
|
|
183
169
|
uv_tcp_t server;
|
|
184
170
|
int r;
|
|
185
171
|
|
|
186
|
-
uv_init();
|
|
187
|
-
|
|
188
|
-
|
|
189
172
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
190
173
|
ASSERT(r == 0);
|
|
191
174
|
r = uv_tcp_bind(&server, addr);
|
|
@@ -199,8 +182,6 @@ TEST_IMPL(tcp_listen_without_bind) {
|
|
|
199
182
|
int r;
|
|
200
183
|
uv_tcp_t server;
|
|
201
184
|
|
|
202
|
-
uv_init();
|
|
203
|
-
|
|
204
185
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
205
186
|
ASSERT(r == 0);
|
|
206
187
|
r = uv_listen((uv_stream_t*)&server, 128, NULL);
|
|
@@ -39,9 +39,6 @@ TEST_IMPL(tcp_bind6_error_addrinuse) {
|
|
|
39
39
|
uv_tcp_t server1, server2;
|
|
40
40
|
int r;
|
|
41
41
|
|
|
42
|
-
uv_init();
|
|
43
|
-
|
|
44
|
-
|
|
45
42
|
r = uv_tcp_init(uv_default_loop(), &server1);
|
|
46
43
|
ASSERT(r == 0);
|
|
47
44
|
r = uv_tcp_bind6(&server1, addr);
|
|
@@ -75,9 +72,6 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) {
|
|
|
75
72
|
uv_tcp_t server;
|
|
76
73
|
int r;
|
|
77
74
|
|
|
78
|
-
uv_init();
|
|
79
|
-
|
|
80
|
-
|
|
81
75
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
82
76
|
ASSERT(r == 0);
|
|
83
77
|
r = uv_tcp_bind6(&server, addr);
|
|
@@ -102,9 +96,6 @@ TEST_IMPL(tcp_bind6_error_fault) {
|
|
|
102
96
|
|
|
103
97
|
garbage_addr = (struct sockaddr_in6*) &garbage;
|
|
104
98
|
|
|
105
|
-
uv_init();
|
|
106
|
-
|
|
107
|
-
|
|
108
99
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
109
100
|
ASSERT(r == 0);
|
|
110
101
|
r = uv_tcp_bind6(&server, *garbage_addr);
|
|
@@ -129,9 +120,6 @@ TEST_IMPL(tcp_bind6_error_inval) {
|
|
|
129
120
|
uv_tcp_t server;
|
|
130
121
|
int r;
|
|
131
122
|
|
|
132
|
-
uv_init();
|
|
133
|
-
|
|
134
|
-
|
|
135
123
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
136
124
|
ASSERT(r == 0);
|
|
137
125
|
r = uv_tcp_bind6(&server, addr1);
|
|
@@ -157,9 +145,6 @@ TEST_IMPL(tcp_bind6_localhost_ok) {
|
|
|
157
145
|
uv_tcp_t server;
|
|
158
146
|
int r;
|
|
159
147
|
|
|
160
|
-
uv_init();
|
|
161
|
-
|
|
162
|
-
|
|
163
148
|
r = uv_tcp_init(uv_default_loop(), &server);
|
|
164
149
|
ASSERT(r == 0);
|
|
165
150
|
r = uv_tcp_bind6(&server, addr);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "uv.h"
|
|
23
|
+
#include "task.h"
|
|
24
|
+
|
|
25
|
+
#include <errno.h>
|
|
26
|
+
#include <string.h> /* memset */
|
|
27
|
+
|
|
28
|
+
#define NUM_WRITE_REQS 32
|
|
29
|
+
|
|
30
|
+
static uv_tcp_t tcp_handle;
|
|
31
|
+
static uv_connect_t connect_req;
|
|
32
|
+
|
|
33
|
+
static int write_cb_called;
|
|
34
|
+
static int close_cb_called;
|
|
35
|
+
|
|
36
|
+
static void connect_cb(uv_connect_t* req, int status);
|
|
37
|
+
static void write_cb(uv_write_t* req, int status);
|
|
38
|
+
static void close_cb(uv_handle_t* handle);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
static void connect_cb(uv_connect_t* conn_req, int status) {
|
|
42
|
+
uv_write_t* req;
|
|
43
|
+
uv_buf_t buf;
|
|
44
|
+
int i, r;
|
|
45
|
+
|
|
46
|
+
buf = uv_buf_init("PING", 4);
|
|
47
|
+
for (i = 0; i < NUM_WRITE_REQS; i++) {
|
|
48
|
+
req = malloc(sizeof *req);
|
|
49
|
+
ASSERT(req != NULL);
|
|
50
|
+
|
|
51
|
+
r = uv_write(req, (uv_stream_t*)&tcp_handle, &buf, 1, write_cb);
|
|
52
|
+
ASSERT(r == 0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
uv_close((uv_handle_t*)&tcp_handle, close_cb);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
static void write_cb(uv_write_t* req, int status) {
|
|
60
|
+
/* write callbacks should run before the close callback */
|
|
61
|
+
ASSERT(close_cb_called == 0);
|
|
62
|
+
ASSERT(req->handle == (uv_stream_t*)&tcp_handle);
|
|
63
|
+
write_cb_called++;
|
|
64
|
+
free(req);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
static void close_cb(uv_handle_t* handle) {
|
|
69
|
+
ASSERT(handle == (uv_handle_t*)&tcp_handle);
|
|
70
|
+
close_cb_called++;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
static void connection_cb(uv_stream_t* server, int status) {
|
|
75
|
+
ASSERT(status == 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
static void start_server(uv_loop_t* loop, uv_tcp_t* handle) {
|
|
80
|
+
int r;
|
|
81
|
+
|
|
82
|
+
r = uv_tcp_init(loop, handle);
|
|
83
|
+
ASSERT(r == 0);
|
|
84
|
+
|
|
85
|
+
r = uv_tcp_bind(handle, uv_ip4_addr("127.0.0.1", TEST_PORT));
|
|
86
|
+
ASSERT(r == 0);
|
|
87
|
+
|
|
88
|
+
r = uv_listen((uv_stream_t*)handle, 128, connection_cb);
|
|
89
|
+
ASSERT(r == 0);
|
|
90
|
+
|
|
91
|
+
uv_unref(loop);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/* Check that pending write requests have their callbacks
|
|
96
|
+
* invoked when the handle is closed.
|
|
97
|
+
*/
|
|
98
|
+
TEST_IMPL(tcp_close) {
|
|
99
|
+
uv_loop_t* loop;
|
|
100
|
+
uv_tcp_t tcp_server;
|
|
101
|
+
int r;
|
|
102
|
+
|
|
103
|
+
loop = uv_default_loop();
|
|
104
|
+
|
|
105
|
+
/* We can't use the echo server, it doesn't handle ECONNRESET. */
|
|
106
|
+
start_server(loop, &tcp_server);
|
|
107
|
+
|
|
108
|
+
r = uv_tcp_init(loop, &tcp_handle);
|
|
109
|
+
ASSERT(r == 0);
|
|
110
|
+
|
|
111
|
+
r = uv_tcp_connect(&connect_req,
|
|
112
|
+
&tcp_handle,
|
|
113
|
+
uv_ip4_addr("127.0.0.1", TEST_PORT),
|
|
114
|
+
connect_cb);
|
|
115
|
+
ASSERT(r == 0);
|
|
116
|
+
|
|
117
|
+
ASSERT(write_cb_called == 0);
|
|
118
|
+
ASSERT(close_cb_called == 0);
|
|
119
|
+
|
|
120
|
+
r = uv_run(loop);
|
|
121
|
+
ASSERT(r == 0);
|
|
122
|
+
|
|
123
|
+
printf("%d of %d write reqs seen\n", write_cb_called, NUM_WRITE_REQS);
|
|
124
|
+
|
|
125
|
+
ASSERT(write_cb_called == NUM_WRITE_REQS);
|
|
126
|
+
ASSERT(close_cb_called == 1);
|
|
127
|
+
|
|
128
|
+
return 0;
|
|
129
|
+
}
|