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.
Files changed (251) hide show
  1. data/README.markdown +3 -0
  2. data/Rakefile +38 -0
  3. data/asyncengine.gemspec +8 -4
  4. data/ext/asyncengine/ae_call_from_other_thread.c +106 -0
  5. data/ext/asyncengine/ae_call_from_other_thread.h +12 -0
  6. data/ext/asyncengine/ae_handle_common.c +193 -48
  7. data/ext/asyncengine/ae_handle_common.h +40 -13
  8. data/ext/asyncengine/ae_ip_utils.c +246 -0
  9. data/ext/asyncengine/ae_ip_utils.h +25 -0
  10. data/ext/asyncengine/ae_next_tick.c +81 -21
  11. data/ext/asyncengine/ae_next_tick.h +4 -2
  12. data/ext/asyncengine/ae_resolver.c +156 -0
  13. data/ext/asyncengine/ae_resolver.h +10 -0
  14. data/ext/asyncengine/ae_tcp.c +908 -0
  15. data/ext/asyncengine/ae_tcp.h +20 -0
  16. data/ext/asyncengine/ae_timer.c +355 -81
  17. data/ext/asyncengine/ae_timer.h +11 -4
  18. data/ext/asyncengine/ae_udp.c +579 -13
  19. data/ext/asyncengine/ae_udp.h +15 -2
  20. data/ext/asyncengine/ae_utils.c +192 -0
  21. data/ext/asyncengine/ae_utils.h +16 -0
  22. data/ext/asyncengine/asyncengine_ruby.c +469 -26
  23. data/ext/asyncengine/asyncengine_ruby.h +49 -11
  24. data/ext/asyncengine/debug.h +68 -0
  25. data/ext/asyncengine/extconf.rb +26 -2
  26. data/ext/asyncengine/ip_parser.c +5954 -0
  27. data/ext/asyncengine/ip_parser.h +16 -0
  28. data/ext/asyncengine/libuv/AUTHORS +16 -0
  29. data/ext/asyncengine/libuv/common.gypi +4 -4
  30. data/ext/asyncengine/libuv/config-mingw.mk +6 -6
  31. data/ext/asyncengine/libuv/config-unix.mk +13 -13
  32. data/ext/asyncengine/libuv/gyp_uv +5 -1
  33. data/ext/asyncengine/libuv/ibc_tests/exec_test.sh +8 -0
  34. data/ext/asyncengine/libuv/ibc_tests/uv_shutdown_write_issue.c +171 -0
  35. data/ext/asyncengine/libuv/ibc_tests/uv_tcp_close_while_connecting.c +102 -0
  36. data/ext/asyncengine/libuv/include/uv-private/ngx-queue.h +3 -1
  37. data/ext/asyncengine/libuv/include/uv-private/uv-unix.h +103 -50
  38. data/ext/asyncengine/libuv/include/uv-private/uv-win.h +76 -24
  39. data/ext/asyncengine/libuv/include/uv.h +353 -88
  40. data/ext/asyncengine/libuv/src/ares/ares__close_sockets.o +0 -0
  41. data/ext/asyncengine/libuv/src/ares/ares__get_hostent.o +0 -0
  42. data/ext/asyncengine/libuv/src/ares/ares__read_line.o +0 -0
  43. data/ext/asyncengine/libuv/src/ares/ares__timeval.o +0 -0
  44. data/ext/asyncengine/libuv/src/ares/ares_cancel.o +0 -0
  45. data/ext/asyncengine/libuv/src/ares/ares_data.o +0 -0
  46. data/ext/asyncengine/libuv/src/ares/ares_destroy.o +0 -0
  47. data/ext/asyncengine/libuv/src/ares/ares_expand_name.o +0 -0
  48. data/ext/asyncengine/libuv/src/ares/ares_expand_string.o +0 -0
  49. data/ext/asyncengine/libuv/src/ares/ares_fds.o +0 -0
  50. data/ext/asyncengine/libuv/src/ares/ares_free_hostent.o +0 -0
  51. data/ext/asyncengine/libuv/src/ares/ares_free_string.o +0 -0
  52. data/ext/asyncengine/libuv/src/ares/ares_gethostbyaddr.o +0 -0
  53. data/ext/asyncengine/libuv/src/ares/ares_gethostbyname.o +0 -0
  54. data/ext/asyncengine/libuv/src/ares/ares_getnameinfo.o +0 -0
  55. data/ext/asyncengine/libuv/src/ares/ares_getopt.o +0 -0
  56. data/ext/asyncengine/libuv/src/ares/ares_getsock.o +0 -0
  57. data/ext/asyncengine/libuv/src/ares/ares_init.o +0 -0
  58. data/ext/asyncengine/libuv/src/ares/ares_library_init.o +0 -0
  59. data/ext/asyncengine/libuv/src/ares/ares_llist.o +0 -0
  60. data/ext/asyncengine/libuv/src/ares/ares_mkquery.o +0 -0
  61. data/ext/asyncengine/libuv/src/ares/ares_nowarn.o +0 -0
  62. data/ext/asyncengine/libuv/src/ares/ares_options.o +0 -0
  63. data/ext/asyncengine/libuv/src/ares/ares_parse_a_reply.o +0 -0
  64. data/ext/asyncengine/libuv/src/ares/ares_parse_aaaa_reply.o +0 -0
  65. data/ext/asyncengine/libuv/src/ares/ares_parse_mx_reply.o +0 -0
  66. data/ext/asyncengine/libuv/src/ares/ares_parse_ns_reply.o +0 -0
  67. data/ext/asyncengine/libuv/src/ares/ares_parse_ptr_reply.o +0 -0
  68. data/ext/asyncengine/libuv/src/ares/ares_parse_srv_reply.o +0 -0
  69. data/ext/asyncengine/libuv/src/ares/ares_parse_txt_reply.o +0 -0
  70. data/ext/asyncengine/libuv/src/ares/ares_process.o +0 -0
  71. data/ext/asyncengine/libuv/src/ares/ares_query.o +0 -0
  72. data/ext/asyncengine/libuv/src/ares/ares_search.o +0 -0
  73. data/ext/asyncengine/libuv/src/ares/ares_send.o +0 -0
  74. data/ext/asyncengine/libuv/src/ares/ares_strcasecmp.o +0 -0
  75. data/ext/asyncengine/libuv/src/ares/ares_strdup.o +0 -0
  76. data/ext/asyncengine/libuv/src/ares/ares_strerror.o +0 -0
  77. data/ext/asyncengine/libuv/src/ares/ares_timeout.o +0 -0
  78. data/ext/asyncengine/libuv/src/ares/ares_version.o +0 -0
  79. data/ext/asyncengine/libuv/src/ares/ares_writev.o +0 -0
  80. data/ext/asyncengine/libuv/src/ares/bitncmp.o +0 -0
  81. data/ext/asyncengine/libuv/src/ares/inet_net_pton.o +0 -0
  82. data/ext/asyncengine/libuv/src/ares/inet_ntop.o +0 -0
  83. data/ext/asyncengine/libuv/src/cares.c +225 -0
  84. data/ext/asyncengine/libuv/src/cares.o +0 -0
  85. data/ext/asyncengine/libuv/src/fs-poll.c +237 -0
  86. data/ext/asyncengine/libuv/src/fs-poll.o +0 -0
  87. data/ext/asyncengine/libuv/src/unix/async.c +78 -17
  88. data/ext/asyncengine/libuv/src/unix/async.o +0 -0
  89. data/ext/asyncengine/libuv/src/unix/core.c +305 -213
  90. data/ext/asyncengine/libuv/src/unix/core.o +0 -0
  91. data/ext/asyncengine/libuv/src/unix/cygwin.c +1 -1
  92. data/ext/asyncengine/libuv/src/unix/darwin.c +2 -1
  93. data/ext/asyncengine/libuv/src/unix/dl.c +36 -44
  94. data/ext/asyncengine/libuv/src/unix/dl.o +0 -0
  95. data/ext/asyncengine/libuv/src/unix/eio/eio.o +0 -0
  96. data/ext/asyncengine/libuv/src/unix/error.c +6 -0
  97. data/ext/asyncengine/libuv/src/unix/error.o +0 -0
  98. data/ext/asyncengine/libuv/src/unix/ev/ev.c +8 -4
  99. data/ext/asyncengine/libuv/src/unix/ev/ev.o +0 -0
  100. data/ext/asyncengine/libuv/src/unix/freebsd.c +1 -1
  101. data/ext/asyncengine/libuv/src/unix/fs.c +25 -33
  102. data/ext/asyncengine/libuv/src/unix/fs.o +0 -0
  103. data/ext/asyncengine/libuv/src/unix/internal.h +50 -31
  104. data/ext/asyncengine/libuv/src/unix/kqueue.c +2 -7
  105. data/ext/asyncengine/libuv/src/unix/linux/core.o +0 -0
  106. data/ext/asyncengine/libuv/src/unix/linux/inotify.c +12 -14
  107. data/ext/asyncengine/libuv/src/unix/linux/inotify.o +0 -0
  108. data/ext/asyncengine/libuv/src/unix/linux/{core.c → linux-core.c} +1 -1
  109. data/ext/asyncengine/libuv/src/unix/linux/linux-core.o +0 -0
  110. data/ext/asyncengine/libuv/src/unix/linux/syscalls.c +147 -1
  111. data/ext/asyncengine/libuv/src/unix/linux/syscalls.h +39 -2
  112. data/ext/asyncengine/libuv/src/unix/linux/syscalls.o +0 -0
  113. data/ext/asyncengine/libuv/src/unix/loop-watcher.c +63 -0
  114. data/ext/asyncengine/libuv/src/unix/loop-watcher.o +0 -0
  115. data/ext/asyncengine/libuv/src/unix/loop.c +29 -6
  116. data/ext/asyncengine/libuv/src/unix/loop.o +0 -0
  117. data/ext/asyncengine/libuv/src/unix/netbsd.c +1 -1
  118. data/ext/asyncengine/libuv/src/unix/openbsd.c +1 -1
  119. data/ext/asyncengine/libuv/src/unix/pipe.c +31 -36
  120. data/ext/asyncengine/libuv/src/unix/pipe.o +0 -0
  121. data/ext/asyncengine/libuv/src/unix/poll.c +116 -0
  122. data/ext/asyncengine/libuv/src/unix/poll.o +0 -0
  123. data/ext/asyncengine/libuv/src/unix/process.c +193 -115
  124. data/ext/asyncengine/libuv/src/unix/process.o +0 -0
  125. data/ext/asyncengine/libuv/src/unix/stream.c +146 -153
  126. data/ext/asyncengine/libuv/src/unix/stream.o +0 -0
  127. data/ext/asyncengine/libuv/src/unix/sunos.c +45 -36
  128. data/ext/asyncengine/libuv/src/unix/tcp.c +6 -5
  129. data/ext/asyncengine/libuv/src/unix/tcp.o +0 -0
  130. data/ext/asyncengine/libuv/src/unix/thread.c +82 -25
  131. data/ext/asyncengine/libuv/src/unix/thread.o +0 -0
  132. data/ext/asyncengine/libuv/src/unix/timer.c +69 -58
  133. data/ext/asyncengine/libuv/src/unix/timer.o +0 -0
  134. data/ext/asyncengine/libuv/src/unix/tty.c +3 -3
  135. data/ext/asyncengine/libuv/src/unix/tty.o +0 -0
  136. data/ext/asyncengine/libuv/src/unix/udp.c +57 -66
  137. data/ext/asyncengine/libuv/src/unix/udp.o +0 -0
  138. data/ext/asyncengine/libuv/src/unix/uv-eio.c +33 -50
  139. data/ext/asyncengine/libuv/src/unix/uv-eio.o +0 -0
  140. data/ext/asyncengine/libuv/src/uv-common.c +68 -38
  141. data/ext/asyncengine/libuv/src/uv-common.h +104 -20
  142. data/ext/asyncengine/libuv/src/uv-common.o +0 -0
  143. data/ext/asyncengine/libuv/src/win/async.c +20 -17
  144. data/ext/asyncengine/libuv/src/win/core.c +44 -31
  145. data/ext/asyncengine/libuv/src/win/dl.c +40 -36
  146. data/ext/asyncengine/libuv/src/win/error.c +21 -1
  147. data/ext/asyncengine/libuv/src/win/fs-event.c +19 -21
  148. data/ext/asyncengine/libuv/src/win/fs.c +541 -189
  149. data/ext/asyncengine/libuv/src/win/getaddrinfo.c +56 -63
  150. data/ext/asyncengine/libuv/src/win/handle-inl.h +145 -0
  151. data/ext/asyncengine/libuv/src/win/handle.c +26 -101
  152. data/ext/asyncengine/libuv/src/win/internal.h +92 -107
  153. data/ext/asyncengine/libuv/src/win/loop-watcher.c +6 -14
  154. data/ext/asyncengine/libuv/src/win/pipe.c +78 -64
  155. data/ext/asyncengine/libuv/src/win/poll.c +618 -0
  156. data/ext/asyncengine/libuv/src/win/process-stdio.c +479 -0
  157. data/ext/asyncengine/libuv/src/win/process.c +147 -274
  158. data/ext/asyncengine/libuv/src/win/req-inl.h +225 -0
  159. data/ext/asyncengine/libuv/src/win/req.c +0 -149
  160. data/ext/asyncengine/libuv/src/{unix/check.c → win/stream-inl.h} +31 -42
  161. data/ext/asyncengine/libuv/src/win/stream.c +9 -43
  162. data/ext/asyncengine/libuv/src/win/tcp.c +200 -82
  163. data/ext/asyncengine/libuv/src/win/thread.c +42 -2
  164. data/ext/asyncengine/libuv/src/win/threadpool.c +3 -2
  165. data/ext/asyncengine/libuv/src/win/timer.c +13 -63
  166. data/ext/asyncengine/libuv/src/win/tty.c +26 -20
  167. data/ext/asyncengine/libuv/src/win/udp.c +26 -17
  168. data/ext/asyncengine/libuv/src/win/util.c +312 -167
  169. data/ext/asyncengine/libuv/src/win/winapi.c +16 -1
  170. data/ext/asyncengine/libuv/src/win/winapi.h +33 -9
  171. data/ext/asyncengine/libuv/src/win/winsock.c +88 -1
  172. data/ext/asyncengine/libuv/src/win/winsock.h +36 -3
  173. data/ext/asyncengine/libuv/test/benchmark-ares.c +16 -17
  174. data/ext/asyncengine/libuv/test/benchmark-fs-stat.c +164 -0
  175. data/ext/asyncengine/libuv/test/benchmark-list.h +9 -0
  176. data/ext/asyncengine/libuv/{src/unix/prepare.c → test/benchmark-loop-count.c} +42 -33
  177. data/ext/asyncengine/libuv/test/benchmark-million-timers.c +65 -0
  178. data/ext/asyncengine/libuv/test/benchmark-pound.c +1 -1
  179. data/ext/asyncengine/libuv/test/benchmark-sizes.c +2 -0
  180. data/ext/asyncengine/libuv/test/benchmark-spawn.c +7 -1
  181. data/ext/asyncengine/libuv/test/benchmark-udp-packet-storm.c +1 -1
  182. data/ext/asyncengine/libuv/test/echo-server.c +8 -0
  183. data/ext/asyncengine/libuv/test/run-tests.c +30 -0
  184. data/ext/asyncengine/libuv/test/runner-unix.c +6 -26
  185. data/ext/asyncengine/libuv/test/runner-win.c +5 -63
  186. data/ext/asyncengine/libuv/test/runner.c +10 -1
  187. data/ext/asyncengine/libuv/test/task.h +0 -8
  188. data/ext/asyncengine/libuv/test/test-async.c +43 -141
  189. data/ext/asyncengine/libuv/test/test-callback-order.c +76 -0
  190. data/ext/asyncengine/libuv/test/test-counters-init.c +2 -3
  191. data/ext/asyncengine/libuv/test/test-dlerror.c +17 -8
  192. data/ext/asyncengine/libuv/test/test-fs-event.c +31 -39
  193. data/ext/asyncengine/libuv/test/test-fs-poll.c +146 -0
  194. data/ext/asyncengine/libuv/test/test-fs.c +114 -2
  195. data/ext/asyncengine/libuv/test/test-gethostbyname.c +8 -8
  196. data/ext/asyncengine/libuv/test/test-hrtime.c +18 -15
  197. data/ext/asyncengine/libuv/test/test-ipc.c +8 -2
  198. data/ext/asyncengine/libuv/test/test-list.h +59 -9
  199. data/ext/asyncengine/libuv/test/test-loop-handles.c +2 -25
  200. data/ext/asyncengine/libuv/{src/unix/idle.c → test/test-poll-close.c} +37 -39
  201. data/ext/asyncengine/libuv/test/test-poll.c +573 -0
  202. data/ext/asyncengine/libuv/test/test-ref.c +79 -63
  203. data/ext/asyncengine/libuv/test/test-run-once.c +15 -11
  204. data/ext/asyncengine/libuv/test/test-semaphore.c +111 -0
  205. data/ext/asyncengine/libuv/test/test-spawn.c +368 -20
  206. data/ext/asyncengine/libuv/test/test-stdio-over-pipes.c +25 -35
  207. data/ext/asyncengine/libuv/test/test-tcp-close-while-connecting.c +80 -0
  208. data/ext/asyncengine/libuv/test/test-tcp-close.c +1 -1
  209. data/ext/asyncengine/libuv/test/test-tcp-connect-error-after-write.c +95 -0
  210. data/ext/asyncengine/libuv/test/test-tcp-connect-timeout.c +85 -0
  211. data/ext/asyncengine/libuv/test/test-tcp-shutdown-after-write.c +131 -0
  212. data/ext/asyncengine/libuv/test/test-tcp-write-error.c +2 -2
  213. data/ext/asyncengine/libuv/test/test-tcp-writealot.c +29 -54
  214. data/ext/asyncengine/libuv/test/test-timer-again.c +1 -1
  215. data/ext/asyncengine/libuv/test/test-timer.c +23 -1
  216. data/ext/asyncengine/libuv/test/test-udp-options.c +1 -1
  217. data/ext/asyncengine/libuv/test/{test-eio-overflow.c → test-walk-handles.c} +31 -44
  218. data/ext/asyncengine/libuv/uv.gyp +26 -9
  219. data/ext/asyncengine/rb_utilities.c +54 -0
  220. data/ext/asyncengine/rb_utilities.h +63 -0
  221. data/lib/asyncengine.rb +45 -38
  222. data/lib/asyncengine/asyncengine_ext.so +0 -0
  223. data/lib/asyncengine/debug.rb +37 -0
  224. data/lib/asyncengine/handle.rb +9 -0
  225. data/lib/asyncengine/tcp.rb +28 -0
  226. data/lib/asyncengine/timer.rb +18 -28
  227. data/lib/asyncengine/udp.rb +29 -0
  228. data/lib/asyncengine/utils.rb +32 -0
  229. data/lib/asyncengine/uv_error.rb +17 -0
  230. data/lib/asyncengine/version.rb +9 -1
  231. data/test/ae_test_helper.rb +62 -0
  232. data/test/test_basic.rb +169 -0
  233. data/test/test_call_from_other_thread.rb +55 -0
  234. data/test/test_error.rb +92 -0
  235. data/test/test_ip_utils.rb +44 -0
  236. data/test/test_next_tick.rb +37 -0
  237. data/test/test_resolver.rb +51 -0
  238. data/test/test_threads.rb +69 -0
  239. data/test/test_timer.rb +95 -0
  240. data/test/test_udp.rb +216 -0
  241. data/test/test_utils.rb +49 -0
  242. metadata +84 -57
  243. data/ext/asyncengine/libuv/mkmf.log +0 -24
  244. data/ext/asyncengine/libuv/src/unix/cares.c +0 -194
  245. data/ext/asyncengine/libuv/src/unix/cares.o +0 -0
  246. data/ext/asyncengine/libuv/src/unix/check.o +0 -0
  247. data/ext/asyncengine/libuv/src/unix/idle.o +0 -0
  248. data/ext/asyncengine/libuv/src/unix/prepare.o +0 -0
  249. data/ext/asyncengine/libuv/src/win/cares.c +0 -290
  250. data/lib/asyncengine/errors.rb +0 -5
  251. data/lib/asyncengine/next_tick.rb +0 -24
