asyncengine 0.0.1.testing1 → 0.0.2.alpha1
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/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
|
@@ -49,7 +49,7 @@ extern "C" {
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
#define UV_VERSION_MAJOR 0
|
|
52
|
-
#define UV_VERSION_MINOR
|
|
52
|
+
#define UV_VERSION_MINOR 9
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
#include <stdint.h> /* int64_t */
|
|
@@ -57,8 +57,10 @@ extern "C" {
|
|
|
57
57
|
|
|
58
58
|
#include "ares.h"
|
|
59
59
|
|
|
60
|
-
#
|
|
61
|
-
typedef intptr_t ssize_t;
|
|
60
|
+
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
|
|
61
|
+
typedef intptr_t ssize_t;
|
|
62
|
+
# define _SSIZE_T_
|
|
63
|
+
# define _SSIZE_T_DEFINED
|
|
62
64
|
#endif
|
|
63
65
|
|
|
64
66
|
#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
|
|
@@ -123,7 +125,8 @@ typedef intptr_t ssize_t;
|
|
|
123
125
|
XX( 52, EXDEV, "cross-device link not permitted") \
|
|
124
126
|
XX( 53, ENOTEMPTY, "directory not empty") \
|
|
125
127
|
XX( 54, ENOSPC, "no space left on device") \
|
|
126
|
-
XX( 55, EIO, "i/o error")
|
|
128
|
+
XX( 55, EIO, "i/o error") \
|
|
129
|
+
XX( 56, EROFS, "read-only file system" )
|
|
127
130
|
|
|
128
131
|
|
|
129
132
|
#define UV_ERRNO_GEN(val, name, s) UV_##name = val,
|
|
@@ -134,12 +137,13 @@ typedef enum {
|
|
|
134
137
|
#undef UV_ERRNO_GEN
|
|
135
138
|
|
|
136
139
|
#define UV_HANDLE_TYPE_MAP(XX) \
|
|
137
|
-
XX(ARES_TASK, ares_task) \
|
|
138
140
|
XX(ASYNC, async) \
|
|
139
141
|
XX(CHECK, check) \
|
|
140
142
|
XX(FS_EVENT, fs_event) \
|
|
143
|
+
XX(FS_POLL, fs_poll) \
|
|
141
144
|
XX(IDLE, idle) \
|
|
142
145
|
XX(NAMED_PIPE, pipe) \
|
|
146
|
+
XX(POLL, poll) \
|
|
143
147
|
XX(PREPARE, prepare) \
|
|
144
148
|
XX(PROCESS, process) \
|
|
145
149
|
XX(TCP, tcp) \
|
|
@@ -161,8 +165,8 @@ typedef enum {
|
|
|
161
165
|
#define XX(uc, lc) UV_##uc,
|
|
162
166
|
UV_HANDLE_TYPE_MAP(XX)
|
|
163
167
|
#undef XX
|
|
168
|
+
UV_ARES_TASK,
|
|
164
169
|
UV_FILE,
|
|
165
|
-
UV_HANDLE_TYPE_PRIVATE
|
|
166
170
|
UV_HANDLE_TYPE_MAX
|
|
167
171
|
} uv_handle_type;
|
|
168
172
|
|
|
@@ -176,7 +180,7 @@ typedef enum {
|
|
|
176
180
|
} uv_req_type;
|
|
177
181
|
|
|
178
182
|
|
|
179
|
-
|
|
183
|
+
/* Handle types. */
|
|
180
184
|
typedef struct uv_loop_s uv_loop_t;
|
|
181
185
|
typedef struct uv_ares_task_s uv_ares_task_t;
|
|
182
186
|
typedef struct uv_err_s uv_err_t;
|
|
@@ -186,27 +190,31 @@ typedef struct uv_tcp_s uv_tcp_t;
|
|
|
186
190
|
typedef struct uv_udp_s uv_udp_t;
|
|
187
191
|
typedef struct uv_pipe_s uv_pipe_t;
|
|
188
192
|
typedef struct uv_tty_s uv_tty_t;
|
|
193
|
+
typedef struct uv_poll_s uv_poll_t;
|
|
189
194
|
typedef struct uv_timer_s uv_timer_t;
|
|
190
195
|
typedef struct uv_prepare_s uv_prepare_t;
|
|
191
196
|
typedef struct uv_check_s uv_check_t;
|
|
192
197
|
typedef struct uv_idle_s uv_idle_t;
|
|
193
198
|
typedef struct uv_async_s uv_async_t;
|
|
194
|
-
typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
|
|
195
199
|
typedef struct uv_process_s uv_process_t;
|
|
196
|
-
typedef struct
|
|
197
|
-
typedef struct
|
|
198
|
-
|
|
199
|
-
/* Request types */
|
|
200
|
+
typedef struct uv_fs_event_s uv_fs_event_t;
|
|
201
|
+
typedef struct uv_fs_poll_s uv_fs_poll_t;
|
|
202
|
+
|
|
203
|
+
/* Request types. */
|
|
200
204
|
typedef struct uv_req_s uv_req_t;
|
|
205
|
+
typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
|
|
201
206
|
typedef struct uv_shutdown_s uv_shutdown_t;
|
|
202
207
|
typedef struct uv_write_s uv_write_t;
|
|
203
208
|
typedef struct uv_connect_s uv_connect_t;
|
|
204
209
|
typedef struct uv_udp_send_s uv_udp_send_t;
|
|
205
210
|
typedef struct uv_fs_s uv_fs_t;
|
|
206
|
-
/* uv_fs_event_t is a subclass of uv_handle_t. */
|
|
207
|
-
typedef struct uv_fs_event_s uv_fs_event_t;
|
|
208
211
|
typedef struct uv_work_s uv_work_t;
|
|
209
212
|
|
|
213
|
+
/* None of the above. */
|
|
214
|
+
typedef struct uv_counters_s uv_counters_t;
|
|
215
|
+
typedef struct uv_cpu_info_s uv_cpu_info_t;
|
|
216
|
+
typedef struct uv_interface_address_s uv_interface_address_t;
|
|
217
|
+
|
|
210
218
|
|
|
211
219
|
/*
|
|
212
220
|
* This function must be called before any other functions in libuv.
|
|
@@ -219,10 +227,6 @@ typedef struct uv_work_s uv_work_t;
|
|
|
219
227
|
UV_EXTERN uv_loop_t* uv_loop_new(void);
|
|
220
228
|
UV_EXTERN void uv_loop_delete(uv_loop_t*);
|
|
221
229
|
|
|
222
|
-
/* This is a debugging tool. It's NOT part of the official API. */
|
|
223
|
-
UV_EXTERN int uv_loop_refcount(const uv_loop_t*);
|
|
224
|
-
|
|
225
|
-
|
|
226
230
|
/*
|
|
227
231
|
* Returns the default loop.
|
|
228
232
|
*/
|
|
@@ -230,21 +234,24 @@ UV_EXTERN uv_loop_t* uv_default_loop(void);
|
|
|
230
234
|
|
|
231
235
|
/*
|
|
232
236
|
* This function starts the event loop. It blocks until the reference count
|
|
233
|
-
* of the loop drops to zero.
|
|
237
|
+
* of the loop drops to zero. Always returns zero.
|
|
234
238
|
*/
|
|
235
|
-
UV_EXTERN int uv_run
|
|
239
|
+
UV_EXTERN int uv_run(uv_loop_t*);
|
|
236
240
|
|
|
237
241
|
/*
|
|
238
|
-
*
|
|
242
|
+
* Poll for new events once. Note that this function blocks if there are no
|
|
243
|
+
* pending events. Returns zero when done (no active handles or requests left),
|
|
244
|
+
* or non-zero if more events are expected (meaning you should call
|
|
245
|
+
* uv_run_once() again sometime in the future).
|
|
239
246
|
*/
|
|
240
|
-
UV_EXTERN int uv_run_once
|
|
247
|
+
UV_EXTERN int uv_run_once(uv_loop_t*);
|
|
241
248
|
|
|
242
249
|
/*
|
|
243
250
|
* Manually modify the event loop's reference count. Useful if the user wants
|
|
244
251
|
* to have a handle or timeout that doesn't keep the loop alive.
|
|
245
252
|
*/
|
|
246
|
-
UV_EXTERN void uv_ref(
|
|
247
|
-
UV_EXTERN void uv_unref(
|
|
253
|
+
UV_EXTERN void uv_ref(uv_handle_t*);
|
|
254
|
+
UV_EXTERN void uv_unref(uv_handle_t*);
|
|
248
255
|
|
|
249
256
|
UV_EXTERN void uv_update_time(uv_loop_t*);
|
|
250
257
|
UV_EXTERN int64_t uv_now(uv_loop_t*);
|
|
@@ -285,18 +292,21 @@ typedef void (*uv_connect_cb)(uv_connect_t* req, int status);
|
|
|
285
292
|
typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);
|
|
286
293
|
typedef void (*uv_connection_cb)(uv_stream_t* server, int status);
|
|
287
294
|
typedef void (*uv_close_cb)(uv_handle_t* handle);
|
|
295
|
+
typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events);
|
|
288
296
|
typedef void (*uv_timer_cb)(uv_timer_t* handle, int status);
|
|
289
297
|
/* TODO: do these really need a status argument? */
|
|
290
298
|
typedef void (*uv_async_cb)(uv_async_t* handle, int status);
|
|
291
299
|
typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status);
|
|
292
300
|
typedef void (*uv_check_cb)(uv_check_t* handle, int status);
|
|
293
301
|
typedef void (*uv_idle_cb)(uv_idle_t* handle, int status);
|
|
294
|
-
typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* handle, int status,
|
|
295
|
-
struct addrinfo* res);
|
|
296
302
|
typedef void (*uv_exit_cb)(uv_process_t*, int exit_status, int term_signal);
|
|
303
|
+
typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg);
|
|
297
304
|
typedef void (*uv_fs_cb)(uv_fs_t* req);
|
|
298
305
|
typedef void (*uv_work_cb)(uv_work_t* req);
|
|
299
306
|
typedef void (*uv_after_work_cb)(uv_work_t* req);
|
|
307
|
+
typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req,
|
|
308
|
+
int status,
|
|
309
|
+
struct addrinfo* res);
|
|
300
310
|
|
|
301
311
|
/*
|
|
302
312
|
* This will be called repeatedly after the uv_fs_event_t is initialized.
|
|
@@ -307,6 +317,11 @@ typedef void (*uv_after_work_cb)(uv_work_t* req);
|
|
|
307
317
|
typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
|
|
308
318
|
int events, int status);
|
|
309
319
|
|
|
320
|
+
typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle,
|
|
321
|
+
int status,
|
|
322
|
+
const uv_statbuf_t* prev,
|
|
323
|
+
const uv_statbuf_t* curr);
|
|
324
|
+
|
|
310
325
|
typedef enum {
|
|
311
326
|
UV_LEAVE_GROUP = 0,
|
|
312
327
|
UV_JOIN_GROUP
|
|
@@ -332,12 +347,13 @@ UV_EXTERN const char* uv_err_name(uv_err_t err);
|
|
|
332
347
|
|
|
333
348
|
|
|
334
349
|
#define UV_REQ_FIELDS \
|
|
335
|
-
/* read-only */ \
|
|
336
|
-
uv_req_type type; \
|
|
337
350
|
/* public */ \
|
|
338
351
|
void* data; \
|
|
339
352
|
/* private */ \
|
|
340
|
-
|
|
353
|
+
ngx_queue_t active_queue; \
|
|
354
|
+
UV_REQ_PRIVATE_FIELDS \
|
|
355
|
+
/* read-only */ \
|
|
356
|
+
uv_req_type type; \
|
|
341
357
|
|
|
342
358
|
/* Abstract base class of all requests. */
|
|
343
359
|
struct uv_req_s {
|
|
@@ -368,15 +384,17 @@ struct uv_shutdown_s {
|
|
|
368
384
|
};
|
|
369
385
|
|
|
370
386
|
|
|
371
|
-
#define UV_HANDLE_FIELDS
|
|
372
|
-
/* read-only */
|
|
373
|
-
uv_loop_t* loop;
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
387
|
+
#define UV_HANDLE_FIELDS \
|
|
388
|
+
/* read-only */ \
|
|
389
|
+
uv_loop_t* loop; \
|
|
390
|
+
/* public */ \
|
|
391
|
+
uv_close_cb close_cb; \
|
|
392
|
+
void* data; \
|
|
393
|
+
/* read-only */ \
|
|
394
|
+
uv_handle_type type; \
|
|
395
|
+
/* private */ \
|
|
396
|
+
ngx_queue_t handle_queue; \
|
|
397
|
+
UV_HANDLE_PRIVATE_FIELDS \
|
|
380
398
|
|
|
381
399
|
/* The abstract base class of all handles. */
|
|
382
400
|
struct uv_handle_s {
|
|
@@ -399,7 +417,13 @@ UV_EXTERN size_t uv_req_size(uv_req_type type);
|
|
|
399
417
|
* Returns 1 if the prepare/check/idle/timer handle has been started, 0
|
|
400
418
|
* otherwise. For other handle types this always returns 1.
|
|
401
419
|
*/
|
|
402
|
-
UV_EXTERN int uv_is_active(uv_handle_t* handle);
|
|
420
|
+
UV_EXTERN int uv_is_active(const uv_handle_t* handle);
|
|
421
|
+
|
|
422
|
+
/*
|
|
423
|
+
* Walk the list of open handles.
|
|
424
|
+
*/
|
|
425
|
+
UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg);
|
|
426
|
+
|
|
403
427
|
|
|
404
428
|
/*
|
|
405
429
|
* Request handle to be closed. close_cb will be called asynchronously after
|
|
@@ -418,7 +442,7 @@ UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
|
|
|
418
442
|
* base and len members of the uv_buf_t struct. The user is responsible for
|
|
419
443
|
* freeing base after the uv_buf_t is done. Return struct passed by value.
|
|
420
444
|
*/
|
|
421
|
-
UV_EXTERN uv_buf_t uv_buf_init(char* base,
|
|
445
|
+
UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len);
|
|
422
446
|
|
|
423
447
|
|
|
424
448
|
/*
|
|
@@ -540,8 +564,8 @@ struct uv_write_s {
|
|
|
540
564
|
/*
|
|
541
565
|
* Used to determine whether a stream is readable or writable.
|
|
542
566
|
*/
|
|
543
|
-
UV_EXTERN int uv_is_readable(uv_stream_t* handle);
|
|
544
|
-
UV_EXTERN int uv_is_writable(uv_stream_t* handle);
|
|
567
|
+
UV_EXTERN int uv_is_readable(const uv_stream_t* handle);
|
|
568
|
+
UV_EXTERN int uv_is_writable(const uv_stream_t* handle);
|
|
545
569
|
|
|
546
570
|
|
|
547
571
|
/*
|
|
@@ -551,7 +575,7 @@ UV_EXTERN int uv_is_writable(uv_stream_t* handle);
|
|
|
551
575
|
* and the arrival of the close callback, and cannot be used
|
|
552
576
|
* to validate the handle.
|
|
553
577
|
*/
|
|
554
|
-
UV_EXTERN int uv_is_closing(uv_handle_t* handle);
|
|
578
|
+
UV_EXTERN int uv_is_closing(const uv_handle_t* handle);
|
|
555
579
|
|
|
556
580
|
|
|
557
581
|
/*
|
|
@@ -923,6 +947,74 @@ UV_EXTERN void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
|
|
|
923
947
|
UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
|
|
924
948
|
|
|
925
949
|
|
|
950
|
+
/*
|
|
951
|
+
* uv_poll_t is a subclass of uv_handle_t.
|
|
952
|
+
*
|
|
953
|
+
* The uv_poll watcher is used to watch file descriptors for readability and
|
|
954
|
+
* writability, similar to the purpose of poll(2).
|
|
955
|
+
*
|
|
956
|
+
* The purpose of uv_poll is to enable integrating external libraries that
|
|
957
|
+
* rely on the event loop to signal it about the socket status changes, like
|
|
958
|
+
* c-ares or libssh2. Using uv_poll_t for any other other purpose is not
|
|
959
|
+
* recommended; uv_tcp_t, uv_udp_t, etc. provide an implementation that is
|
|
960
|
+
* much faster and more scalable than what can be achieved with uv_poll_t,
|
|
961
|
+
* especially on Windows.
|
|
962
|
+
*
|
|
963
|
+
* It is possible that uv_poll occasionally signals that a file descriptor is
|
|
964
|
+
* readable or writable even when it isn't. The user should therefore always
|
|
965
|
+
* be prepared to handle EAGAIN or equivalent when it attempts to read from or
|
|
966
|
+
* write to the fd.
|
|
967
|
+
*
|
|
968
|
+
* It is not okay to have multiple active uv_poll watchers for the same socket.
|
|
969
|
+
* This can cause libuv to busyloop or otherwise malfunction.
|
|
970
|
+
*
|
|
971
|
+
* The user should not close a file descriptor while it is being polled by an
|
|
972
|
+
* active uv_poll watcher. This can cause the poll watcher to report an error,
|
|
973
|
+
* but it might also start polling another socket. However the fd can be safely
|
|
974
|
+
* closed immediately after a call to uv_poll_stop() or uv_close().
|
|
975
|
+
*
|
|
976
|
+
* On windows only sockets can be polled with uv_poll. On unix any file
|
|
977
|
+
* descriptor that would be accepted by poll(2) can be used with uv_poll.
|
|
978
|
+
*/
|
|
979
|
+
struct uv_poll_s {
|
|
980
|
+
UV_HANDLE_FIELDS
|
|
981
|
+
uv_poll_cb poll_cb;
|
|
982
|
+
UV_POLL_PRIVATE_FIELDS
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
enum uv_poll_event {
|
|
986
|
+
UV_READABLE = 1,
|
|
987
|
+
UV_WRITABLE = 2
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
/* Initialize the poll watcher using a file descriptor. */
|
|
991
|
+
UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
|
|
992
|
+
|
|
993
|
+
/* Initialize the poll watcher using a socket descriptor. On unix this is */
|
|
994
|
+
/* identical to uv_poll_init. On windows it takes a SOCKET handle. */
|
|
995
|
+
UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
|
|
996
|
+
uv_os_sock_t socket);
|
|
997
|
+
|
|
998
|
+
/*
|
|
999
|
+
* Starts polling the file descriptor. `events` is a bitmask consisting made up
|
|
1000
|
+
* of UV_READABLE and UV_WRITABLE. As soon as an event is detected the callback
|
|
1001
|
+
* will be called with `status` set to 0, and the detected events set en the
|
|
1002
|
+
* `events` field.
|
|
1003
|
+
*
|
|
1004
|
+
* If an error happens while polling status may be set to -1 and the error
|
|
1005
|
+
* code can be retrieved with uv_last_error. The user should not close the
|
|
1006
|
+
* socket while uv_poll is active. If the user does that anyway, the callback
|
|
1007
|
+
* *may* be called reporting an error status, but this is not guaranteed.
|
|
1008
|
+
*
|
|
1009
|
+
* Calling uv_poll_start on an uv_poll watcher that is already active is fine.
|
|
1010
|
+
* Doing so will update the events mask that is being watched for.
|
|
1011
|
+
*/
|
|
1012
|
+
UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb);
|
|
1013
|
+
|
|
1014
|
+
/* Stops polling the file descriptor. */
|
|
1015
|
+
UV_EXTERN int uv_poll_stop(uv_poll_t* handle);
|
|
1016
|
+
|
|
1017
|
+
|
|
926
1018
|
/*
|
|
927
1019
|
* uv_prepare_t is a subclass of uv_handle_t.
|
|
928
1020
|
*
|
|
@@ -1058,7 +1150,7 @@ UV_EXTERN void uv_ares_destroy(uv_loop_t*, ares_channel channel);
|
|
|
1058
1150
|
struct uv_getaddrinfo_s {
|
|
1059
1151
|
UV_REQ_FIELDS
|
|
1060
1152
|
/* read-only */
|
|
1061
|
-
uv_loop_t* loop;
|
|
1153
|
+
uv_loop_t* loop;
|
|
1062
1154
|
UV_GETADDRINFO_PRIVATE_FIELDS
|
|
1063
1155
|
};
|
|
1064
1156
|
|
|
@@ -1066,22 +1158,59 @@ struct uv_getaddrinfo_s {
|
|
|
1066
1158
|
/*
|
|
1067
1159
|
* Asynchronous getaddrinfo(3).
|
|
1068
1160
|
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1161
|
+
* Either node or service may be NULL but not both.
|
|
1162
|
+
*
|
|
1163
|
+
* hints is a pointer to a struct addrinfo with additional address type
|
|
1164
|
+
* constraints, or NULL. Consult `man -s 3 getaddrinfo` for details.
|
|
1165
|
+
*
|
|
1166
|
+
* Returns 0 on success, -1 on error. Call uv_last_error() to get the error.
|
|
1167
|
+
*
|
|
1168
|
+
* If successful, your callback gets called sometime in the future with the
|
|
1169
|
+
* lookup result, which is either:
|
|
1072
1170
|
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1171
|
+
* a) status == 0, the res argument points to a valid struct addrinfo, or
|
|
1172
|
+
* b) status == -1, the res argument is NULL.
|
|
1075
1173
|
*
|
|
1076
|
-
* On
|
|
1174
|
+
* On NXDOMAIN, the status code is -1 and uv_last_error() returns UV_ENOENT.
|
|
1175
|
+
*
|
|
1176
|
+
* Call uv_freeaddrinfo() to free the addrinfo structure.
|
|
1077
1177
|
*/
|
|
1078
|
-
UV_EXTERN int uv_getaddrinfo(uv_loop_t
|
|
1079
|
-
|
|
1080
|
-
|
|
1178
|
+
UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop,
|
|
1179
|
+
uv_getaddrinfo_t* req,
|
|
1180
|
+
uv_getaddrinfo_cb getaddrinfo_cb,
|
|
1181
|
+
const char* node,
|
|
1182
|
+
const char* service,
|
|
1183
|
+
const struct addrinfo* hints);
|
|
1081
1184
|
|
|
1185
|
+
/*
|
|
1186
|
+
* Free the struct addrinfo. Passing NULL is allowed and is a no-op.
|
|
1187
|
+
*/
|
|
1082
1188
|
UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);
|
|
1083
1189
|
|
|
1084
1190
|
/* uv_spawn() options */
|
|
1191
|
+
typedef enum {
|
|
1192
|
+
UV_IGNORE = 0x00,
|
|
1193
|
+
UV_CREATE_PIPE = 0x01,
|
|
1194
|
+
UV_INHERIT_FD = 0x02,
|
|
1195
|
+
UV_INHERIT_STREAM = 0x04,
|
|
1196
|
+
|
|
1197
|
+
/* When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
|
|
1198
|
+
* determine the direction of flow, from the child process' perspective. Both
|
|
1199
|
+
* flags may be specified to create a duplex data stream.
|
|
1200
|
+
*/
|
|
1201
|
+
UV_READABLE_PIPE = 0x10,
|
|
1202
|
+
UV_WRITABLE_PIPE = 0x20
|
|
1203
|
+
} uv_stdio_flags;
|
|
1204
|
+
|
|
1205
|
+
typedef struct uv_stdio_container_s {
|
|
1206
|
+
uv_stdio_flags flags;
|
|
1207
|
+
|
|
1208
|
+
union {
|
|
1209
|
+
uv_stream_t* stream;
|
|
1210
|
+
int fd;
|
|
1211
|
+
} data;
|
|
1212
|
+
} uv_stdio_container_t;
|
|
1213
|
+
|
|
1085
1214
|
typedef struct uv_process_options_s {
|
|
1086
1215
|
uv_exit_cb exit_cb; /* Called after the process exits. */
|
|
1087
1216
|
const char* file; /* Path to program to execute. */
|
|
@@ -1102,22 +1231,64 @@ typedef struct uv_process_options_s {
|
|
|
1102
1231
|
* in. Stands for current working directory.
|
|
1103
1232
|
*/
|
|
1104
1233
|
char* cwd;
|
|
1105
|
-
|
|
1106
1234
|
/*
|
|
1107
|
-
*
|
|
1235
|
+
* Various flags that control how uv_spawn() behaves. See the definition of
|
|
1236
|
+
* `enum uv_process_flags` below.
|
|
1237
|
+
*/
|
|
1238
|
+
unsigned int flags;
|
|
1239
|
+
/*
|
|
1240
|
+
* Libuv can change the child process' user/group id. This happens only when
|
|
1241
|
+
* the appropriate bits are set in the flags fields. This is not supported on
|
|
1242
|
+
* windows; uv_spawn() will fail and set the error to UV_ENOTSUP.
|
|
1108
1243
|
*/
|
|
1109
|
-
|
|
1244
|
+
uv_uid_t uid;
|
|
1245
|
+
uv_gid_t gid;
|
|
1110
1246
|
|
|
1111
1247
|
/*
|
|
1112
|
-
* The
|
|
1113
|
-
*
|
|
1114
|
-
* The
|
|
1248
|
+
* The `stdio` field points to an array of uv_stdio_container_t structs that
|
|
1249
|
+
* describe the file descriptors that will be made available to the child
|
|
1250
|
+
* process. The convention is that stdio[0] points to stdin, fd 1 is used for
|
|
1251
|
+
* stdout, and fd 2 is stderr.
|
|
1252
|
+
*
|
|
1253
|
+
* Note that on windows file descriptors greater than 2 are available to the
|
|
1254
|
+
* child process only if the child processes uses the MSVCRT runtime.
|
|
1115
1255
|
*/
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
uv_pipe_t* stderr_stream;
|
|
1256
|
+
int stdio_count;
|
|
1257
|
+
uv_stdio_container_t* stdio;
|
|
1119
1258
|
} uv_process_options_t;
|
|
1120
1259
|
|
|
1260
|
+
/*
|
|
1261
|
+
* These are the flags that can be used for the uv_process_options.flags field.
|
|
1262
|
+
*/
|
|
1263
|
+
enum uv_process_flags {
|
|
1264
|
+
/*
|
|
1265
|
+
* Set the child process' user id. The user id is supplied in the `uid` field
|
|
1266
|
+
* of the options struct. This does not work on windows; setting this flag
|
|
1267
|
+
* will cause uv_spawn() to fail.
|
|
1268
|
+
*/
|
|
1269
|
+
UV_PROCESS_SETUID = (1 << 0),
|
|
1270
|
+
/*
|
|
1271
|
+
* Set the child process' group id. The user id is supplied in the `gid`
|
|
1272
|
+
* field of the options struct. This does not work on windows; setting this
|
|
1273
|
+
* flag will cause uv_spawn() to fail.
|
|
1274
|
+
*/
|
|
1275
|
+
UV_PROCESS_SETGID = (1 << 1),
|
|
1276
|
+
/*
|
|
1277
|
+
* Do not wrap any arguments in quotes, or perform any other escaping, when
|
|
1278
|
+
* converting the argument list into a command line string. This option is
|
|
1279
|
+
* only meaningful on Windows systems. On unix it is silently ignored.
|
|
1280
|
+
*/
|
|
1281
|
+
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
|
|
1282
|
+
/*
|
|
1283
|
+
* Spawn the child process in a detached state - this will make it a process
|
|
1284
|
+
* group leader, and will effectively enable the child to keep running after
|
|
1285
|
+
* the parent exits. Note that the child process will still keep the
|
|
1286
|
+
* parent's event loop alive unless the parent process calls uv_unref() on
|
|
1287
|
+
* the child's process handle.
|
|
1288
|
+
*/
|
|
1289
|
+
UV_PROCESS_DETACHED = (1 << 3)
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1121
1292
|
/*
|
|
1122
1293
|
* uv_process_t is a subclass of uv_handle_t
|
|
1123
1294
|
*/
|
|
@@ -1132,6 +1303,7 @@ struct uv_process_s {
|
|
|
1132
1303
|
UV_EXTERN int uv_spawn(uv_loop_t*, uv_process_t*,
|
|
1133
1304
|
uv_process_options_t options);
|
|
1134
1305
|
|
|
1306
|
+
|
|
1135
1307
|
/*
|
|
1136
1308
|
* Kills the process with the specified signal. The user must still
|
|
1137
1309
|
* call uv_close on the process.
|
|
@@ -1249,8 +1421,8 @@ typedef enum {
|
|
|
1249
1421
|
/* uv_fs_t is a subclass of uv_req_t */
|
|
1250
1422
|
struct uv_fs_s {
|
|
1251
1423
|
UV_REQ_FIELDS
|
|
1252
|
-
uv_loop_t* loop;
|
|
1253
1424
|
uv_fs_type fs_type;
|
|
1425
|
+
uv_loop_t* loop;
|
|
1254
1426
|
uv_fs_cb cb;
|
|
1255
1427
|
ssize_t result;
|
|
1256
1428
|
void* ptr;
|
|
@@ -1268,13 +1440,13 @@ UV_EXTERN int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
|
1268
1440
|
int flags, int mode, uv_fs_cb cb);
|
|
1269
1441
|
|
|
1270
1442
|
UV_EXTERN int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file,
|
|
1271
|
-
void* buf, size_t length,
|
|
1443
|
+
void* buf, size_t length, int64_t offset, uv_fs_cb cb);
|
|
1272
1444
|
|
|
1273
1445
|
UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
1274
1446
|
uv_fs_cb cb);
|
|
1275
1447
|
|
|
1276
1448
|
UV_EXTERN int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file,
|
|
1277
|
-
void* buf, size_t length,
|
|
1449
|
+
void* buf, size_t length, int64_t offset, uv_fs_cb cb);
|
|
1278
1450
|
|
|
1279
1451
|
UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
1280
1452
|
int mode, uv_fs_cb cb);
|
|
@@ -1301,10 +1473,10 @@ UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file,
|
|
|
1301
1473
|
uv_fs_cb cb);
|
|
1302
1474
|
|
|
1303
1475
|
UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
|
|
1304
|
-
|
|
1476
|
+
int64_t offset, uv_fs_cb cb);
|
|
1305
1477
|
|
|
1306
1478
|
UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
|
|
1307
|
-
uv_file in_fd,
|
|
1479
|
+
uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb);
|
|
1308
1480
|
|
|
1309
1481
|
UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
1310
1482
|
int mode, uv_fs_cb cb);
|
|
@@ -1327,6 +1499,12 @@ UV_EXTERN int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
|
1327
1499
|
*/
|
|
1328
1500
|
#define UV_FS_SYMLINK_DIR 0x0001
|
|
1329
1501
|
|
|
1502
|
+
/*
|
|
1503
|
+
* This flag can be used with uv_fs_symlink on Windows
|
|
1504
|
+
* to specify whether the symlink is to be created using junction points.
|
|
1505
|
+
*/
|
|
1506
|
+
#define UV_FS_SYMLINK_JUNCTION 0x0002
|
|
1507
|
+
|
|
1330
1508
|
UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
1331
1509
|
const char* new_path, int flags, uv_fs_cb cb);
|
|
1332
1510
|
|
|
@@ -1356,6 +1534,46 @@ struct uv_fs_event_s {
|
|
|
1356
1534
|
};
|
|
1357
1535
|
|
|
1358
1536
|
|
|
1537
|
+
/*
|
|
1538
|
+
* uv_fs_stat() based polling file watcher.
|
|
1539
|
+
*/
|
|
1540
|
+
struct uv_fs_poll_s {
|
|
1541
|
+
UV_HANDLE_FIELDS
|
|
1542
|
+
/* Private, don't touch. */
|
|
1543
|
+
int busy_polling; /* TODO(bnoordhuis) Fold into flags field. */
|
|
1544
|
+
unsigned int interval;
|
|
1545
|
+
uint64_t start_time;
|
|
1546
|
+
char* path;
|
|
1547
|
+
uv_fs_poll_cb poll_cb;
|
|
1548
|
+
uv_timer_t timer_handle;
|
|
1549
|
+
uv_fs_t* fs_req;
|
|
1550
|
+
uv_statbuf_t statbuf;
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
|
|
1554
|
+
|
|
1555
|
+
/*
|
|
1556
|
+
* Check the file at `path` for changes every `interval` milliseconds.
|
|
1557
|
+
*
|
|
1558
|
+
* Your callback i invoked with `status == -1` if `path` does not exist
|
|
1559
|
+
* or is inaccessible. The watcher is *not* stopped but your callback is
|
|
1560
|
+
* not called again until something changes (e.g. when the file is created
|
|
1561
|
+
* or the error reason changes).
|
|
1562
|
+
*
|
|
1563
|
+
* When `status == 0`, your callback receives pointers to the old and new
|
|
1564
|
+
* `uv_statbuf_t` structs. They are valid for the duration of the callback
|
|
1565
|
+
* only!
|
|
1566
|
+
*
|
|
1567
|
+
* For maximum portability, use multi-second intervals. Sub-second intervals
|
|
1568
|
+
* will not detect all changes on many file systems.
|
|
1569
|
+
*/
|
|
1570
|
+
UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
|
|
1571
|
+
uv_fs_poll_cb poll_cb,
|
|
1572
|
+
const char* path,
|
|
1573
|
+
unsigned int interval);
|
|
1574
|
+
|
|
1575
|
+
UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
|
|
1576
|
+
|
|
1359
1577
|
/*
|
|
1360
1578
|
* Gets load avg
|
|
1361
1579
|
* See: http://en.wikipedia.org/wiki/Load_(computing)
|
|
@@ -1427,23 +1645,42 @@ UV_EXTERN extern uint64_t uv_hrtime(void);
|
|
|
1427
1645
|
|
|
1428
1646
|
|
|
1429
1647
|
/*
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1648
|
+
* Disables inheritance for file descriptors / handles that this process
|
|
1649
|
+
* inherited from its parent. The effect is that child processes spawned by
|
|
1650
|
+
* this proces don't accidently inherit these handles.
|
|
1651
|
+
*
|
|
1652
|
+
* It is recommended to call this function as early in your program as possible,
|
|
1653
|
+
* before the inherited file descriptors can be closed or duplicated.
|
|
1654
|
+
*
|
|
1655
|
+
* Note that this function works on a best-effort basis: there is no guarantee
|
|
1656
|
+
* that libuv can discover all file descriptors that were inherited. In general
|
|
1657
|
+
* it does a better job on Windows than it does on unix.
|
|
1658
|
+
*
|
|
1659
|
+
* TODO(bb): insert snarky remark to annoy bnoordhuis and the folks at joyent.
|
|
1660
|
+
*/
|
|
1661
|
+
UV_EXTERN void uv_disable_stdio_inheritance(void);
|
|
1662
|
+
|
|
1663
|
+
/*
|
|
1664
|
+
* Opens a shared library. The filename is in utf-8. Returns 0 on success and
|
|
1665
|
+
* -1 on error. Call `uv_dlerror(uv_lib_t*)` to get the error message.
|
|
1666
|
+
*/
|
|
1667
|
+
UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib);
|
|
1668
|
+
|
|
1669
|
+
/*
|
|
1670
|
+
* Close the shared libary.
|
|
1432
1671
|
*/
|
|
1433
|
-
UV_EXTERN
|
|
1434
|
-
UV_EXTERN uv_err_t uv_dlclose(uv_lib_t library);
|
|
1672
|
+
UV_EXTERN void uv_dlclose(uv_lib_t* lib);
|
|
1435
1673
|
|
|
1436
1674
|
/*
|
|
1437
1675
|
* Retrieves a data pointer from a dynamic library. It is legal for a symbol to
|
|
1438
|
-
* map to NULL.
|
|
1676
|
+
* map to NULL. Returns 0 on success and -1 if the symbol was not found.
|
|
1439
1677
|
*/
|
|
1440
|
-
UV_EXTERN
|
|
1678
|
+
UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
|
|
1441
1679
|
|
|
1442
1680
|
/*
|
|
1443
|
-
*
|
|
1681
|
+
* Returns the last uv_dlopen() or uv_dlsym() error message.
|
|
1444
1682
|
*/
|
|
1445
|
-
UV_EXTERN const char
|
|
1446
|
-
UV_EXTERN void uv_dlerror_free(uv_lib_t library, const char *msg);
|
|
1683
|
+
UV_EXTERN const char* uv_dlerror(uv_lib_t* lib);
|
|
1447
1684
|
|
|
1448
1685
|
/*
|
|
1449
1686
|
* The mutex functions return 0 on success, -1 on error
|
|
@@ -1467,6 +1704,15 @@ UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
|
|
|
1467
1704
|
UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
|
|
1468
1705
|
UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
|
|
1469
1706
|
|
|
1707
|
+
/*
|
|
1708
|
+
* Same goes for the semaphore functions.
|
|
1709
|
+
*/
|
|
1710
|
+
UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
|
|
1711
|
+
UV_EXTERN void uv_sem_destroy(uv_sem_t* sem);
|
|
1712
|
+
UV_EXTERN void uv_sem_post(uv_sem_t* sem);
|
|
1713
|
+
UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
|
|
1714
|
+
UV_EXTERN int uv_sem_trywait(uv_sem_t* sem);
|
|
1715
|
+
|
|
1470
1716
|
/* Runs a function once and only once. Concurrent calls to uv_once() with the
|
|
1471
1717
|
* same guard will block all callers except one (it's unspecified which one).
|
|
1472
1718
|
* The guard should be initialized statically with the UV_ONCE_INIT macro.
|
|
@@ -1479,6 +1725,8 @@ UV_EXTERN int uv_thread_join(uv_thread_t *tid);
|
|
|
1479
1725
|
|
|
1480
1726
|
/* the presence of these unions force similar struct layout */
|
|
1481
1727
|
union uv_any_handle {
|
|
1728
|
+
uv_handle_t handle;
|
|
1729
|
+
uv_stream_t stream;
|
|
1482
1730
|
uv_tcp_t tcp;
|
|
1483
1731
|
uv_pipe_t pipe;
|
|
1484
1732
|
uv_prepare_t prepare;
|
|
@@ -1486,8 +1734,12 @@ union uv_any_handle {
|
|
|
1486
1734
|
uv_idle_t idle;
|
|
1487
1735
|
uv_async_t async;
|
|
1488
1736
|
uv_timer_t timer;
|
|
1489
|
-
uv_getaddrinfo_t getaddrinfo;
|
|
1490
1737
|
uv_fs_event_t fs_event;
|
|
1738
|
+
uv_fs_poll_t fs_poll;
|
|
1739
|
+
uv_poll_t poll;
|
|
1740
|
+
uv_process_t process;
|
|
1741
|
+
uv_tty_t tty;
|
|
1742
|
+
uv_udp_t udp;
|
|
1491
1743
|
};
|
|
1492
1744
|
|
|
1493
1745
|
union uv_any_req {
|
|
@@ -1497,36 +1749,49 @@ union uv_any_req {
|
|
|
1497
1749
|
uv_shutdown_t shutdown;
|
|
1498
1750
|
uv_fs_t fs_req;
|
|
1499
1751
|
uv_work_t work_req;
|
|
1752
|
+
uv_udp_send_t udp_send_req;
|
|
1753
|
+
uv_getaddrinfo_t getaddrinfo_req;
|
|
1500
1754
|
};
|
|
1501
1755
|
|
|
1502
1756
|
|
|
1503
1757
|
struct uv_counters_s {
|
|
1758
|
+
uint64_t async_init;
|
|
1759
|
+
uint64_t check_init;
|
|
1504
1760
|
uint64_t eio_init;
|
|
1505
|
-
uint64_t
|
|
1761
|
+
uint64_t fs_event_init;
|
|
1762
|
+
uint64_t fs_poll_init;
|
|
1506
1763
|
uint64_t handle_init;
|
|
1507
|
-
uint64_t
|
|
1508
|
-
uint64_t tcp_init;
|
|
1509
|
-
uint64_t udp_init;
|
|
1764
|
+
uint64_t idle_init;
|
|
1510
1765
|
uint64_t pipe_init;
|
|
1511
|
-
uint64_t
|
|
1766
|
+
uint64_t poll_init;
|
|
1512
1767
|
uint64_t prepare_init;
|
|
1513
|
-
uint64_t check_init;
|
|
1514
|
-
uint64_t idle_init;
|
|
1515
|
-
uint64_t async_init;
|
|
1516
|
-
uint64_t timer_init;
|
|
1517
1768
|
uint64_t process_init;
|
|
1518
|
-
uint64_t
|
|
1769
|
+
uint64_t req_init;
|
|
1770
|
+
uint64_t stream_init;
|
|
1771
|
+
uint64_t tcp_init;
|
|
1772
|
+
uint64_t timer_init;
|
|
1773
|
+
uint64_t tty_init;
|
|
1774
|
+
uint64_t udp_init;
|
|
1519
1775
|
};
|
|
1520
1776
|
|
|
1521
1777
|
|
|
1522
1778
|
struct uv_loop_s {
|
|
1523
1779
|
UV_LOOP_PRIVATE_FIELDS
|
|
1780
|
+
ares_channel channel;
|
|
1781
|
+
/* While the channel is active this timer is called once per second to be */
|
|
1782
|
+
/* sure that we're always calling ares_process. See the warning above the */
|
|
1783
|
+
/* definition of ares_timeout(). */
|
|
1784
|
+
uv_timer_t ares_timer; \
|
|
1524
1785
|
/* RB_HEAD(uv__ares_tasks, uv_ares_task_t) */
|
|
1525
|
-
struct uv__ares_tasks { uv_ares_task_t* rbh_root; }
|
|
1786
|
+
struct uv__ares_tasks { uv_ares_task_t* rbh_root; } ares_handles;
|
|
1526
1787
|
/* Diagnostic counters */
|
|
1527
1788
|
uv_counters_t counters;
|
|
1528
1789
|
/* The last error */
|
|
1529
1790
|
uv_err_t last_err;
|
|
1791
|
+
/* Loop reference counting */
|
|
1792
|
+
unsigned int active_handles;
|
|
1793
|
+
ngx_queue_t handle_queue;
|
|
1794
|
+
ngx_queue_t active_reqs;
|
|
1530
1795
|
/* User data - use this for whatever. */
|
|
1531
1796
|
void* data;
|
|
1532
1797
|
};
|