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.
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
@@ -0,0 +1,16 @@
1
+ #ifndef _AE_IP_PARSER_H
2
+ #define _AE_IP_PARSER_H
3
+
4
+
5
+ typedef enum {
6
+ ip_type_no_ip = 0,
7
+ ip_type_ipv4,
8
+ ip_type_ipv6,
9
+ ip_type_ipv6_reference,
10
+ } enum_ip_type;
11
+
12
+
13
+ enum_ip_type ae_ip_parser_execute(const char *str, int len);
14
+
15
+
16
+ #endif /* _AE_IP_PARSER_H */
@@ -43,3 +43,19 @@ Paddy Byers <paddy.byers@gmail.com>
43
43
  Dan VerWeire <dverweire@gmail.com>
44
44
  Brandon Benvie <brandon@bbenvie.com>
45
45
  Brandon Philips <brandon.philips@rackspace.com>
46
+ Nathan Rajlich <nathan@tootallnate.net>
47
+ Brandon Philips <brandon@ifup.org>
48
+ Charlie McConnell <charlie@charlieistheman.com>
49
+ Vladimir Dronnikov <dronnikov@gmail.com>
50
+ Aaron Bieber <qbit@deftly.net>
51
+ Bulat Shakirzyanov <mallluhuct@gmail.com>
52
+ Brian White <mscdex@mscdex.net>
53
+ Erik Dubbelboer <erik@dubbelboer.com>
54
+ Keno Fischer <kenof@stanford.edu>
55
+ Ira Cooper <Ira.Cooper@mathworks.com>
56
+ Andrius Bentkus <andrius.bentkus@gmail.com>
57
+ Brian White <mscdex@gmail.com>
58
+ Iñaki Baz Castillo <ibc@aliax.net>
59
+ Mark Cavage <mark.cavage@joyent.com>
60
+ George Yohng <georgegh@oss3d.com>
61
+ Xidorn Quan <quanxunzhen@gmail.com>
@@ -24,7 +24,7 @@
24
24
  }],
25
25
  ],
26
26
  'Optimization': 0, # /Od, no optimization
27
- 'MinimalRebuild': 'true',
27
+ 'MinimalRebuild': 'false',
28
28
  'OmitFramePointers': 'false',
29
29
  'BasicRuntimeChecks': 3, # /RTC1
30
30
  },
@@ -57,9 +57,6 @@
57
57
  'OmitFramePointers': 'true',
58
58
  'EnableFunctionLevelLinking': 'true',
59
59
  'EnableIntrinsicFunctions': 'true',
60
- 'AdditionalOptions': [
61
- '/MP', # compile across multiple CPUs
62
- ],
63
60
  },