@@ -100,7 +100,9 @@ struct ngx_queue_s {
100
100
 
101
101
 
102
102
  #define ngx_queue_foreach(q, h) \
103
- for ((q) = ngx_queue_head(h); (q) != (h); (q) = ngx_queue_next(q))
103
+ for ((q) = ngx_queue_head(h); \
104
+ (q) != ngx_queue_sentinel(h); \
105
+ (q) = ngx_queue_next(q))
104
106
 
105
107
 
106
108
  #endif /* NGX_QUEUE_H_INCLUDED_ */
@@ -28,13 +28,26 @@
28
28
  #include "eio.h"
29
29
 
30
30
  #include <sys/types.h>
31
+ #include <sys/stat.h>
32
+ #include <fcntl.h>
33
+
31
34
  #include <sys/socket.h>
32
35
  #include <netinet/in.h>
33
36
  #include <netinet/tcp.h>
34
37
  #include <arpa/inet.h>
35
38
  #include <netdb.h>
39
+
36
40
  #include <termios.h>
41
+ #include <pwd.h>
42
+
43
+ #include <semaphore.h>
37
44
  #include <pthread.h>
45
+ #include <signal.h>
46
+
47
+ #if __sun
48
+ # include <sys/port.h>
49
+ # include <port.h>
50
+ #endif
38
51
 
39
52
  /* Note: May be cast to struct iovec. See writev(2). */
40
53
  typedef struct {
@@ -44,18 +57,39 @@ typedef struct {
44
57
 
45
58
  typedef int uv_file;
46
59
 
60
+ typedef int uv_os_sock_t;
61
+
62
+ typedef struct stat uv_statbuf_t;
63
+
47
64
  #define UV_ONCE_INIT PTHREAD_ONCE_INIT
48
65
 
49
66
  typedef pthread_once_t uv_once_t;
50
67
  typedef pthread_t uv_thread_t;
51
68
  typedef pthread_mutex_t uv_mutex_t;
52
69
  typedef pthread_rwlock_t uv_rwlock_t;
70
+ typedef sem_t uv_sem_t;
71
+
72
+ /* Platform-specific definitions for uv_spawn support. */
73
+ typedef gid_t uv_gid_t;
74
+ typedef uid_t uv_uid_t;
53
75
 
54
76
  /* Platform-specific definitions for uv_dlopen support. */
55
- typedef void* uv_lib_t;
56
77
  #define UV_DYNAMIC /* empty */
78
+ typedef struct {
79
+ void* handle;
80
+ char* errmsg;
81
+ } uv_lib_t;
82
+
83
+ struct uv__io_s;
84
+ struct uv_loop_s;
85
+
86
+ typedef struct uv__io_s uv__io_t;
87
+ typedef void (*uv__io_cb)(struct uv_loop_s* loop, uv__io_t* handle, int events);
88
+
89
+ struct uv__io_s {
90
+ ev_io io_watcher;
91
+ };
57
92
 
58
- #define UV_HANDLE_TYPE_PRIVATE /* empty */
59
93
  #define UV_REQ_TYPE_PRIVATE /* empty */
60
94
 
61
95
  #if __linux__
@@ -64,28 +98,34 @@ typedef void* uv_lib_t;
64
98
  struct uv__inotify_watchers { \
65
99
  struct uv_fs_event_s* rbh_root; \
66
100
  } inotify_watchers; \
67
- ev_io inotify_read_watcher; \
101
+ uv__io_t inotify_read_watcher; \
68
102
  int inotify_fd;
103
+ #elif defined(PORT_SOURCE_FILE)
104
+ # define UV_LOOP_PRIVATE_PLATFORM_FIELDS \
105
+ uv__io_t fs_event_watcher; \
106
+ int fs_fd;
69
107
  #else
70
108
  # define UV_LOOP_PRIVATE_PLATFORM_FIELDS
71
109
  #endif
72
110
 
73
- #define UV_LOOP_PRIVATE_FIELDS \
74
- ares_channel channel; \
75
- /* \
76
- * While the channel is active this timer is called once per second to be \
77
- * sure that we're always calling ares_process. See the warning above the \
78
- * definition of ares_timeout(). \
79
- */ \
80
- uv_timer_t timer; \
81
- /* Poll result queue */ \
82
- eio_channel uv_eio_channel; \
83
- struct ev_loop* ev; \
84
- /* Various thing for libeio. */ \
85
- uv_async_t uv_eio_want_poll_notifier; \
86
- uv_async_t uv_eio_done_poll_notifier; \
87
- uv_idle_t uv_eio_poller; \
88
- uv_handle_t* endgame_handles; \
111
+ #define UV_LOOP_PRIVATE_FIELDS \
112
+ /* Poll result queue */ \
113
+ eio_channel uv_eio_channel; \
114
+ struct ev_loop* ev; \
115
+ /* Various thing for libeio. */ \
116
+ uv_async_t uv_eio_want_poll_notifier; \
117
+ uv_async_t uv_eio_done_poll_notifier; \
118
+ uv_idle_t uv_eio_poller; \
119
+ uv_handle_t* closing_handles; \
120
+ ngx_queue_t prepare_handles; \
121
+ ngx_queue_t check_handles; \
122
+ ngx_queue_t idle_handles; \
123
+ ngx_queue_t async_handles; \
124
+ uv__io_t async_watcher; \
125
+ int async_pipefd[2]; \
126
+ /* RB_HEAD(uv__timers, uv_timer_s) */ \
127
+ struct uv__timers { struct uv_timer_s* rbh_root; } timer_handles; \
128
+ uint64_t time; \
89
129
  UV_LOOP_PRIVATE_PLATFORM_FIELDS
90
130
 
91
131
  #define UV_REQ_BUFSML_SIZE (4)
@@ -107,10 +147,9 @@ typedef void* uv_lib_t;
107
147
 
108
148
  #define UV_UDP_SEND_PRIVATE_FIELDS \
109
149
  ngx_queue_t queue; \
110
- struct sockaddr_storage addr; \
111
- socklen_t addrlen; \
112
- uv_buf_t* bufs; \
150
+ struct sockaddr_in6 addr; \
113
151
  int bufcnt; \
152
+ uv_buf_t* bufs; \
114
153
  ssize_t status; \
115
154
  uv_udp_send_cb send_cb; \
116
155
  uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \
@@ -120,22 +159,21 @@ typedef void* uv_lib_t;
120
159
 
121
160
  /* TODO: union or classes please! */
122
161
  #define UV_HANDLE_PRIVATE_FIELDS \
123
- int fd; \
124
162
  int flags; \
125
- uv_handle_t* endgame_next; /* that's what uv-win calls it */ \
163
+ uv_handle_t* next_closing; \
126
164
 
127
165
 
128
166
  #define UV_STREAM_PRIVATE_FIELDS \
129
167
  uv_connect_t *connect_req; \
130
168
  uv_shutdown_t *shutdown_req; \
131
- ev_io read_watcher; \
132
- ev_io write_watcher; \
169
+ uv__io_t read_watcher; \
170
+ uv__io_t write_watcher; \
133
171
  ngx_queue_t write_queue; \
134
172
  ngx_queue_t write_completed_queue; \
135
- int delayed_error; \
136
173
  uv_connection_cb connection_cb; \
174
+ int delayed_error; \
137
175
  int accepted_fd; \
138
- int blocking;
176
+ int fd; \
139
177
 
140
178
 
141
179
  /* UV_TCP */
@@ -144,10 +182,11 @@ typedef void* uv_lib_t;
144
182
 
145
183
  /* UV_UDP */
146
184
  #define UV_UDP_PRIVATE_FIELDS \
185
+ int fd; \
147
186
  uv_alloc_cb alloc_cb; \
148
187
  uv_udp_recv_cb recv_cb; \
149
- ev_io read_watcher; \
150
- ev_io write_watcher; \
188
+ uv__io_t read_watcher; \
189
+ uv__io_t write_watcher; \
151
190
  ngx_queue_t write_queue; \
152
191
  ngx_queue_t write_completed_queue; \
153
192
 
@@ -157,34 +196,49 @@ typedef void* uv_lib_t;
157
196
  const char* pipe_fname; /* strdup'ed */
158
197
 
159
198
 
160
- /* UV_PREPARE */ \
199
+ /* UV_POLL */
200
+ #define UV_POLL_PRIVATE_FIELDS \
201
+ int fd; \
202
+ uv__io_t io_watcher;
203
+
204
+
205
+ /* UV_PREPARE */
161
206
  #define UV_PREPARE_PRIVATE_FIELDS \
162
- ev_prepare prepare_watcher; \
163
- uv_prepare_cb prepare_cb;
207
+ uv_prepare_cb prepare_cb; \
208
+ ngx_queue_t queue;
164
209
 
165
210
 
166
211
  /* UV_CHECK */
167
212
  #define UV_CHECK_PRIVATE_FIELDS \
168
- ev_check check_watcher; \
169
- uv_check_cb check_cb;
213
+ uv_check_cb check_cb; \
214
+ ngx_queue_t queue;
170
215
 
171
216
 
172
217
  /* UV_IDLE */
173
218
  #define UV_IDLE_PRIVATE_FIELDS \
174
- ev_idle idle_watcher; \
175
- uv_idle_cb idle_cb;
219
+ uv_idle_cb idle_cb; \
220
+ ngx_queue_t queue;
176
221
 
177
222
 
178
223
  /* UV_ASYNC */
179
- #define UV_ASYNC_PRIVATE_FIELDS \
180
- ev_async async_watcher; \
181
- uv_async_cb async_cb;
224
+ #define UV_ASYNC_PRIVATE_FIELDS \
225
+ volatile sig_atomic_t pending; \
226
+ uv_async_cb async_cb; \
227
+ ngx_queue_t queue;
182
228
 
183
229
 
184
230
  /* UV_TIMER */
185
- #define UV_TIMER_PRIVATE_FIELDS \
186
- ev_timer timer_watcher; \
187
- uv_timer_cb timer_cb;
231
+ #define UV_TIMER_PRIVATE_FIELDS \
232
+ /* RB_ENTRY(uv_timer_s) node; */ \
233
+ struct { \
234
+ struct uv_timer_s* rbe_left; \
235
+ struct uv_timer_s* rbe_right; \
236
+ struct uv_timer_s* rbe_parent; \
237
+ int rbe_color; \
238
+ } tree_entry; \
239
+ uv_timer_cb timer_cb; \
240
+ uint64_t timeout; \
241
+ uint64_t repeat;
188
242
 
189
243
  #define UV_GETADDRINFO_PRIVATE_FIELDS \
190
244
  uv_getaddrinfo_cb cb; \
@@ -219,11 +273,12 @@ typedef void* uv_lib_t;
219
273
  struct uv_fs_event_s* rbe_parent; \
220
274
  int rbe_color; \
221
275
  } node; \
222
- ev_io read_watcher; \
223
- uv_fs_event_cb cb;
276
+ uv_fs_event_cb cb; \
277
+ int fd; \
224
278
 
225
279
  #elif defined(__APPLE__) \
226
280
  || defined(__FreeBSD__) \
281
+ || defined(__DragonFly__) \
227
282
  || defined(__OpenBSD__) \
228
283
  || defined(__NetBSD__)
229
284
 
@@ -231,17 +286,15 @@ typedef void* uv_lib_t;
231
286
  ev_io event_watcher; \
232
287
  uv_fs_event_cb cb; \
233
288
  int fflags; \
289
+ int fd;
234
290
 
235
291
  #elif defined(__sun)
236
292
 
237
- #include <sys/port.h>
238
- #include <port.h>
239
-
240
293
  #ifdef PORT_SOURCE_FILE
241
294
  # define UV_FS_EVENT_PRIVATE_FIELDS \
242
- ev_io event_watcher; \
243
295
  uv_fs_event_cb cb; \
244
- file_obj_t fo;
296
+ file_obj_t fo; \
297
+ int fd;
245
298
  #else /* !PORT_SOURCE_FILE */
246
299
  # define UV_FS_EVENT_PRIVATE_FIELDS
247
300
  #endif
@@ -32,9 +32,14 @@
32
32
  #include <sys/stat.h>
33
33
 
34
34
  #include "tree.h"
35
+ #include "ngx-queue.h"
35
36
 
36
37
  #define MAX_PIPENAME_LEN 256
37
38
 
39
+ #ifndef S_IFLNK
40
+ # define S_IFLNK 0xA000
41
+ #endif
42
+
38
43
  /*
39
44
  * Guids and typedefs for winsock extension functions
40
45
  * Mingw32 doesn't have these :-(
@@ -115,8 +120,7 @@ typedef int (WSAAPI* LPFN_WSARECV)
115
120
  LPDWORD bytes,
116
121
  LPDWORD flags,
117
122
  LPWSAOVERLAPPED overlapped,
118
- LPWSAOVERLAPPED_COMPLETION_ROUTINE
119
- completion_routine);
123
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
120
124
 
121
125
  typedef int (WSAAPI* LPFN_WSARECVFROM)
122
126
  (SOCKET socket,
@@ -129,6 +133,26 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
129
133
  LPWSAOVERLAPPED overlapped,
130
134
  LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
131
135
 
136
+ #ifndef _NTDEF_
137
+ typedef LONG NTSTATUS;
138
+ typedef NTSTATUS *PNTSTATUS;
139
+ #endif
140
+
141
+ typedef struct _AFD_POLL_HANDLE_INFO {
142
+ HANDLE Handle;
143
+ ULONG Events;
144
+ NTSTATUS Status;
145
+ } AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
146
+
147
+ typedef struct _AFD_POLL_INFO {
148
+ LARGE_INTEGER Timeout;
149
+ ULONG NumberOfHandles;
150
+ ULONG Exclusive;
151
+ AFD_POLL_HANDLE_INFO Handles[1];
152
+ } AFD_POLL_INFO, *PAFD_POLL_INFO;
153
+
154
+ #define UV_MSAFD_PROVIDER_COUNT 3
155
+
132
156
 
133
157
  /**
134
158
  * It should be possible to cast uv_buf_t[] to WSABUF[]
@@ -141,8 +165,14 @@ typedef struct uv_buf_t {
141
165
 
142
166
  typedef int uv_file;
143
167
 
168
+ typedef struct _stati64 uv_statbuf_t;
169
+
170
+ typedef SOCKET uv_os_sock_t;
171
+
144
172
  typedef HANDLE uv_thread_t;
145
173
 
174
+ typedef HANDLE uv_sem_t;
175
+
146
176
  typedef CRITICAL_SECTION uv_mutex_t;
147
177
 
148
178
  typedef union {
@@ -166,17 +196,22 @@ typedef struct uv_once_s {
166
196
  HANDLE padding;
167
197
  } uv_once_t;
168
198
 
199
+ /* Platform-specific definitions for uv_spawn support. */
200
+ typedef unsigned char uv_uid_t;
201
+ typedef unsigned char uv_gid_t;
202
+
169
203
  /* Platform-specific definitions for uv_dlopen support. */
170
- typedef HMODULE uv_lib_t;
171
204
  #define UV_DYNAMIC FAR WINAPI
205
+ typedef struct {
206
+ HMODULE handle;
207
+ char* errmsg;
208
+ } uv_lib_t;
172
209
 
173
210
  RB_HEAD(uv_timer_tree_s, uv_timer_s);
174
211
 
175
212
  #define UV_LOOP_PRIVATE_FIELDS \
176
213
  /* The loop's I/O completion port */ \
177
214
  HANDLE iocp; \
178
- /* Reference count that keeps the event loop alive */ \
179
- int refs; \
180
215
  /* The current time according to the event loop. in msecs. */ \
181
216
  int64_t time; \
182
217
  /* Tail of a single-linked circular queue of pending reqs. If the queue */ \
@@ -198,24 +233,18 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
198
233
  uv_prepare_t* next_prepare_handle; \
199
234
  uv_check_t* next_check_handle; \
200
235
  uv_idle_t* next_idle_handle; \
201
- ares_channel ares_chan; \
202
- int ares_active_sockets; \
203
- uv_timer_t ares_polling_timer; \
236
+ /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
237
+ SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
204
238
  /* Counter to keep track of active tcp streams */ \
205
239
  unsigned int active_tcp_streams; \
206
240
  /* Counter to keep track of active udp streams */ \
207
241
  unsigned int active_udp_streams;
208
242
 
209
- #define UV_HANDLE_TYPE_PRIVATE \
210
- UV_ARES_EVENT,
211
-
212
243
  #define UV_REQ_TYPE_PRIVATE \
213
244
  /* TODO: remove the req suffix */ \
214
245
  UV_ACCEPT, \
215
- UV_ARES_EVENT_REQ, \
216
- UV_ARES_CLEANUP_REQ, \
217
246
  UV_FS_EVENT_REQ, \
218
- UV_GETADDRINFO_REQ, \
247
+ UV_POLL_REQ, \
219
248
  UV_PROCESS_EXIT, \
220
249
  UV_PROCESS_CLOSE, \
221
250
  UV_READ, \
@@ -278,6 +307,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
278
307
 
279
308
  #define UV_STREAM_PRIVATE_FIELDS \
280
309
  unsigned int reqs_pending; \
310
+ int activecnt; \
281
311
  uv_read_t read_req; \
282
312
  union { \
283
313
  struct { uv_stream_connection_fields }; \
@@ -305,6 +335,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
305
335
  #define UV_UDP_PRIVATE_FIELDS \
306
336
  SOCKET socket; \
307
337
  unsigned int reqs_pending; \
338
+ int activecnt; \
308
339
  uv_req_t recv_req; \
309
340
  uv_buf_t recv_buffer; \
310
341
  struct sockaddr_storage recv_from; \
@@ -324,6 +355,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
324
355
  uv_write_t ipc_header_write_req; \
325
356
  int ipc_pid; \
326
357
  uint64_t remaining_ipc_rawdata_bytes; \
358
+ unsigned char reserved[sizeof(void*)]; \
327
359
  struct { \
328
360
  WSAPROTOCOL_INFOW* socket_info; \
329
361
  int tcp_connection; \
@@ -365,6 +397,21 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
365
397
  COORD saved_position; \
366
398
  WORD saved_attributes;
367
399
 
400
+ #define UV_POLL_PRIVATE_FIELDS \
401
+ SOCKET socket; \
402
+ /* Used in fast mode */ \
403
+ SOCKET peer_socket; \
404
+ AFD_POLL_INFO afd_poll_info_1; \
405
+ AFD_POLL_INFO afd_poll_info_2; \
406
+ /* Used in fast and slow mode. */ \
407
+ uv_req_t poll_req_1; \
408
+ uv_req_t poll_req_2; \
409
+ unsigned char submitted_events_1; \
410
+ unsigned char submitted_events_2; \
411
+ unsigned char mask_events_1; \
412
+ unsigned char mask_events_2; \
413
+ unsigned char events;
414
+
368
415
  #define UV_TIMER_PRIVATE_FIELDS \
369
416
  RB_ENTRY(uv_timer_s) tree_entry; \
370
417
  int64_t due; \
@@ -397,7 +444,6 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
397
444
  unsigned int flags;
398
445
 
399
446
  #define UV_GETADDRINFO_PRIVATE_FIELDS \
400
- struct uv_req_s getadddrinfo_req; \
401
447
  uv_getaddrinfo_cb getaddrinfo_cb; \
402
448
  void* alloc; \
403
449
  wchar_t* node; \
@@ -413,7 +459,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
413
459
  struct uv_process_close_s { \
414
460
  UV_REQ_FIELDS \
415
461
  } close_req; \
416
- HANDLE child_stdio[3]; \
462
+ BYTE* child_stdio_buffer; \
417
463
  int exit_signal; \
418
464
  DWORD spawn_errno; \
419
465
  HANDLE wait_handle; \
@@ -421,20 +467,26 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
421
467
  HANDLE close_handle;
422
468
 
423
469
  #define UV_FS_PRIVATE_FIELDS \
424
- wchar_t* pathw; \
425
470
  int flags; \
426
471
  DWORD sys_errno_; \
427
- struct _stati64 stat; \
428
- void* arg0; \
472
+ union { \
473
+ wchar_t* pathw; \
474
+ int file; \
475
+ }; \
429
476
  union { \
430
477
  struct { \
431
- void* arg1; \
432
- void* arg2; \
433
- void* arg3; \
478
+ int mode; \
479
+ wchar_t* new_pathw; \
480
+ int file_flags; \
481
+ int file_out; \
482
+ void* buf; \
483
+ size_t length; \
484
+ int64_t offset; \
434
485
  }; \
486
+ struct _stati64 stat; \
435
487
  struct { \
436
- ssize_t arg4; \
437
- ssize_t arg5; \
488
+ double atime; \
489
+ double mtime; \
438
490
  }; \
439
491
  };
440
492