noderb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/README.md +157 -7
  2. data/ext/noderb_extension/extconf.rb +1 -3
  3. data/ext/noderb_extension/libuv/BSDmakefile +2 -0
  4. data/ext/noderb_extension/libuv/all.gyp +326 -0
  5. data/ext/noderb_extension/libuv/config-mingw.mk +0 -1
  6. data/ext/noderb_extension/libuv/config-unix.mk +7 -1
  7. data/ext/noderb_extension/libuv/create-msvs-files.bat +13 -6
  8. data/ext/noderb_extension/libuv/{build/gyp_uv → gyp_uv} +1 -2
  9. data/ext/noderb_extension/libuv/include/uv.h +5 -0
  10. data/ext/noderb_extension/libuv/src/eio/config_cygwin.h +3 -0
  11. data/ext/noderb_extension/libuv/src/eio/config_freebsd.h +3 -0
  12. data/ext/noderb_extension/libuv/src/eio/config_sunos.h +3 -0
  13. data/ext/noderb_extension/libuv/src/eio/ecb.h +1 -1
  14. data/ext/noderb_extension/libuv/src/eio/eio.c +8 -1
  15. data/ext/noderb_extension/libuv/src/uv-common.c +1 -0
  16. data/ext/noderb_extension/libuv/src/uv-sunos.c +1 -1
  17. data/ext/noderb_extension/libuv/src/uv-unix.c +72 -59
  18. data/ext/noderb_extension/libuv/src/win/core.c +3 -0
  19. data/ext/noderb_extension/libuv/src/win/internal.h +11 -0
  20. data/ext/noderb_extension/libuv/src/win/ntdll.h +130 -0
  21. data/ext/noderb_extension/libuv/src/win/pipe.c +105 -27
  22. data/ext/noderb_extension/libuv/src/win/process.c +76 -5
  23. data/ext/noderb_extension/libuv/src/win/req.c +7 -0
  24. data/ext/noderb_extension/libuv/src/win/winapi.c +52 -0
  25. data/ext/noderb_extension/libuv/test/benchmark-pound.c +50 -48
  26. data/ext/noderb_extension/libuv/test/echo-server.c +2 -2
  27. data/ext/noderb_extension/libuv/test/test-list.h +2 -0
  28. data/ext/noderb_extension/libuv/test/test-spawn.c +48 -1
  29. data/ext/noderb_extension/noderb.c +38 -339
  30. data/ext/noderb_extension/noderb.h +18 -2
  31. data/ext/noderb_extension/noderb_common.h +13 -0
  32. data/ext/noderb_extension/noderb_dns.c +37 -0
  33. data/ext/noderb_extension/noderb_dns.h +15 -0
  34. data/ext/noderb_extension/noderb_process.c +126 -0
  35. data/ext/noderb_extension/noderb_process.h +17 -0
  36. data/ext/noderb_extension/noderb_tcp.c +127 -0
  37. data/ext/noderb_extension/noderb_tcp.h +19 -0
  38. data/ext/noderb_extension/noderb_timers.c +58 -0
  39. data/ext/noderb_extension/noderb_timers.h +16 -0
  40. data/ext/noderb_extension/noderb_tools.c +127 -0
  41. data/ext/noderb_extension/noderb_tools.h +33 -0
  42. data/lib/noderb/dns.rb +11 -0
  43. data/lib/noderb/next_tick.rb +2 -1
  44. data/lib/noderb/tcp.rb +27 -0
  45. data/lib/noderb/timers.rb +24 -0
  46. data/lib/noderb/version.rb +1 -1
  47. data/lib/noderb.rb +6 -1
  48. metadata +23 -7
  49. data/ext/noderb_extension/libuv/build/all.gyp +0 -254
  50. data/ext/noderb_extension/libuv/doc/desired-api.md +0 -159
  51. /data/ext/noderb_extension/libuv/{build/common.gypi → common.gypi} +0 -0