64
61
  'VCLibrarianTool': {
65
62
  'AdditionalOptions': [
@@ -84,6 +81,9 @@
84
81
  'ExceptionHandling': 1, # /EHsc
85
82
  'SuppressStartupBanner': 'true',
86
83
  'WarnAsError': 'false',
84
+ 'AdditionalOptions': [
85
+ '/MP', # compile across multiple CPUs
86
+ ],
87
87
  },
88
88
  'VCLibrarianTool': {
89
89
  },
@@ -37,14 +37,14 @@ RUNNER_LINKFLAGS=$(LINKFLAGS)
37
37
  RUNNER_LIBS=-lws2_32 -lpsapi -liphlpapi
38
38
  RUNNER_SRC=test/runner-win.c
39
39
 
40
- uv.a: $(WIN_OBJS) src/uv-common.o $(CARES_OBJS)
41
- $(AR) rcs uv.a src/win/*.o src/uv-common.o $(CARES_OBJS)
40
+ uv.a: $(WIN_OBJS) src/cares.o src/fs-poll.o src/uv-common.o $(CARES_OBJS)
41
+ $(AR) rcs uv.a $^
42
42
 
43
- src/win/%.o: src/win/%.c src/win/internal.h
44
- $(CC) $(CFLAGS) -o $@ -c $<
43
+ src/%.o: src/%.c include/uv.h include/uv-private/uv-win.h
44
+ $(CC) $(CFLAGS) -c $< -o $@
45
45
 
46
- src/uv-common.o: src/uv-common.c include/uv.h include/uv-private/uv-win.h
47
- $(CC) $(CFLAGS) -c src/uv-common.c -o src/uv-common.o
46
+ src/win/%.o: src/win/%.c include/uv.h include/uv-private/uv-win.h src/win/internal.h
47
+ $(CC) $(CFLAGS) -o $@ -c $<
48
48
 
49
49
  EIO_CPPFLAGS += $(CPPFLAGS)
50
50
  EIO_CPPFLAGS += -DEIO_STACKSIZE=65536
@@ -21,23 +21,21 @@
21
21
  E=
22
22
  CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
23
23
  CFLAGS += -g
24
- CPPFLAGS += -Isrc/unix/ev
24
+ CPPFLAGS += -Isrc -Isrc/unix/ev
25
25
  LINKFLAGS=-lm
26
26
 
27
27
  CPPFLAGS += -D_LARGEFILE_SOURCE
28
28
  CPPFLAGS += -D_FILE_OFFSET_BITS=64
29
29
 
30
30
  OBJS += src/unix/async.o
31
- OBJS += src/unix/cares.o
32
- OBJS += src/unix/check.o
33
31
  OBJS += src/unix/core.o
34
32
  OBJS += src/unix/dl.o
35
33
  OBJS += src/unix/error.o
36
34
  OBJS += src/unix/fs.o
37
- OBJS += src/unix/idle.o
38
35
  OBJS += src/unix/loop.o
36
+ OBJS += src/unix/loop-watcher.o
39
37
  OBJS += src/unix/pipe.o
40
- OBJS += src/unix/prepare.o
38
+ OBJS += src/unix/poll.o
41
39
  OBJS += src/unix/process.o
42
40
  OBJS += src/unix/stream.o
43
41
  OBJS += src/unix/tcp.o
@@ -69,7 +67,9 @@ EIO_CONFIG=config_linux.h
69
67
  CSTDFLAG += -D_GNU_SOURCE
70
68
  CPPFLAGS += -Isrc/ares/config_linux
71
69
  LINKFLAGS+=-ldl -lrt
72
- OBJS += src/unix/linux/core.o src/unix/linux/inotify.o src/unix/linux/syscalls.o
70
+ OBJS += src/unix/linux/linux-core.o \
71
+ src/unix/linux/inotify.o \
72
+ src/unix/linux/syscalls.o
73
73
  endif
74
74
 
75
75
  ifeq (FreeBSD,$(uname_S))
@@ -103,7 +103,7 @@ ifeq (OpenBSD,$(uname_S))
103
103
  EV_CONFIG=config_openbsd.h
104
104
  EIO_CONFIG=config_openbsd.h
105
105
  CPPFLAGS += -Isrc/ares/config_openbsd
106
- LINKFLAGS+=
106
+ LINKFLAGS+=-lkvm
107
107
  OBJS += src/unix/openbsd.o
108
108
  OBJS += src/unix/kqueue.o
109
109
  endif
@@ -131,14 +131,14 @@ endif
131
131
  RUNNER_LIBS=
132
132
  RUNNER_SRC=test/runner-unix.c
133
133
 
134
- uv.a: $(OBJS) src/uv-common.o src/unix/ev/ev.o src/unix/uv-eio.o src/unix/eio/eio.o $(CARES_OBJS)
135
- $(AR) rcs uv.a $(OBJS) src/uv-common.o src/unix/uv-eio.o src/unix/ev/ev.o src/unix/eio/eio.o $(CARES_OBJS)
134
+ uv.a: $(OBJS) src/cares.o src/fs-poll.o src/uv-common.o src/unix/ev/ev.o src/unix/uv-eio.o src/unix/eio/eio.o $(CARES_OBJS)
135
+ $(AR) rcs uv.a $^
136
136
 
137
- src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h
138
- $(CC) $(CSTDFLAG) $(CPPFLAGS) -Isrc $(CFLAGS) -c $< -o $@
137
+ src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h
138
+ $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
139
139
 
140
- src/uv-common.o: src/uv-common.c include/uv.h include/uv-private/uv-unix.h
141
- $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c src/uv-common.c -o src/uv-common.o
140
+ src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h
141
+ $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
142
142
 
143
143
  src/unix/ev/ev.o: src/unix/ev/ev.c
144
144
  $(CC) $(CPPFLAGS) $(CFLAGS) -c src/unix/ev/ev.c -o src/unix/ev/ev.o -DEV_CONFIG_H=\"$(EV_CONFIG)\"
@@ -8,7 +8,11 @@ script_dir = os.path.dirname(__file__)
8
8
  uv_root = os.path.normpath(script_dir)
9
9
 
10
10
  sys.path.insert(0, os.path.join(uv_root, 'build', 'gyp', 'pylib'))
11
- import gyp
11
+ try:
12
+ import gyp
13
+ except ImportError:
14
+ print('You need to install gyp in build/gyp first. See the README.')
15
+ sys.exit(42)
12
16
 
13
17
  # Directory within which we want all generated files (including Makefiles)
14
18
  # to be written.
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ FILE=$1
6
+
7
+ gcc $FILE ../uv.a -I../include/ -L../ -lm -lpthread -lrt -o /tmp/ibc_test_uv
8
+ /tmp/ibc_test_uv
@@ -0,0 +1,171 @@
1
+ /*
2
+ * Copy this file in libuv directory and run it as follows (Linux):
3
+ *
4
+ * In a second terminal run:
5
+ * nc -l 127.0.0.1 9999
6
+ *
7
+ * libuv reported issue: https://github.com/joyent/libuv/issues/445
8
+ * Status: FIXED.
9
+ *
10
+ */
11
+
12
+
13
+ #include "uv.h"
14
+ #include <stdio.h>
15
+ #include <stddef.h>
16
+ #include <stdint.h>
17
+ #include <stdlib.h>
18
+ #include <string.h>
19
+ #include <time.h>
20
+ #include <assert.h>
21
+
22
+
23
+ #define DEBUG(desc) fprintf(stdout, "DEBUG: %s:%d:%s:: %s\n", __FILE__, __LINE__, __FUNCTION__, desc)
24
+
25
+ #define SERVER_IP "127.0.0.1"
26
+ #define SERVER_PORT 9999
27
+
28
+
29
+ static uv_tcp_t tcp_client;
30
+ static uv_connect_t connect_req;
31
+ static uv_write_t write_req;
32
+ static uv_shutdown_t shutdown_req;
33
+ static uv_timer_t timer;
34
+
35
+ static tcp_connected = 0;
36
+
37
+ static void connect_cb(uv_connect_t* req, int status);
38
+ static void write_cb(uv_write_t* req, int status);
39
+ static void read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf);
40
+ static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size);
41
+ static void read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf);
42
+ static void shutdown_cb(uv_shutdown_t* req, int status);
43
+ static void timer_cb(uv_timer_t* handle, int status);
44
+ static void close_cb(uv_handle_t* handle);
45
+
46
+
47
+ static void connect_cb(uv_connect_t* req, int status)
48
+ {
49
+ uv_tcp_t* _uv_handle = (uv_tcp_t*)req->handle;
50
+
51
+ if (! status) {
52
+ DEBUG("connected");
53
+ tcp_connected = 1;
54
+ }
55
+ else {
56
+ DEBUG("connection failed, run 'nc -l SERVER_IP SERVER_PORT' first please...");
57
+ exit(0);
58
+ }
59
+ }
60
+
61
+
62
+ static void write_cb(uv_write_t* req, int status)
63
+ {
64
+ if (! status)
65
+ DEBUG("write ok");
66
+ else
67
+ DEBUG("write failed");
68
+ }
69
+
70
+
71
+ static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size)
72
+ {
73
+ static char buffer[1024];
74
+
75
+ DEBUG("called");
76
+
77
+ return uv_buf_init(buffer, sizeof(buffer));
78
+ }
79
+
80
+
81
+ static void read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf)
82
+ {
83
+ if (nread >= 0)
84
+ DEBUG("data received");
85
+ else {
86
+ DEBUG("disconnected, so exit()");
87
+ exit(0);
88
+ }
89
+ }
90
+
91
+
92
+ static void shutdown_cb(uv_shutdown_t* req, int status)
93
+ {
94
+ if (! status)
95
+ DEBUG("shutdown ok");
96
+ else {
97
+ DEBUG("shutdown failed, so exit()");
98
+ exit(0);
99
+ }
100
+
101
+ DEBUG("uv_close(tcp_client), will close_cb() be called?... (NOT !, WHY ?)");
102
+ uv_close((uv_handle_t *)&tcp_client, close_cb);
103
+ }
104
+
105
+
106
+ static void timer_cb(uv_timer_t* handle, int status)
107
+ {
108
+ int r;
109
+ char data[5] = "HELLO";
110
+ uv_buf_t buf;
111
+
112
+ DEBUG("timer fires");
113
+
114
+ if (! tcp_connected) {
115
+ DEBUG("tcp_client is not connected when timer fires, run 'nc -l SERVER_IP SERVER_PORT' first please...");
116
+ exit(0);
117
+ }
118
+
119
+ DEBUG("uv_close(timer), will close_cb() be called?... (NOT !, WHY ?)");
120
+ uv_close((uv_handle_t *)&timer, close_cb);
121
+
122
+ buf = uv_buf_init(data, 5);
123
+
124
+ r = uv_write(&write_req, (uv_stream_t *)&tcp_client,
125
+ &buf, 1, write_cb);
126
+ assert(r == 0);
127
+
128
+ r = uv_shutdown(&shutdown_req,
129
+ (uv_stream_t*)&tcp_client,
130
+ shutdown_cb);
131
+ assert(r == 0);
132
+ }
133
+
134
+
135
+ static void close_cb(uv_handle_t* handle)
136
+ {
137
+ DEBUG("handle closed");
138
+ }
139
+
140
+
141
+ int main(int argc, char* argv)
142
+ {
143
+ uv_loop_t* loop;
144
+ int r;
145
+
146
+ loop = uv_default_loop();
147
+ assert(loop != NULL);
148
+
149
+ r = uv_tcp_init(loop, &tcp_client);
150
+ assert(r == 0);
151
+
152
+ r = uv_tcp_connect(&connect_req,
153
+ &tcp_client,
154
+ uv_ip4_addr(SERVER_IP, SERVER_PORT),
155
+ connect_cb);
156
+ assert(r == 0);
157
+
158
+ r = uv_read_start((uv_stream_t*)&tcp_client,
159
+ alloc_cb, read_cb);
160
+
161
+ r = uv_timer_init(loop, &timer);
162
+ assert(r == 0);
163
+
164
+ uv_timer_start(&timer, timer_cb, 1000, 0);
165
+ assert(r == 0);
166
+
167
+ r = uv_run(loop);
168
+ assert(r == 0);
169
+
170
+ return 0;
171
+ }
@@ -0,0 +1,102 @@
1
+ /*
2
+ * libuv reported issue: https://github.com/joyent/libuv/issues/448
3
+ * Status: PENDING.
4
+ *
5
+ */
6
+
7
+
8
+ #include "uv.h"
9
+ #include <stdio.h>
10
+ #include <stddef.h>
11
+ #include <stdint.h>
12
+ #include <stdlib.h>
13
+ #include <string.h>
14
+ #include <assert.h>
15
+
16
+
17
+ #define DEBUG(desc) fprintf(stdout, "DEBUG: %s:%d:%s:: %s\n", __FILE__, __LINE__, __FUNCTION__, desc)
18
+
19
+
20
+ static uv_loop_t* loop;
21
+ static uv_tcp_t tcp_client;
22
+ static uv_connect_t connect_req;
23
+ static uv_timer_t timer1;
24
+ static uv_timer_t timer2;
25
+
26
+ static void connect_cb(uv_connect_t* req, int status);
27
+ static void timer1_cb(uv_timer_t* handle, int status);
28
+ static void timer2_cb(uv_timer_t* handle, int status);
29
+
30
+ static void tcp_close_cb(uv_handle_t* handle) { DEBUG("tcp handle closed"); }
31
+ static void timer1_close_cb(uv_handle_t* handle) { DEBUG("timer 1 handle closed"); }
32
+ static void timer2_close_cb(uv_handle_t* handle) { DEBUG("timer 2 handle closed"); }
33
+
34
+
35
+ static void connect_cb(uv_connect_t* req, int status)
36
+ {
37
+ if (! status) {
38
+ DEBUG("connected to 1.2.3.4:9999? really???");
39
+ exit(1);
40
+ }
41
+ else {
42
+ DEBUG("connection failed or interrupted");
43
+ printf("... uv last error code: %d\n", uv_last_error(loop).code);
44
+ }
45
+ }
46
+
47
+
48
+ /* timer 1 calls to uv_close() for the TCP handle, which SHOULD provoke the
49
+ * connect_cb() with error status right now.
50
+ */
51
+ static void timer1_cb(uv_timer_t* handle, int status)
52
+ {
53
+ DEBUG("timer 1 fires, calling uv_close() for timer 1 and for tcp handle, connect_cb(EINTR) should be called now !!!");
54
+ uv_close((uv_handle_t *)&timer1, timer1_close_cb);
55
+ uv_close((uv_handle_t *)&tcp_client, tcp_close_cb);
56
+ }
57
+
58
+
59
+ static void timer2_cb(uv_timer_t* handle, int status)
60
+ {
61
+ DEBUG("timer 2 fires, calling uv_close() for timer 2... OPPS, connect_cb(EINTR) is called now (so late...), WHY ???");
62
+ uv_close((uv_handle_t *)&timer2, timer2_close_cb);
63
+ }
64
+
65
+
66
+ int main(int argc, char* argv)
67
+ {
68
+ int r;
69
+
70
+ loop = uv_default_loop();
71
+ assert(loop != NULL);
72
+
73
+ r = uv_tcp_init(loop, &tcp_client);
74
+ assert(r == 0);
75
+
76
+ DEBUG("connecting to 1.2.3.4:9999...");
77
+ r = uv_tcp_connect(&connect_req,
78
+ &tcp_client,
79
+ uv_ip4_addr("1.2.3.4", 9999),
80
+ connect_cb);
81
+ assert(r == 0);
82
+
83
+ r = uv_timer_init(loop, &timer1);
84
+ assert(r == 0);
85
+
86
+ DEBUG("timer 1 will fire in 3 seconds and will call uv_close(tcp handle)...");
87
+ uv_timer_start(&timer1, timer1_cb, 3000, 0);
88
+ assert(r == 0);
89
+
90
+ r = uv_timer_init(loop, &timer2);
91
+ assert(r == 0);
92
+
93
+ DEBUG("timer 2 will fire in 6 seconds and will do nothing but demonstrate the bug...");
94
+ uv_timer_start(&timer2, timer2_cb, 6000, 0);
95
+ assert(r == 0);
96
+
97
+ DEBUG("loop started");
98
+ r = uv_run(loop);
99
+ assert(r == 0);
100
+
101
+ return 0;
102
+ }