@@ -1,254 +0,0 @@
1
- {
2
- 'target_defaults': {
3
- 'default_configuration': 'Debug',
4
- 'configurations': {
5
- # TODO: hoist these out and put them somewhere common, because
6
- # RuntimeLibrary MUST MATCH across the entire project
7
- 'Debug': {
8
- 'defines': [ 'DEBUG', '_DEBUG' ],
9
- 'msvs_settings': {
10
- 'VCCLCompilerTool': {
11
- 'RuntimeLibrary': 1, # static debug
12
- },
13
- },
14
- },
15
- 'Release': {
16
- 'defines': [ 'NDEBUG' ],
17
- 'msvs_settings': {
18
- 'VCCLCompilerTool': {
19
- 'RuntimeLibrary': 0, # static release
20
- },
21
- },
22
- }
23
- },
24
- 'msvs_settings': {
25
- 'VCCLCompilerTool': {
26
- },
27
- 'VCLibrarianTool': {
28
- },
29
- 'VCLinkerTool': {
30
- 'GenerateDebugInformation': 'true',
31
- },
32
- },
33
- 'conditions': [
34
- ['OS == "win"', {
35
- 'defines': [
36
- 'WIN32'
37
- ],
38
- }]
39
- ],
40
- },
41
-
42
- 'targets': [
43
- {
44
- 'target_name': 'uv',
45
- 'type': 'static_library',
46
- 'include_dirs': [ '../include' ],
47
- 'direct_dependent_settings': {
48
- 'include_dirs': [ '../include' ],
49
- },
50
-
51
- 'defines': [
52
- 'HAVE_CONFIG_H'
53
- ],
54
- 'sources': [
55
- '../src/uv-common.c',
56
- '../src/ares/ares__close_sockets.c',
57
- '../src/ares/ares__get_hostent.c',
58
- '../src/ares/ares__read_line.c',
59
- '../src/ares/ares__timeval.c',
60
- '../src/ares/ares_cancel.c',
61
- '../src/ares/ares_data.c',
62
- '../src/ares/ares_destroy.c',
63
- '../src/ares/ares_expand_name.c',
64
- '../src/ares/ares_expand_string.c',
65
- '../src/ares/ares_fds.c',
66
- '../src/ares/ares_free_hostent.c',
67
- '../src/ares/ares_free_string.c',
68
- '../src/ares/ares_gethostbyaddr.c',
69
- '../src/ares/ares_gethostbyname.c',
70
- '../src/ares/ares_getnameinfo.c',
71
- '../src/ares/ares_getopt.c',
72
- '../src/ares/ares_getsock.c',
73
- '../src/ares/ares_init.c',
74
- '../src/ares/ares_library_init.c',
75
- '../src/ares/ares_llist.c',
76
- '../src/ares/ares_mkquery.c',
77
- '../src/ares/ares_nowarn.c',
78
- '../src/ares/ares_options.c',
79
- '../src/ares/ares_parse_a_reply.c',
80
- '../src/ares/ares_parse_aaaa_reply.c',
81
- '../src/ares/ares_parse_mx_reply.c',
82
- '../src/ares/ares_parse_ns_reply.c',
83
- '../src/ares/ares_parse_ptr_reply.c',
84
- '../src/ares/ares_parse_srv_reply.c',
85
- '../src/ares/ares_parse_txt_reply.c',
86
- '../src/ares/ares_process.c',
87
- '../src/ares/ares_query.c',
88
- '../src/ares/ares_search.c',
89
- '../src/ares/ares_send.c',
90
- '../src/ares/ares_strcasecmp.c',
91
- '../src/ares/ares_strdup.c',
92
- '../src/ares/ares_strerror.c',
93
- '../src/ares/ares_timeout.c',
94
- '../src/ares/ares_version.c',
95
- '../src/ares/ares_writev.c',
96
- '../src/ares/bitncmp.c',
97
- '../src/ares/inet_net_pton.c',
98
- '../src/ares/inet_ntop.c',
99
- ],
100
- 'conditions': [
101
- [ 'OS=="win"', {
102
- 'include_dirs': [
103
- '../src/ares/config_win32'
104
- ],
105
- 'sources': [ '../src/ares/windows_port.c' ],
106
- 'defines': [
107
- '_WIN32_WINNT=0x0502',
108
- 'EIO_STACKSIZE=262144',
109
- '_GNU_SOURCE',
110
- ],
111
- 'sources': [
112
- '../src/win/async.c',
113
- '../src/win/cares.c',
114
- '../src/win/core.c',
115
- '../src/win/error.c',
116
- '../src/win/getaddrinfo.c',
117
- '../src/win/handle.c',
118
- '../src/win/loop-watcher.c',
119
- '../src/win/pipe.c',
120
- '../src/win/process.c',
121
- '../src/win/req.c',
122
- '../src/win/stdio.c',
123
- '../src/win/stream.c',
124
- '../src/win/tcp.c',
125
- '../src/win/timer.c',
126
- '../src/win/util.c',
127
- ]
128
- }, { # Not Windows i.e. POSIX
129
- 'cflags': [
130
- '-g',
131
- '--std=gnu89',
132
- '-pedantic',
133
- '-Wall',
134
- '-Wextra',
135
- '-Wno-unused-parameter'
136
- ],
137
- 'sources': [
138
- '../src/uv-eio.c',
139
- '../src/eio/eio.c',
140
- '../src/uv-unix.c',
141
- '../src/ev/ev.c',
142
- ],
143
- 'include_dirs': [
144
- '../src/ev'
145
- ],
146
- 'defines': [
147
- '_LARGEFILE_SOURCE',
148
- '_FILE_OFFSET_BITS=64',
149
- '_GNU_SOURCE',
150
- 'EIO_STACKSIZE=262144'
151
- ],
152
- 'libraries': [ '-lm' ]
153
- }],
154
- [ 'OS=="mac"', {
155
- 'include_dirs': [ '../src/ares/config_darwin' ],
156
- 'sources': [ '../src/uv-darwin.c' ],
157
- 'direct_dependent_settings': {
158
- 'libraries': [ '-framework CoreServices' ],
159
- },
160
- 'defines': [
161
- 'EV_CONFIG_H="config_darwin.h"',
162
- 'EIO_CONFIG_H="config_darwin.h"',
163
- ]
164
- }],
165
- [ 'OS=="linux"', {
166
- 'include_dirs': [ '../src/ares/config_linux' ],
167
- 'sources': [ '../src/uv-linux.c' ],
168
- 'defines': [
169
- 'EV_CONFIG_H="config_linux.h"',
170
- 'EIO_CONFIG_H="config_linux.h"',
171
- ],
172
- 'direct_dependent_settings': {
173
- 'libraries': [ '-lrt' ],
174
- },
175
- }],
176
- # TODO add OS=='sun'
177
- ]
178
- },
179
-
180
- {
181
- 'target_name': 'run-tests',
182
- 'type': 'executable',
183
- 'dependencies': [ 'uv' ],
184
- 'sources': [
185
- '../test/runner.c',
186
- '../test/run-tests.c',
187
- '../test/test-async.c',
188
- '../test/echo-server.c',
189
- '../test/test-callback-stack.c',
190
- '../test/test-connection-fail.c',
191
- '../test/test-delayed-accept.c',
192
- '../test/test-fail-always.c',
193
- '../test/test-get-currentexe.c',
194
- '../test/test-getaddrinfo.c',
195
- '../test/test-gethostbyname.c',
196
- '../test/test-getsockname.c',
197
- '../test/test-hrtime.c',
198
- '../test/test-idle.c',
199
- '../test/test-loop-handles.c',
200
- '../test/test-pass-always.c',
201
- '../test/test-ping-pong.c',
202
- '../test/test-pipe-bind-error.c',
203
- '../test/test-ref.c',
204
- '../test/test-shutdown-eof.c',
205
- '../test/test-spawn.c',
206
- '../test/test-tcp-bind-error.c',
207
- '../test/test-tcp-bind6-error.c',
208
- '../test/test-tcp-writealot.c',
209
- '../test/test-timer-again.c',
210
- '../test/test-timer.c',
211
- ],
212
- 'conditions': [
213
- [ 'OS=="win"', {
214
- 'sources': [ '../test/runner-win.c' ],
215
- 'libraries': [ 'ws2_32.lib' ]
216
- }, { # POSIX
217
- 'defines': [ '_GNU_SOURCE' ],
218
- 'ldflags': [ '-pthread' ],
219
- 'sources': [ '../test/runner-unix.c' ]
220
- }]
221
- ]
222
- },
223
-
224
- {
225
- 'target_name': 'run-benchmarks',
226
- 'type': 'executable',
227
- 'dependencies': [ 'uv' ],
228
- 'sources': [
229
- '../test/runner.c',
230
- '../test/run-benchmarks.c',
231
- '../test/echo-server.c',
232
- '../test/dns-server.c',
233
- '../test/benchmark-ares.c',
234
- '../test/benchmark-getaddrinfo.c',
235
- '../test/benchmark-ping-pongs.c',
236
- '../test/benchmark-pound.c',
237
- '../test/benchmark-pump.c',
238
- '../test/benchmark-sizes.c',
239
- '../test/benchmark-spawn.c'
240
- ],
241
- 'conditions': [
242
- [ 'OS=="win"', {
243
- 'sources': [ '../test/runner-win.c' ],
244
- 'libraries': [ 'ws2_32.lib' ]
245
- }, { # POSIX
246
- 'defines': [ '_GNU_SOURCE' ],
247
- 'ldflags': [ '-pthread' ],
248
- 'sources': [ '../test/runner-unix.c' ]
249
- }]
250
- ]
251
- }
252
- ]
253
- }
254
-
@@ -1,159 +0,0 @@
1
- Warning: this is not actual API but desired API.
2
-
3
- # `uv_handle_t`
4
-
5
- This is the abstract base class of all types of handles. All handles have in
6
- common:
7
-
8
- * When handles are initialized, the reference count to the event loop is
9
- increased by one.
10
-
11
- * The user owns the `uv_handle_t` memory and is in charge of freeing it.
12
-
13
- * In order to free resources associated with a handle, one must `uv_close()`
14
- and wait for the `uv_close_cb` callback. After the close callback has been
15
- made, the user is allowed to the `uv_handle_t` object.
16
-
17
- * The `uv_close_cb` is always made directly off the event loop. That is, it
18
- is not called from `uv_close()`.
19
-
20
-
21
-
22
- # `uv_tcp_server_t`
23
-
24
- A TCP server class that is a subclass of `uv_handle_t`. This can be bound to
25
- an address and begin accepting new TCP sockets.
26
-
27
- int uv_bind4(uv_tcp_server_t* tcp_server, struct sockaddr_in* address);
28
- int uv_bind6(uv_tcp_server_t* tcp_server, struct sockaddr_in6* address);
29
-
30
- Binds the TCP server to an address. The `address` can be created with
31
- `uv_ip4_addr()`. Call this before `uv_listen()`
32
-
33
- Returns zero on success, -1 on failure. Errors in order of least-seriousness:
34
-
35
- * `UV_EADDRINUSE` There is already another socket bound to the specified
36
- address.
37
-
38
- * `UV_EADDRNOTAVAIL` The `address` parameter is an IP address that is not
39
-
40
- * `UV_EINVAL` The server is already bound to an address.
41
-
42
- * `UV_EFAULT` Memory of `address` parameter is unintelligible.
43
-
44
-
45
- int uv_listen(uv_tcp_server_t*, int backlog, uv_connection_cb cb);
46
-
47
- Begins listening for connections. The accept callback is level-triggered.
48
-
49
-
50
- int uv_accept(uv_tcp_server_t* server,
51
- uv_tcp_t* client);
52
-
53
- Accepts a connection. This should be called after the accept callback is
54
- made. The `client` parameter should be uninitialized memory; `uv_accept` is
55
- used instead of `uv_tcp_init` for server-side `uv_tcp_t` initialization.
56
-
57
- Return value 0 indicates success, -1 failure. Possible errors:
58
-
59
- * `UV_EAGAIN` There are no connections. Wait for the `uv_connection_cb` callback
60
- to be called again.
61
-
62
- * `UV_EFAULT` The memory of either `server` is unintelligible.
63
-
64
-
65
-
66
- # `uv_stream_t`
67
-
68
- An abstract subclass of `uv_handle_t`. Streams represent something that
69
- reads and/or writes data. Streams can be half or full-duplex. TCP sockets
70
- are streams, files are streams with offsets.
71
-
72
- int uv_read_start(uv_stream_t* stream,
73
- uv_alloc_cb alloc_cb,
74
- uv_read_cb read_cb);
75
-
76
- Starts the stream reading continuously. The `alloc_cb` is used to allow the
77
- user to implement various means of supplying the stream with buffers to
78
- fill. The `read_cb` returns buffers to the user filled with data.
79
-
80
- Sometimes the buffers returned to the user do not contain data. This does
81
- not indicate EOF as in other systems. EOF is made via the `uv_eof_cb` which
82
- can be set like this `uv_set_eof_cb(stream, eof_cb);`
83
-
84
-
85
- int uv_read_stop(uv_stream_t* stream);
86
-
87
- Stops reading from the stream.
88
-
89
- int uv_write_req_init(uv_write_req_t*,
90
- uv_stream_t*,
91
- uv_buf_t bufs[],
92
- int butcnf);
93
-
94
- Initiates a write request on a stream.
95
-
96
- int uv_shutdown_req_init(uv_shutdown_req_t*, uv_stream_t*)
97
-
98
- Initiates a shutdown of outgoing data once the write queue drains.
99
-
100
-
101
-
102
- # `uv_tcp_t`
103
-
104
- The TCP handle class represents one endpoint of a duplex TCP stream.
105
- `uv_tcp_t` is a subclass of `uv_stream_t`. A TCP handle can represent a
106
- client side connection (one that has been used with uv_connect_req_init`)
107
- or a server-side connection (one that was initialized with `uv_accept`)
108
-
109
- int uv_connect_req_init(uv_connect_req_t* req,
110
- uv_tcp_t* socket,
111
- struct sockaddr* addr);
112
-
113
- Initiates a request to open a connection.
114
-
115
-
116
-
117
- # `uv_req_t`
118
-
119
- Abstract class represents an asynchronous request. This is a subclass of `uv_handle_t`.
120
-
121
-
122
- # `uv_connect_req_t`
123
-
124
- Subclass of `uv_req_t`. Represents a request for a TCP connection. Operates
125
- on `uv_tcp_t` handles. Like other types of requests the `close_cb` indicates
126
- completion of the request.
127
-
128
- int uv_connect_req_init(uv_connect_req_t* req,
129
- uv_tcp_t* socket,
130
- struct sockaddr* addr);
131
-
132
- Initializes the connection request. Returning 0 indicates success, -1 if
133
- there was an error. The following values can be retrieved from
134
- `uv_last_error` in the case of an error:
135
-
136
- * ???
137
-
138
-
139
- # `uv_shutdown_req_t`
140
-
141
- Subclass of `uv_req_t`. Represents an ongoing shutdown request. Once the
142
- write queue of the parent `uv_stream_t` is drained, the outbound data
143
- channel is shutdown. Once a shutdown request is initiated on a stream, the
144
- stream will allow no more writes.
145
-
146
- int uv_shutdown_req_init(uv_shutdown_req_t*,
147
- uv_stream_t* parent);
148
-
149
- Initializes the shutdown request.
150
-
151
-
152
- # `uv_write_req_t`
153
-
154
- int uv_write_req_init(uv_write_req_t*,
155
- uv_stream_t*,
156
- uv_buf_t bufs[],
157
- int butcnf);
158
-
159
- Initiates a write request on a stream.