sidekick-client 0.1.0

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 (247) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +52 -0
  6. data/VERSION +1 -0
  7. data/lib/ext/README +1 -0
  8. data/lib/ext/bunny-0.6.0/LICENSE +20 -0
  9. data/lib/ext/bunny-0.6.0/README.rdoc +66 -0
  10. data/lib/ext/bunny-0.6.0/Rakefile +24 -0
  11. data/lib/ext/bunny-0.6.0/bunny.gemspec +65 -0
  12. data/lib/ext/bunny-0.6.0/examples/simple_08.rb +30 -0
  13. data/lib/ext/bunny-0.6.0/examples/simple_09.rb +30 -0
  14. data/lib/ext/bunny-0.6.0/examples/simple_ack_08.rb +33 -0
  15. data/lib/ext/bunny-0.6.0/examples/simple_ack_09.rb +33 -0
  16. data/lib/ext/bunny-0.6.0/examples/simple_consumer_08.rb +53 -0
  17. data/lib/ext/bunny-0.6.0/examples/simple_consumer_09.rb +53 -0
  18. data/lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb +39 -0
  19. data/lib/ext/bunny-0.6.0/examples/simple_fanout_09.rb +39 -0
  20. data/lib/ext/bunny-0.6.0/examples/simple_headers_08.rb +40 -0
  21. data/lib/ext/bunny-0.6.0/examples/simple_headers_09.rb +40 -0
  22. data/lib/ext/bunny-0.6.0/examples/simple_publisher_08.rb +27 -0
  23. data/lib/ext/bunny-0.6.0/examples/simple_publisher_09.rb +27 -0
  24. data/lib/ext/bunny-0.6.0/examples/simple_topic_08.rb +59 -0
  25. data/lib/ext/bunny-0.6.0/examples/simple_topic_09.rb +59 -0
  26. data/lib/ext/bunny-0.6.0/lib/bunny/channel08.rb +39 -0
  27. data/lib/ext/bunny-0.6.0/lib/bunny/channel09.rb +39 -0
  28. data/lib/ext/bunny-0.6.0/lib/bunny/client08.rb +494 -0
  29. data/lib/ext/bunny-0.6.0/lib/bunny/client09.rb +460 -0
  30. data/lib/ext/bunny-0.6.0/lib/bunny/exchange08.rb +175 -0
  31. data/lib/ext/bunny-0.6.0/lib/bunny/exchange09.rb +177 -0
  32. data/lib/ext/bunny-0.6.0/lib/bunny/queue08.rb +389 -0
  33. data/lib/ext/bunny-0.6.0/lib/bunny/queue09.rb +395 -0
  34. data/lib/ext/bunny-0.6.0/lib/bunny/subscription08.rb +85 -0
  35. data/lib/ext/bunny-0.6.0/lib/bunny/subscription09.rb +85 -0
  36. data/lib/ext/bunny-0.6.0/lib/bunny.rb +87 -0
  37. data/lib/ext/bunny-0.6.0/lib/qrack/channel.rb +18 -0
  38. data/lib/ext/bunny-0.6.0/lib/qrack/client.rb +204 -0
  39. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/protocol08.rb +132 -0
  40. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/protocol09.rb +133 -0
  41. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/spec08.rb +823 -0
  42. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/spec09.rb +521 -0
  43. data/lib/ext/bunny-0.6.0/lib/qrack/qrack08.rb +23 -0
  44. data/lib/ext/bunny-0.6.0/lib/qrack/qrack09.rb +23 -0
  45. data/lib/ext/bunny-0.6.0/lib/qrack/queue.rb +53 -0
  46. data/lib/ext/bunny-0.6.0/lib/qrack/subscription.rb +102 -0
  47. data/lib/ext/bunny-0.6.0/lib/qrack/transport/buffer08.rb +276 -0
  48. data/lib/ext/bunny-0.6.0/lib/qrack/transport/buffer09.rb +276 -0
  49. data/lib/ext/bunny-0.6.0/lib/qrack/transport/frame08.rb +112 -0
  50. data/lib/ext/bunny-0.6.0/lib/qrack/transport/frame09.rb +94 -0
  51. data/lib/ext/bunny-0.6.0/spec/spec_08/bunny_spec.rb +65 -0
  52. data/lib/ext/bunny-0.6.0/spec/spec_08/connection_spec.rb +12 -0
  53. data/lib/ext/bunny-0.6.0/spec/spec_08/exchange_spec.rb +162 -0
  54. data/lib/ext/bunny-0.6.0/spec/spec_08/queue_spec.rb +206 -0
  55. data/lib/ext/bunny-0.6.0/spec/spec_09/bunny_spec.rb +65 -0
  56. data/lib/ext/bunny-0.6.0/spec/spec_09/connection_spec.rb +12 -0
  57. data/lib/ext/bunny-0.6.0/spec/spec_09/exchange_spec.rb +162 -0
  58. data/lib/ext/bunny-0.6.0/spec/spec_09/queue_spec.rb +205 -0
  59. data/lib/ext/eventmachine-0.12.10/.gitignore +14 -0
  60. data/lib/ext/eventmachine-0.12.10/README +82 -0
  61. data/lib/ext/eventmachine-0.12.10/Rakefile +374 -0
  62. data/lib/ext/eventmachine-0.12.10/docs/COPYING +60 -0
  63. data/lib/ext/eventmachine-0.12.10/docs/ChangeLog +211 -0
  64. data/lib/ext/eventmachine-0.12.10/docs/DEFERRABLES +133 -0
  65. data/lib/ext/eventmachine-0.12.10/docs/EPOLL +141 -0
  66. data/lib/ext/eventmachine-0.12.10/docs/GNU +281 -0
  67. data/lib/ext/eventmachine-0.12.10/docs/INSTALL +13 -0
  68. data/lib/ext/eventmachine-0.12.10/docs/KEYBOARD +38 -0
  69. data/lib/ext/eventmachine-0.12.10/docs/LEGAL +25 -0
  70. data/lib/ext/eventmachine-0.12.10/docs/LIGHTWEIGHT_CONCURRENCY +70 -0
  71. data/lib/ext/eventmachine-0.12.10/docs/PURE_RUBY +75 -0
  72. data/lib/ext/eventmachine-0.12.10/docs/RELEASE_NOTES +94 -0
  73. data/lib/ext/eventmachine-0.12.10/docs/SMTP +2 -0
  74. data/lib/ext/eventmachine-0.12.10/docs/SPAWNED_PROCESSES +89 -0
  75. data/lib/ext/eventmachine-0.12.10/docs/TODO +8 -0
  76. data/lib/ext/eventmachine-0.12.10/eventmachine.gemspec +40 -0
  77. data/lib/ext/eventmachine-0.12.10/examples/ex_channel.rb +43 -0
  78. data/lib/ext/eventmachine-0.12.10/examples/ex_queue.rb +2 -0
  79. data/lib/ext/eventmachine-0.12.10/examples/helper.rb +2 -0
  80. data/lib/ext/eventmachine-0.12.10/ext/binder.cpp +125 -0
  81. data/lib/ext/eventmachine-0.12.10/ext/binder.h +46 -0
  82. data/lib/ext/eventmachine-0.12.10/ext/cmain.cpp +827 -0
  83. data/lib/ext/eventmachine-0.12.10/ext/cplusplus.cpp +202 -0
  84. data/lib/ext/eventmachine-0.12.10/ext/ed.cpp +1893 -0
  85. data/lib/ext/eventmachine-0.12.10/ext/ed.h +424 -0
  86. data/lib/ext/eventmachine-0.12.10/ext/em.cpp +2282 -0
  87. data/lib/ext/eventmachine-0.12.10/ext/em.h +232 -0
  88. data/lib/ext/eventmachine-0.12.10/ext/emwin.cpp +300 -0
  89. data/lib/ext/eventmachine-0.12.10/ext/emwin.h +94 -0
  90. data/lib/ext/eventmachine-0.12.10/ext/epoll.cpp +26 -0
  91. data/lib/ext/eventmachine-0.12.10/ext/epoll.h +25 -0
  92. data/lib/ext/eventmachine-0.12.10/ext/eventmachine.h +122 -0
  93. data/lib/ext/eventmachine-0.12.10/ext/eventmachine_cpp.h +96 -0
  94. data/lib/ext/eventmachine-0.12.10/ext/extconf.rb +148 -0
  95. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/extconf.rb +83 -0
  96. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.cpp +214 -0
  97. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.h +59 -0
  98. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/rubymain.cpp +127 -0
  99. data/lib/ext/eventmachine-0.12.10/ext/files.cpp +94 -0
  100. data/lib/ext/eventmachine-0.12.10/ext/files.h +65 -0
  101. data/lib/ext/eventmachine-0.12.10/ext/kb.cpp +81 -0
  102. data/lib/ext/eventmachine-0.12.10/ext/page.cpp +107 -0
  103. data/lib/ext/eventmachine-0.12.10/ext/page.h +51 -0
  104. data/lib/ext/eventmachine-0.12.10/ext/pipe.cpp +349 -0
  105. data/lib/ext/eventmachine-0.12.10/ext/project.h +151 -0
  106. data/lib/ext/eventmachine-0.12.10/ext/rubymain.cpp +1166 -0
  107. data/lib/ext/eventmachine-0.12.10/ext/sigs.cpp +89 -0
  108. data/lib/ext/eventmachine-0.12.10/ext/sigs.h +32 -0
  109. data/lib/ext/eventmachine-0.12.10/ext/ssl.cpp +460 -0
  110. data/lib/ext/eventmachine-0.12.10/ext/ssl.h +94 -0
  111. data/lib/ext/eventmachine-0.12.10/java/.classpath +8 -0
  112. data/lib/ext/eventmachine-0.12.10/java/.project +17 -0
  113. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactor.java +570 -0
  114. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  115. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
  116. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
  117. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
  118. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Application.java +194 -0
  119. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Connection.java +74 -0
  120. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/ConnectionFactory.java +37 -0
  121. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +46 -0
  122. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/PeriodicTimer.java +38 -0
  123. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Timer.java +54 -0
  124. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -0
  125. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -0
  126. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  127. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  128. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestServers.java +75 -0
  129. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -0
  130. data/lib/ext/eventmachine-0.12.10/lib/em/buftok.rb +138 -0
  131. data/lib/ext/eventmachine-0.12.10/lib/em/callback.rb +26 -0
  132. data/lib/ext/eventmachine-0.12.10/lib/em/channel.rb +57 -0
  133. data/lib/ext/eventmachine-0.12.10/lib/em/connection.rb +564 -0
  134. data/lib/ext/eventmachine-0.12.10/lib/em/deferrable.rb +192 -0
  135. data/lib/ext/eventmachine-0.12.10/lib/em/file_watch.rb +54 -0
  136. data/lib/ext/eventmachine-0.12.10/lib/em/future.rb +61 -0
  137. data/lib/ext/eventmachine-0.12.10/lib/em/messages.rb +66 -0
  138. data/lib/ext/eventmachine-0.12.10/lib/em/process_watch.rb +44 -0
  139. data/lib/ext/eventmachine-0.12.10/lib/em/processes.rb +119 -0
  140. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/header_and_content.rb +138 -0
  141. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient.rb +263 -0
  142. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient2.rb +590 -0
  143. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/line_and_text.rb +125 -0
  144. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/linetext2.rb +161 -0
  145. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/memcache.rb +323 -0
  146. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/object_protocol.rb +45 -0
  147. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/postgres3.rb +247 -0
  148. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/saslauth.rb +175 -0
  149. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpclient.rb +357 -0
  150. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpserver.rb +547 -0
  151. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/socks4.rb +66 -0
  152. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/stomp.rb +200 -0
  153. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/tcptest.rb +53 -0
  154. data/lib/ext/eventmachine-0.12.10/lib/em/protocols.rb +36 -0
  155. data/lib/ext/eventmachine-0.12.10/lib/em/queue.rb +61 -0
  156. data/lib/ext/eventmachine-0.12.10/lib/em/spawnable.rb +85 -0
  157. data/lib/ext/eventmachine-0.12.10/lib/em/streamer.rb +130 -0
  158. data/lib/ext/eventmachine-0.12.10/lib/em/timers.rb +56 -0
  159. data/lib/ext/eventmachine-0.12.10/lib/em/version.rb +3 -0
  160. data/lib/ext/eventmachine-0.12.10/lib/eventmachine.rb +1592 -0
  161. data/lib/ext/eventmachine-0.12.10/lib/evma/callback.rb +32 -0
  162. data/lib/ext/eventmachine-0.12.10/lib/evma/container.rb +75 -0
  163. data/lib/ext/eventmachine-0.12.10/lib/evma/factory.rb +77 -0
  164. data/lib/ext/eventmachine-0.12.10/lib/evma/protocol.rb +87 -0
  165. data/lib/ext/eventmachine-0.12.10/lib/evma/reactor.rb +48 -0
  166. data/lib/ext/eventmachine-0.12.10/lib/evma.rb +32 -0
  167. data/lib/ext/eventmachine-0.12.10/lib/jeventmachine.rb +257 -0
  168. data/lib/ext/eventmachine-0.12.10/lib/pr_eventmachine.rb +1022 -0
  169. data/lib/ext/eventmachine-0.12.10/setup.rb +1585 -0
  170. data/lib/ext/eventmachine-0.12.10/tasks/cpp.rake_example +77 -0
  171. data/lib/ext/eventmachine-0.12.10/tests/client.crt +31 -0
  172. data/lib/ext/eventmachine-0.12.10/tests/client.key +51 -0
  173. data/lib/ext/eventmachine-0.12.10/tests/test_attach.rb +126 -0
  174. data/lib/ext/eventmachine-0.12.10/tests/test_basic.rb +284 -0
  175. data/lib/ext/eventmachine-0.12.10/tests/test_channel.rb +63 -0
  176. data/lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb +35 -0
  177. data/lib/ext/eventmachine-0.12.10/tests/test_defer.rb +47 -0
  178. data/lib/ext/eventmachine-0.12.10/tests/test_epoll.rb +160 -0
  179. data/lib/ext/eventmachine-0.12.10/tests/test_error_handler.rb +35 -0
  180. data/lib/ext/eventmachine-0.12.10/tests/test_errors.rb +82 -0
  181. data/lib/ext/eventmachine-0.12.10/tests/test_exc.rb +55 -0
  182. data/lib/ext/eventmachine-0.12.10/tests/test_file_watch.rb +49 -0
  183. data/lib/ext/eventmachine-0.12.10/tests/test_futures.rb +198 -0
  184. data/lib/ext/eventmachine-0.12.10/tests/test_get_sock_opt.rb +30 -0
  185. data/lib/ext/eventmachine-0.12.10/tests/test_handler_check.rb +37 -0
  186. data/lib/ext/eventmachine-0.12.10/tests/test_hc.rb +218 -0
  187. data/lib/ext/eventmachine-0.12.10/tests/test_httpclient.rb +218 -0
  188. data/lib/ext/eventmachine-0.12.10/tests/test_httpclient2.rb +153 -0
  189. data/lib/ext/eventmachine-0.12.10/tests/test_inactivity_timeout.rb +50 -0
  190. data/lib/ext/eventmachine-0.12.10/tests/test_kb.rb +60 -0
  191. data/lib/ext/eventmachine-0.12.10/tests/test_ltp.rb +182 -0
  192. data/lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb +317 -0
  193. data/lib/ext/eventmachine-0.12.10/tests/test_next_tick.rb +133 -0
  194. data/lib/ext/eventmachine-0.12.10/tests/test_object_protocol.rb +37 -0
  195. data/lib/ext/eventmachine-0.12.10/tests/test_pause.rb +70 -0
  196. data/lib/ext/eventmachine-0.12.10/tests/test_pending_connect_timeout.rb +48 -0
  197. data/lib/ext/eventmachine-0.12.10/tests/test_process_watch.rb +48 -0
  198. data/lib/ext/eventmachine-0.12.10/tests/test_processes.rb +128 -0
  199. data/lib/ext/eventmachine-0.12.10/tests/test_proxy_connection.rb +92 -0
  200. data/lib/ext/eventmachine-0.12.10/tests/test_pure.rb +125 -0
  201. data/lib/ext/eventmachine-0.12.10/tests/test_queue.rb +44 -0
  202. data/lib/ext/eventmachine-0.12.10/tests/test_running.rb +42 -0
  203. data/lib/ext/eventmachine-0.12.10/tests/test_sasl.rb +72 -0
  204. data/lib/ext/eventmachine-0.12.10/tests/test_send_file.rb +242 -0
  205. data/lib/ext/eventmachine-0.12.10/tests/test_servers.rb +76 -0
  206. data/lib/ext/eventmachine-0.12.10/tests/test_smtpclient.rb +83 -0
  207. data/lib/ext/eventmachine-0.12.10/tests/test_smtpserver.rb +85 -0
  208. data/lib/ext/eventmachine-0.12.10/tests/test_spawn.rb +322 -0
  209. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_args.rb +79 -0
  210. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_methods.rb +50 -0
  211. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_verify.rb +82 -0
  212. data/lib/ext/eventmachine-0.12.10/tests/test_timers.rb +162 -0
  213. data/lib/ext/eventmachine-0.12.10/tests/test_ud.rb +36 -0
  214. data/lib/ext/eventmachine-0.12.10/tests/testem.rb +31 -0
  215. data/lib/ext/eventmachine-0.12.10/web/whatis +7 -0
  216. data/lib/ext/misc/README +1 -0
  217. data/lib/ext/misc/indifferent_access.rb +131 -0
  218. data/lib/ext/uuidtools-2.1.1/CHANGELOG +56 -0
  219. data/lib/ext/uuidtools-2.1.1/LICENSE +20 -0
  220. data/lib/ext/uuidtools-2.1.1/README +13 -0
  221. data/lib/ext/uuidtools-2.1.1/Rakefile +48 -0
  222. data/lib/ext/uuidtools-2.1.1/lib/compat/securerandom.rb +202 -0
  223. data/lib/ext/uuidtools-2.1.1/lib/uuidtools/version.rb +35 -0
  224. data/lib/ext/uuidtools-2.1.1/lib/uuidtools.rb +618 -0
  225. data/lib/ext/uuidtools-2.1.1/spec/spec.opts +1 -0
  226. data/lib/ext/uuidtools-2.1.1/spec/spec_helper.rb +7 -0
  227. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/mac_address_spec.rb +15 -0
  228. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/utility_spec.rb +21 -0
  229. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/uuid_creation_spec.rb +121 -0
  230. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/uuid_parsing_spec.rb +127 -0
  231. data/lib/ext/uuidtools-2.1.1/tasks/benchmark.rake +38 -0
  232. data/lib/ext/uuidtools-2.1.1/tasks/clobber.rake +2 -0
  233. data/lib/ext/uuidtools-2.1.1/tasks/gem.rake +68 -0
  234. data/lib/ext/uuidtools-2.1.1/tasks/git.rake +40 -0
  235. data/lib/ext/uuidtools-2.1.1/tasks/metrics.rake +22 -0
  236. data/lib/ext/uuidtools-2.1.1/tasks/rdoc.rake +29 -0
  237. data/lib/ext/uuidtools-2.1.1/tasks/rubyforge.rake +89 -0
  238. data/lib/ext/uuidtools-2.1.1/tasks/spec.rake +64 -0
  239. data/lib/ext/uuidtools-2.1.1/website/index.html +95 -0
  240. data/lib/sidekick/client/sidekick_client.rb +46 -0
  241. data/lib/sidekick/shared/sidekick_logger.rb +14 -0
  242. data/lib/sidekick/shared/sidekick_queue_publisher.rb +91 -0
  243. data/lib/sidekick-client.rb +7 -0
  244. data/sidekick-client.gemspec +289 -0
  245. data/test/helper.rb +10 -0
  246. data/test/test_sidekick-client.rb +7 -0
  247. metadata +311 -0
@@ -0,0 +1,151 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: project.h
6
+ Date: 06Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+
21
+ #ifndef __Project__H_
22
+ #define __Project__H_
23
+
24
+
25
+ #ifdef OS_WIN32
26
+ #pragma warning(disable:4786)
27
+ #endif
28
+
29
+ #include <iostream>
30
+ #include <map>
31
+ #include <set>
32
+ #include <vector>
33
+ #include <deque>
34
+ #include <string>
35
+ #include <sstream>
36
+ #include <stdexcept>
37
+
38
+
39
+ #ifdef OS_UNIX
40
+ #include <signal.h>
41
+ #include <netdb.h>
42
+ #include <time.h>
43
+ #include <sys/time.h>
44
+ #include <sys/types.h>
45
+ #include <sys/stat.h>
46
+ #include <sys/socket.h>
47
+ #include <sys/un.h>
48
+ #include <sys/resource.h>
49
+ #include <sys/wait.h>
50
+ #include <assert.h>
51
+ #include <unistd.h>
52
+ #include <fcntl.h>
53
+ #include <errno.h>
54
+ #include <netinet/in.h>
55
+ #include <netinet/tcp.h>
56
+ #include <arpa/inet.h>
57
+ #include <pwd.h>
58
+ typedef int SOCKET;
59
+ #define closesocket close
60
+ #define INVALID_SOCKET -1
61
+ #define SOCKET_ERROR -1
62
+ #ifdef OS_SOLARIS8
63
+ #include <strings.h>
64
+ #include <sys/un.h>
65
+ #ifndef AF_LOCAL
66
+ #define AF_LOCAL AF_UNIX
67
+ #endif
68
+ // INADDR_NONE is undefined on Solaris < 8. Thanks to Brett Eisenberg and Tim Pease.
69
+ #ifndef INADDR_NONE
70
+ #define INADDR_NONE ((unsigned long)-1)
71
+ #endif
72
+ #endif /* OS_SOLARIS8 */
73
+
74
+ #ifdef _AIX
75
+ #include <strings.h>
76
+ #ifndef AF_LOCAL
77
+ #define AF_LOCAL AF_UNIX
78
+ #endif
79
+ #endif /* _AIX */
80
+
81
+ #endif /* OS_UNIX */
82
+
83
+ #ifdef OS_WIN32
84
+ // 21Sep09: windows limits select() to 64 sockets by default, we increase it to 1024 here (before including winsock2.h)
85
+ #define FD_SETSIZE 1024
86
+
87
+ #define WIN32_LEAN_AND_MEAN
88
+ #include <windows.h>
89
+ #include <winsock2.h>
90
+ #include <ws2tcpip.h>
91
+ #include <rpc.h>
92
+ #include <fcntl.h>
93
+ #include <assert.h>
94
+
95
+ typedef int socklen_t;
96
+ typedef int pid_t;
97
+ #endif
98
+
99
+
100
+ using namespace std;
101
+
102
+ #ifdef WITH_SSL
103
+ #include <openssl/ssl.h>
104
+ #include <openssl/err.h>
105
+ #endif
106
+
107
+ #ifdef HAVE_EPOLL
108
+ #include <sys/epoll.h>
109
+ #endif
110
+
111
+ #ifdef HAVE_KQUEUE
112
+ #include <sys/event.h>
113
+ #include <sys/queue.h>
114
+ #endif
115
+
116
+ #ifdef HAVE_INOTIFY
117
+ #include <sys/inotify.h>
118
+ #endif
119
+
120
+ #ifdef HAVE_OLD_INOTIFY
121
+ #include <sys/syscall.h>
122
+ #include <linux/inotify.h>
123
+ static inline int inotify_init (void) { return syscall (__NR_inotify_init); }
124
+ static inline int inotify_add_watch (int fd, const char *name, __u32 mask) { return syscall (__NR_inotify_add_watch, fd, name, mask); }
125
+ static inline int inotify_rm_watch (int fd, __u32 wd) { return syscall (__NR_inotify_rm_watch, fd, wd); }
126
+ #define HAVE_INOTIFY 1
127
+ #endif
128
+
129
+ #ifdef HAVE_INOTIFY
130
+ #define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event))
131
+ #endif
132
+
133
+ #ifdef HAVE_WRITEV
134
+ #include <sys/uio.h>
135
+ #endif
136
+
137
+ #include "binder.h"
138
+ #include "em.h"
139
+ #include "epoll.h"
140
+ #include "sigs.h"
141
+ #include "ed.h"
142
+ #include "files.h"
143
+ #include "page.h"
144
+ #include "ssl.h"
145
+ #include "eventmachine.h"
146
+ #include "eventmachine_cpp.h"
147
+
148
+
149
+
150
+
151
+ #endif // __Project__H_
@@ -0,0 +1,1166 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: rubymain.cpp
6
+ Date: 06Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #include "project.h"
21
+ #include "eventmachine.h"
22
+ #include <ruby.h>
23
+
24
+ #ifndef RFLOAT_VALUE
25
+ #define RFLOAT_VALUE(arg) RFLOAT(arg)->value
26
+ #endif
27
+
28
+ /*******
29
+ Statics
30
+ *******/
31
+
32
+ static VALUE EmModule;
33
+ static VALUE EmConnection;
34
+
35
+ static VALUE EM_eConnectionError;
36
+ static VALUE EM_eUnknownTimerFired;
37
+ static VALUE EM_eConnectionNotBound;
38
+ static VALUE EM_eUnsupported;
39
+
40
+ static VALUE Intern_at_signature;
41
+ static VALUE Intern_at_timers;
42
+ static VALUE Intern_at_conns;
43
+ static VALUE Intern_at_error_handler;
44
+ static VALUE Intern_event_callback;
45
+ static VALUE Intern_run_deferred_callbacks;
46
+ static VALUE Intern_delete;
47
+ static VALUE Intern_call;
48
+ static VALUE Intern_receive_data;
49
+ static VALUE Intern_ssl_handshake_completed;
50
+ static VALUE Intern_ssl_verify_peer;
51
+ static VALUE Intern_notify_readable;
52
+ static VALUE Intern_notify_writable;
53
+ static VALUE Intern_proxy_target_unbound;
54
+
55
+ static VALUE rb_cProcStatus;
56
+
57
+ struct em_event {
58
+ unsigned long a1;
59
+ int a2;
60
+ const char *a3;
61
+ unsigned long a4;
62
+ };
63
+
64
+ /****************
65
+ t_event_callback
66
+ ****************/
67
+
68
+ static void event_callback (struct em_event* e)
69
+ {
70
+ const unsigned long a1 = e->a1;
71
+ int a2 = e->a2;
72
+ const char *a3 = e->a3;
73
+ const unsigned long a4 = e->a4;
74
+
75
+ if (a2 == EM_CONNECTION_READ) {
76
+ VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
77
+ VALUE q = rb_hash_aref (t, ULONG2NUM (a1));
78
+ if (q == Qnil)
79
+ rb_raise (EM_eConnectionNotBound, "received %lu bytes of data for unknown signature: %lu", a4, a1);
80
+ rb_funcall (q, Intern_receive_data, 1, rb_str_new (a3, a4));
81
+ }
82
+ else if (a2 == EM_CONNECTION_NOTIFY_READABLE) {
83
+ VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
84
+ VALUE q = rb_hash_aref (t, ULONG2NUM (a1));
85
+ if (q == Qnil)
86
+ rb_raise (EM_eConnectionNotBound, "unknown connection: %lu", a1);
87
+ rb_funcall (q, Intern_notify_readable, 0);
88
+ }
89
+ else if (a2 == EM_CONNECTION_NOTIFY_WRITABLE) {
90
+ VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
91
+ VALUE q = rb_hash_aref (t, ULONG2NUM (a1));
92
+ if (q == Qnil)
93
+ rb_raise (EM_eConnectionNotBound, "unknown connection: %lu", a1);
94
+ rb_funcall (q, Intern_notify_writable, 0);
95
+ }
96
+ else if (a2 == EM_LOOPBREAK_SIGNAL) {
97
+ rb_funcall (EmModule, Intern_run_deferred_callbacks, 0);
98
+ }
99
+ else if (a2 == EM_TIMER_FIRED) {
100
+ VALUE t = rb_ivar_get (EmModule, Intern_at_timers);
101
+ VALUE q = rb_funcall (t, Intern_delete, 1, ULONG2NUM (a4));
102
+ if (q == Qnil) {
103
+ rb_raise (EM_eUnknownTimerFired, "no such timer: %lu", a4);
104
+ } else if (q == Qfalse) {
105
+ /* Timer Canceled */
106
+ } else {
107
+ rb_funcall (q, Intern_call, 0);
108
+ }
109
+ }
110
+ #ifdef WITH_SSL
111
+ else if (a2 == EM_SSL_HANDSHAKE_COMPLETED) {
112
+ VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
113
+ VALUE q = rb_hash_aref (t, ULONG2NUM (a1));
114
+ if (q == Qnil)
115
+ rb_raise (EM_eConnectionNotBound, "unknown connection: %lu", a1);
116
+ rb_funcall (q, Intern_ssl_handshake_completed, 0);
117
+ }
118
+ else if (a2 == EM_SSL_VERIFY) {
119
+ VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
120
+ VALUE q = rb_hash_aref (t, ULONG2NUM (a1));
121
+ if (q == Qnil)
122
+ rb_raise (EM_eConnectionNotBound, "unknown connection: %lu", a1);
123
+ VALUE r = rb_funcall (q, Intern_ssl_verify_peer, 1, rb_str_new(a3, a4));
124
+ if (RTEST(r))
125
+ evma_accept_ssl_peer (a1);
126
+ }
127
+ #endif
128
+ else if (a2 == EM_PROXY_TARGET_UNBOUND) {
129
+ VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
130
+ VALUE q = rb_hash_aref (t, ULONG2NUM (a1));
131
+ if (q == Qnil)
132
+ rb_raise (EM_eConnectionNotBound, "unknown connection: %lu", a1);
133
+ rb_funcall (q, Intern_proxy_target_unbound, 0);
134
+ }
135
+ else
136
+ rb_funcall (EmModule, Intern_event_callback, 3, ULONG2NUM(a1), INT2FIX(a2), a3 ? rb_str_new(a3,a4) : ULONG2NUM(a4));
137
+ }
138
+
139
+ /*******************
140
+ event_error_handler
141
+ *******************/
142
+
143
+ static void event_error_handler(VALUE unused, VALUE err)
144
+ {
145
+ VALUE error_handler = rb_ivar_get(EmModule, Intern_at_error_handler);
146
+ rb_funcall (error_handler, Intern_call, 1, err);
147
+ }
148
+
149
+ /**********************
150
+ event_callback_wrapper
151
+ **********************/
152
+
153
+ static void event_callback_wrapper (const unsigned long a1, int a2, const char *a3, const unsigned long a4)
154
+ {
155
+ struct em_event e;
156
+ e.a1 = a1;
157
+ e.a2 = a2;
158
+ e.a3 = a3;
159
+ e.a4 = a4;
160
+
161
+ if (!rb_ivar_defined(EmModule, Intern_at_error_handler))
162
+ event_callback(&e);
163
+ else
164
+ rb_rescue((VALUE (*)(ANYARGS))event_callback, (VALUE)&e, (VALUE (*)(ANYARGS))event_error_handler, Qnil);
165
+ }
166
+
167
+ /**************************
168
+ t_initialize_event_machine
169
+ **************************/
170
+
171
+ static VALUE t_initialize_event_machine (VALUE self)
172
+ {
173
+ evma_initialize_library (event_callback_wrapper);
174
+ return Qnil;
175
+ }
176
+
177
+
178
+
179
+ /*****************************
180
+ t_run_machine_without_threads
181
+ *****************************/
182
+
183
+ static VALUE t_run_machine_without_threads (VALUE self)
184
+ {
185
+ evma_run_machine();
186
+ return Qnil;
187
+ }
188
+
189
+
190
+ /*******************
191
+ t_add_oneshot_timer
192
+ *******************/
193
+
194
+ static VALUE t_add_oneshot_timer (VALUE self, VALUE interval)
195
+ {
196
+ const unsigned long f = evma_install_oneshot_timer (FIX2INT (interval));
197
+ if (!f)
198
+ rb_raise (rb_eRuntimeError, "ran out of timers; use #set_max_timers to increase limit");
199
+ return ULONG2NUM (f);
200
+ }
201
+
202
+
203
+ /**************
204
+ t_start_server
205
+ **************/
206
+
207
+ static VALUE t_start_server (VALUE self, VALUE server, VALUE port)
208
+ {
209
+ const unsigned long f = evma_create_tcp_server (StringValuePtr(server), FIX2INT(port));
210
+ if (!f)
211
+ rb_raise (rb_eRuntimeError, "no acceptor");
212
+ return ULONG2NUM (f);
213
+ }
214
+
215
+ /*************
216
+ t_stop_server
217
+ *************/
218
+
219
+ static VALUE t_stop_server (VALUE self, VALUE signature)
220
+ {
221
+ evma_stop_tcp_server (NUM2ULONG (signature));
222
+ return Qnil;
223
+ }
224
+
225
+
226
+ /*******************
227
+ t_start_unix_server
228
+ *******************/
229
+
230
+ static VALUE t_start_unix_server (VALUE self, VALUE filename)
231
+ {
232
+ const unsigned long f = evma_create_unix_domain_server (StringValuePtr(filename));
233
+ if (!f)
234
+ rb_raise (rb_eRuntimeError, "no unix-domain acceptor");
235
+ return ULONG2NUM (f);
236
+ }
237
+
238
+
239
+
240
+ /***********
241
+ t_send_data
242
+ ***********/
243
+
244
+ static VALUE t_send_data (VALUE self, VALUE signature, VALUE data, VALUE data_length)
245
+ {
246
+ int b = evma_send_data_to_connection (NUM2ULONG (signature), StringValuePtr (data), FIX2INT (data_length));
247
+ return INT2NUM (b);
248
+ }
249
+
250
+
251
+ /***********
252
+ t_start_tls
253
+ ***********/
254
+
255
+ static VALUE t_start_tls (VALUE self, VALUE signature)
256
+ {
257
+ evma_start_tls (NUM2ULONG (signature));
258
+ return Qnil;
259
+ }
260
+
261
+ /***************
262
+ t_set_tls_parms
263
+ ***************/
264
+
265
+ static VALUE t_set_tls_parms (VALUE self, VALUE signature, VALUE privkeyfile, VALUE certchainfile, VALUE verify_peer)
266
+ {
267
+ /* set_tls_parms takes a series of positional arguments for specifying such things
268
+ * as private keys and certificate chains.
269
+ * It's expected that the parameter list will grow as we add more supported features.
270
+ * ALL of these parameters are optional, and can be specified as empty or NULL strings.
271
+ */
272
+ evma_set_tls_parms (NUM2ULONG (signature), StringValuePtr (privkeyfile), StringValuePtr (certchainfile), (verify_peer == Qtrue ? 1 : 0));
273
+ return Qnil;
274
+ }
275
+
276
+ /***************
277
+ t_get_peer_cert
278
+ ***************/
279
+
280
+ static VALUE t_get_peer_cert (VALUE self, VALUE signature)
281
+ {
282
+ VALUE ret = Qnil;
283
+
284
+ #ifdef WITH_SSL
285
+ X509 *cert = NULL;
286
+ BUF_MEM *buf;
287
+ BIO *out;
288
+
289
+ cert = evma_get_peer_cert (NUM2ULONG (signature));
290
+
291
+ if (cert != NULL) {
292
+ out = BIO_new(BIO_s_mem());
293
+ PEM_write_bio_X509(out, cert);
294
+ BIO_get_mem_ptr(out, &buf);
295
+ ret = rb_str_new(buf->data, buf->length);
296
+ X509_free(cert);
297
+ BUF_MEM_free(buf);
298
+ }
299
+ #endif
300
+
301
+ return ret;
302
+ }
303
+
304
+ /**************
305
+ t_get_peername
306
+ **************/
307
+
308
+ static VALUE t_get_peername (VALUE self, VALUE signature)
309
+ {
310
+ struct sockaddr s;
311
+ if (evma_get_peername (NUM2ULONG (signature), &s)) {
312
+ return rb_str_new ((const char*)&s, sizeof(s));
313
+ }
314
+
315
+ return Qnil;
316
+ }
317
+
318
+ /**************
319
+ t_get_sockname
320
+ **************/
321
+
322
+ static VALUE t_get_sockname (VALUE self, VALUE signature)
323
+ {
324
+ struct sockaddr s;
325
+ if (evma_get_sockname (NUM2ULONG (signature), &s)) {
326
+ return rb_str_new ((const char*)&s, sizeof(s));
327
+ }
328
+
329
+ return Qnil;
330
+ }
331
+
332
+ /********************
333
+ t_get_subprocess_pid
334
+ ********************/
335
+
336
+ static VALUE t_get_subprocess_pid (VALUE self, VALUE signature)
337
+ {
338
+ pid_t pid;
339
+ if (evma_get_subprocess_pid (NUM2ULONG (signature), &pid)) {
340
+ return INT2NUM (pid);
341
+ }
342
+
343
+ return Qnil;
344
+ }
345
+
346
+ /***********************
347
+ t_get_subprocess_status
348
+ ***********************/
349
+
350
+ static VALUE t_get_subprocess_status (VALUE self, VALUE signature)
351
+ {
352
+ VALUE proc_status = Qnil;
353
+
354
+ int status;
355
+ pid_t pid;
356
+
357
+ if (evma_get_subprocess_status (NUM2ULONG (signature), &status)) {
358
+ if (evma_get_subprocess_pid (NUM2ULONG (signature), &pid)) {
359
+ proc_status = rb_obj_alloc(rb_cProcStatus);
360
+ rb_iv_set(proc_status, "status", INT2FIX(status));
361
+ rb_iv_set(proc_status, "pid", INT2FIX(pid));
362
+ }
363
+ }
364
+
365
+ return proc_status;
366
+ }
367
+
368
+ /**********************
369
+ t_get_connection_count
370
+ **********************/
371
+
372
+ static VALUE t_get_connection_count (VALUE self)
373
+ {
374
+ return INT2NUM(evma_get_connection_count());
375
+ }
376
+
377
+ /*****************************
378
+ t_get_comm_inactivity_timeout
379
+ *****************************/
380
+
381
+ static VALUE t_get_comm_inactivity_timeout (VALUE self, VALUE signature)
382
+ {
383
+ return rb_float_new(evma_get_comm_inactivity_timeout(NUM2ULONG (signature)));
384
+ }
385
+
386
+ /*****************************
387
+ t_set_comm_inactivity_timeout
388
+ *****************************/
389
+
390
+ static VALUE t_set_comm_inactivity_timeout (VALUE self, VALUE signature, VALUE timeout)
391
+ {
392
+ float ti = RFLOAT_VALUE(timeout);
393
+ if (evma_set_comm_inactivity_timeout (NUM2ULONG (signature), ti));
394
+ return Qtrue;
395
+ return Qfalse;
396
+ }
397
+
398
+ /*****************************
399
+ t_get_pending_connect_timeout
400
+ *****************************/
401
+
402
+ static VALUE t_get_pending_connect_timeout (VALUE self, VALUE signature)
403
+ {
404
+ return rb_float_new(evma_get_pending_connect_timeout(NUM2ULONG (signature)));
405
+ }
406
+
407
+ /*****************************
408
+ t_set_pending_connect_timeout
409
+ *****************************/
410
+
411
+ static VALUE t_set_pending_connect_timeout (VALUE self, VALUE signature, VALUE timeout)
412
+ {
413
+ float ti = RFLOAT_VALUE(timeout);
414
+ if (evma_set_pending_connect_timeout (NUM2ULONG (signature), ti));
415
+ return Qtrue;
416
+ return Qfalse;
417
+ }
418
+
419
+ /***************
420
+ t_send_datagram
421
+ ***************/
422
+
423
+ static VALUE t_send_datagram (VALUE self, VALUE signature, VALUE data, VALUE data_length, VALUE address, VALUE port)
424
+ {
425
+ int b = evma_send_datagram (NUM2ULONG (signature), StringValuePtr (data), FIX2INT (data_length), StringValuePtr(address), FIX2INT(port));
426
+ return INT2NUM (b);
427
+ }
428
+
429
+
430
+ /******************
431
+ t_close_connection
432
+ ******************/
433
+
434
+ static VALUE t_close_connection (VALUE self, VALUE signature, VALUE after_writing)
435
+ {
436
+ evma_close_connection (NUM2ULONG (signature), ((after_writing == Qtrue) ? 1 : 0));
437
+ return Qnil;
438
+ }
439
+
440
+ /********************************
441
+ t_report_connection_error_status
442
+ ********************************/
443
+
444
+ static VALUE t_report_connection_error_status (VALUE self, VALUE signature)
445
+ {
446
+ int b = evma_report_connection_error_status (NUM2ULONG (signature));
447
+ return INT2NUM (b);
448
+ }
449
+
450
+
451
+
452
+ /****************
453
+ t_connect_server
454
+ ****************/
455
+
456
+ static VALUE t_connect_server (VALUE self, VALUE server, VALUE port)
457
+ {
458
+ // Avoid FIX2INT in this case, because it doesn't deal with type errors properly.
459
+ // Specifically, if the value of port comes in as a string rather than an integer,
460
+ // NUM2INT will throw a type error, but FIX2INT will generate garbage.
461
+
462
+ try {
463
+ const unsigned long f = evma_connect_to_server (NULL, 0, StringValuePtr(server), NUM2INT(port));
464
+ if (!f)
465
+ rb_raise (EM_eConnectionError, "no connection");
466
+ return ULONG2NUM (f);
467
+ } catch (std::runtime_error e) {
468
+ rb_raise (EM_eConnectionError, e.what());
469
+ }
470
+ }
471
+
472
+ /*********************
473
+ t_bind_connect_server
474
+ *********************/
475
+
476
+ static VALUE t_bind_connect_server (VALUE self, VALUE bind_addr, VALUE bind_port, VALUE server, VALUE port)
477
+ {
478
+ // Avoid FIX2INT in this case, because it doesn't deal with type errors properly.
479
+ // Specifically, if the value of port comes in as a string rather than an integer,
480
+ // NUM2INT will throw a type error, but FIX2INT will generate garbage.
481
+
482
+ try {
483
+ const unsigned long f = evma_connect_to_server (StringValuePtr(bind_addr), NUM2INT(bind_port), StringValuePtr(server), NUM2INT(port));
484
+ if (!f)
485
+ rb_raise (EM_eConnectionError, "no connection");
486
+ return ULONG2NUM (f);
487
+ } catch (std::runtime_error e) {
488
+ rb_raise (EM_eConnectionError, e.what());
489
+ }
490
+ }
491
+
492
+ /*********************
493
+ t_connect_unix_server
494
+ *********************/
495
+
496
+ static VALUE t_connect_unix_server (VALUE self, VALUE serversocket)
497
+ {
498
+ const unsigned long f = evma_connect_to_unix_server (StringValuePtr(serversocket));
499
+ if (!f)
500
+ rb_raise (rb_eRuntimeError, "no connection");
501
+ return ULONG2NUM (f);
502
+ }
503
+
504
+ /***********
505
+ t_attach_fd
506
+ ***********/
507
+
508
+ static VALUE t_attach_fd (VALUE self, VALUE file_descriptor, VALUE watch_mode)
509
+ {
510
+ const unsigned long f = evma_attach_fd (NUM2INT(file_descriptor), watch_mode == Qtrue);
511
+ if (!f)
512
+ rb_raise (rb_eRuntimeError, "no connection");
513
+ return ULONG2NUM (f);
514
+ }
515
+
516
+ /***********
517
+ t_detach_fd
518
+ ***********/
519
+
520
+ static VALUE t_detach_fd (VALUE self, VALUE signature)
521
+ {
522
+ return INT2NUM(evma_detach_fd (NUM2ULONG (signature)));
523
+ }
524
+
525
+ /**************
526
+ t_get_sock_opt
527
+ **************/
528
+
529
+ static VALUE t_get_sock_opt (VALUE self, VALUE signature, VALUE lev, VALUE optname)
530
+ {
531
+ int fd = evma_get_file_descriptor (NUM2ULONG (signature));
532
+ int level = NUM2INT(lev), option = NUM2INT(optname);
533
+ socklen_t len = 128;
534
+ char buf[128];
535
+
536
+ if (getsockopt(fd, level, option, buf, &len) < 0)
537
+ rb_sys_fail("getsockopt");
538
+
539
+ return rb_str_new(buf, len);
540
+ }
541
+
542
+ /********************
543
+ t_is_notify_readable
544
+ ********************/
545
+
546
+ static VALUE t_is_notify_readable (VALUE self, VALUE signature)
547
+ {
548
+ return evma_is_notify_readable(NUM2ULONG (signature)) ? Qtrue : Qfalse;
549
+ }
550
+
551
+ /*********************
552
+ t_set_notify_readable
553
+ *********************/
554
+
555
+ static VALUE t_set_notify_readable (VALUE self, VALUE signature, VALUE mode)
556
+ {
557
+ evma_set_notify_readable(NUM2ULONG (signature), mode == Qtrue);
558
+ return Qnil;
559
+ }
560
+
561
+ /********************
562
+ t_is_notify_readable
563
+ ********************/
564
+
565
+ static VALUE t_is_notify_writable (VALUE self, VALUE signature)
566
+ {
567
+ return evma_is_notify_writable(NUM2ULONG (signature)) ? Qtrue : Qfalse;
568
+ }
569
+
570
+ /*********************
571
+ t_set_notify_writable
572
+ *********************/
573
+
574
+ static VALUE t_set_notify_writable (VALUE self, VALUE signature, VALUE mode)
575
+ {
576
+ evma_set_notify_writable(NUM2ULONG (signature), mode == Qtrue);
577
+ return Qnil;
578
+ }
579
+
580
+ /*******
581
+ t_pause
582
+ *******/
583
+
584
+ static VALUE t_pause (VALUE self, VALUE signature)
585
+ {
586
+ return evma_pause(NUM2ULONG (signature)) ? Qtrue : Qfalse;
587
+ }
588
+
589
+ /********
590
+ t_resume
591
+ ********/
592
+
593
+ static VALUE t_resume (VALUE self, VALUE signature)
594
+ {
595
+ return evma_resume(NUM2ULONG (signature)) ? Qtrue : Qfalse;
596
+ }
597
+
598
+ /**********
599
+ t_paused_p
600
+ **********/
601
+
602
+ static VALUE t_paused_p (VALUE self, VALUE signature)
603
+ {
604
+ return evma_is_paused(NUM2ULONG (signature)) ? Qtrue : Qfalse;
605
+ }
606
+
607
+ /*****************
608
+ t_open_udp_socket
609
+ *****************/
610
+
611
+ static VALUE t_open_udp_socket (VALUE self, VALUE server, VALUE port)
612
+ {
613
+ const unsigned long f = evma_open_datagram_socket (StringValuePtr(server), FIX2INT(port));
614
+ if (!f)
615
+ rb_raise (rb_eRuntimeError, "no datagram socket");
616
+ return ULONG2NUM (f);
617
+ }
618
+
619
+
620
+
621
+ /*****************
622
+ t_release_machine
623
+ *****************/
624
+
625
+ static VALUE t_release_machine (VALUE self)
626
+ {
627
+ evma_release_library();
628
+ return Qnil;
629
+ }
630
+
631
+
632
+ /******
633
+ t_stop
634
+ ******/
635
+
636
+ static VALUE t_stop (VALUE self)
637
+ {
638
+ evma_stop_machine();
639
+ return Qnil;
640
+ }
641
+
642
+ /******************
643
+ t_signal_loopbreak
644
+ ******************/
645
+
646
+ static VALUE t_signal_loopbreak (VALUE self)
647
+ {
648
+ evma_signal_loopbreak();
649
+ return Qnil;
650
+ }
651
+
652
+ /**************
653
+ t_library_type
654
+ **************/
655
+
656
+ static VALUE t_library_type (VALUE self)
657
+ {
658
+ return rb_eval_string (":extension");
659
+ }
660
+
661
+
662
+
663
+ /*******************
664
+ t_set_timer_quantum
665
+ *******************/
666
+
667
+ static VALUE t_set_timer_quantum (VALUE self, VALUE interval)
668
+ {
669
+ evma_set_timer_quantum (FIX2INT (interval));
670
+ return Qnil;
671
+ }
672
+
673
+ /********************
674
+ t_get_max_timer_count
675
+ ********************/
676
+
677
+ static VALUE t_get_max_timer_count (VALUE self)
678
+ {
679
+ return INT2FIX (evma_get_max_timer_count());
680
+ }
681
+
682
+ /********************
683
+ t_set_max_timer_count
684
+ ********************/
685
+
686
+ static VALUE t_set_max_timer_count (VALUE self, VALUE ct)
687
+ {
688
+ evma_set_max_timer_count (FIX2INT (ct));
689
+ return Qnil;
690
+ }
691
+
692
+ /***************
693
+ t_setuid_string
694
+ ***************/
695
+
696
+ static VALUE t_setuid_string (VALUE self, VALUE username)
697
+ {
698
+ evma_setuid_string (StringValuePtr (username));
699
+ return Qnil;
700
+ }
701
+
702
+
703
+
704
+ /*************
705
+ t__write_file
706
+ *************/
707
+
708
+ static VALUE t__write_file (VALUE self, VALUE filename)
709
+ {
710
+ const unsigned long f = evma__write_file (StringValuePtr (filename));
711
+ if (!f)
712
+ rb_raise (rb_eRuntimeError, "file not opened");
713
+ return ULONG2NUM (f);
714
+ }
715
+
716
+ /**************
717
+ t_invoke_popen
718
+ **************/
719
+
720
+ static VALUE t_invoke_popen (VALUE self, VALUE cmd)
721
+ {
722
+ // 1.8.7+
723
+ #ifdef RARRAY_LEN
724
+ int len = RARRAY_LEN(cmd);
725
+ #else
726
+ int len = RARRAY (cmd)->len;
727
+ #endif
728
+ if (len > 98)
729
+ rb_raise (rb_eRuntimeError, "too many arguments to popen");
730
+ char *strings [100];
731
+ for (int i=0; i < len; i++) {
732
+ VALUE ix = INT2FIX (i);
733
+ VALUE s = rb_ary_aref (1, &ix, cmd);
734
+ strings[i] = StringValuePtr (s);
735
+ }
736
+ strings[len] = NULL;
737
+
738
+ const unsigned long f = evma_popen (strings);
739
+ if (!f) {
740
+ char *err = strerror (errno);
741
+ char buf[100];
742
+ memset (buf, 0, sizeof(buf));
743
+ snprintf (buf, sizeof(buf)-1, "no popen: %s", (err?err:"???"));
744
+ rb_raise (rb_eRuntimeError, "%s", buf);
745
+ }
746
+ return ULONG2NUM (f);
747
+ }
748
+
749
+
750
+ /***************
751
+ t_read_keyboard
752
+ ***************/
753
+
754
+ static VALUE t_read_keyboard (VALUE self)
755
+ {
756
+ const unsigned long f = evma_open_keyboard();
757
+ if (!f)
758
+ rb_raise (rb_eRuntimeError, "no keyboard reader");
759
+ return ULONG2NUM (f);
760
+ }
761
+
762
+
763
+ /****************
764
+ t_watch_filename
765
+ ****************/
766
+
767
+ static VALUE t_watch_filename (VALUE self, VALUE fname)
768
+ {
769
+ try {
770
+ return ULONG2NUM(evma_watch_filename(StringValuePtr(fname)));
771
+ } catch (std::runtime_error e) {
772
+ rb_sys_fail(e.what());
773
+ }
774
+ }
775
+
776
+
777
+ /******************
778
+ t_unwatch_filename
779
+ ******************/
780
+
781
+ static VALUE t_unwatch_filename (VALUE self, VALUE sig)
782
+ {
783
+ evma_unwatch_filename(NUM2ULONG (sig));
784
+ return Qnil;
785
+ }
786
+
787
+
788
+ /***********
789
+ t_watch_pid
790
+ ***********/
791
+
792
+ static VALUE t_watch_pid (VALUE self, VALUE pid)
793
+ {
794
+ try {
795
+ return ULONG2NUM(evma_watch_pid(NUM2INT(pid)));
796
+ } catch (std::runtime_error e) {
797
+ rb_sys_fail(e.what());
798
+ }
799
+ }
800
+
801
+
802
+ /*************
803
+ t_unwatch_pid
804
+ *************/
805
+
806
+ static VALUE t_unwatch_pid (VALUE self, VALUE sig)
807
+ {
808
+ evma_unwatch_pid(NUM2ULONG (sig));
809
+ return Qnil;
810
+ }
811
+
812
+
813
+ /**********
814
+ t__epoll_p
815
+ **********/
816
+
817
+ static VALUE t__epoll_p (VALUE self)
818
+ {
819
+ #ifdef HAVE_EPOLL
820
+ return Qtrue;
821
+ #else
822
+ return Qfalse;
823
+ #endif
824
+ }
825
+
826
+ /********
827
+ t__epoll
828
+ ********/
829
+
830
+ static VALUE t__epoll (VALUE self)
831
+ {
832
+ evma_set_epoll (1);
833
+ return Qtrue;
834
+ }
835
+
836
+ /***********
837
+ t__epoll_set
838
+ ***********/
839
+
840
+ static VALUE t__epoll_set (VALUE self, VALUE val)
841
+ {
842
+ if (t__epoll_p(self) == Qfalse)
843
+ rb_raise (EM_eUnsupported, "epoll is not supported on this platform");
844
+
845
+ evma_set_epoll (val == Qtrue ? 1 : 0);
846
+ return val;
847
+ }
848
+
849
+
850
+ /***********
851
+ t__kqueue_p
852
+ ***********/
853
+
854
+ static VALUE t__kqueue_p (VALUE self)
855
+ {
856
+ #ifdef HAVE_KQUEUE
857
+ return Qtrue;
858
+ #else
859
+ return Qfalse;
860
+ #endif
861
+ }
862
+
863
+ /*********
864
+ t__kqueue
865
+ *********/
866
+
867
+ static VALUE t__kqueue (VALUE self)
868
+ {
869
+ evma_set_kqueue (1);
870
+ return Qtrue;
871
+ }
872
+
873
+ /*************
874
+ t__kqueue_set
875
+ *************/
876
+
877
+ static VALUE t__kqueue_set (VALUE self, VALUE val)
878
+ {
879
+ if (t__kqueue_p(self) == Qfalse)
880
+ rb_raise (EM_eUnsupported, "kqueue is not supported on this platform");
881
+
882
+ evma_set_kqueue (val == Qtrue ? 1 : 0);
883
+ return val;
884
+ }
885
+
886
+
887
+ /********
888
+ t__ssl_p
889
+ ********/
890
+
891
+ static VALUE t__ssl_p (VALUE self)
892
+ {
893
+ #ifdef WITH_SSL
894
+ return Qtrue;
895
+ #else
896
+ return Qfalse;
897
+ #endif
898
+ }
899
+
900
+
901
+ /****************
902
+ t_send_file_data
903
+ ****************/
904
+
905
+ static VALUE t_send_file_data (VALUE self, VALUE signature, VALUE filename)
906
+ {
907
+
908
+ /* The current implementation of evma_send_file_data_to_connection enforces a strict
909
+ * upper limit on the file size it will transmit (currently 32K). The function returns
910
+ * zero on success, -1 if the requested file exceeds its size limit, and a positive
911
+ * number for other errors.
912
+ * TODO: Positive return values are actually errno's, which is probably the wrong way to
913
+ * do this. For one thing it's ugly. For another, we can't be sure zero is never a real errno.
914
+ */
915
+
916
+ int b = evma_send_file_data_to_connection (NUM2ULONG (signature), StringValuePtr(filename));
917
+ if (b == -1)
918
+ rb_raise(rb_eRuntimeError, "File too large. send_file_data() supports files under 32k.");
919
+ if (b > 0) {
920
+ char *err = strerror (b);
921
+ char buf[1024];
922
+ memset (buf, 0, sizeof(buf));
923
+ snprintf (buf, sizeof(buf)-1, ": %s %s", StringValuePtr(filename),(err?err:"???"));
924
+
925
+ rb_raise (rb_eIOError, "%s", buf);
926
+ }
927
+
928
+ return INT2NUM (0);
929
+ }
930
+
931
+
932
+ /*******************
933
+ t_set_rlimit_nofile
934
+ *******************/
935
+
936
+ static VALUE t_set_rlimit_nofile (VALUE self, VALUE arg)
937
+ {
938
+ arg = (NIL_P(arg)) ? -1 : NUM2INT (arg);
939
+ return INT2NUM (evma_set_rlimit_nofile (arg));
940
+ }
941
+
942
+ /***************************
943
+ conn_get_outbound_data_size
944
+ ***************************/
945
+
946
+ static VALUE conn_get_outbound_data_size (VALUE self)
947
+ {
948
+ VALUE sig = rb_ivar_get (self, Intern_at_signature);
949
+ return INT2NUM (evma_get_outbound_data_size (NUM2ULONG (sig)));
950
+ }
951
+
952
+
953
+ /******************************
954
+ conn_associate_callback_target
955
+ ******************************/
956
+
957
+ static VALUE conn_associate_callback_target (VALUE self, VALUE sig)
958
+ {
959
+ // No-op for the time being.
960
+ return Qnil;
961
+ }
962
+
963
+
964
+ /***************
965
+ t_get_loop_time
966
+ ****************/
967
+
968
+ static VALUE t_get_loop_time (VALUE self)
969
+ {
970
+ #ifndef HAVE_RB_TIME_NEW
971
+ static VALUE cTime = rb_path2class("Time");
972
+ static ID at = rb_intern("at");
973
+ #endif
974
+
975
+ if (gCurrentLoopTime != 0) {
976
+ #ifndef HAVE_RB_TIME_NEW
977
+ return rb_funcall(cTime, at, 2, INT2NUM(gCurrentLoopTime / 1000000), INT2NUM(gCurrentLoopTime % 1000000));
978
+ #else
979
+ return rb_time_new(gCurrentLoopTime / 1000000, gCurrentLoopTime % 1000000);
980
+ #endif
981
+ }
982
+ return Qnil;
983
+ }
984
+
985
+
986
+ /*************
987
+ t_start_proxy
988
+ **************/
989
+
990
+ static VALUE t_start_proxy (VALUE self, VALUE from, VALUE to, VALUE bufsize)
991
+ {
992
+ evma_start_proxy(NUM2ULONG (from), NUM2ULONG (to), NUM2ULONG(bufsize));
993
+ return Qnil;
994
+ }
995
+
996
+
997
+ /************
998
+ t_stop_proxy
999
+ *************/
1000
+
1001
+ static VALUE t_stop_proxy (VALUE self, VALUE from)
1002
+ {
1003
+ evma_stop_proxy(NUM2ULONG (from));
1004
+ return Qnil;
1005
+ }
1006
+
1007
+
1008
+ /************************
1009
+ t_get_heartbeat_interval
1010
+ *************************/
1011
+
1012
+ static VALUE t_get_heartbeat_interval (VALUE self)
1013
+ {
1014
+ return rb_float_new(evma_get_heartbeat_interval());
1015
+ }
1016
+
1017
+
1018
+ /************************
1019
+ t_set_heartbeat_interval
1020
+ *************************/
1021
+
1022
+ static VALUE t_set_heartbeat_interval (VALUE self, VALUE interval)
1023
+ {
1024
+ float iv = RFLOAT_VALUE(interval);
1025
+ if (evma_set_heartbeat_interval(iv))
1026
+ return Qtrue;
1027
+ return Qfalse;
1028
+ }
1029
+
1030
+
1031
+ /*********************
1032
+ Init_rubyeventmachine
1033
+ *********************/
1034
+
1035
+ extern "C" void Init_rubyeventmachine()
1036
+ {
1037
+ // Lookup Process::Status for get_subprocess_status
1038
+ VALUE rb_mProcess = rb_const_get(rb_cObject, rb_intern("Process"));
1039
+ rb_cProcStatus = rb_const_get(rb_mProcess, rb_intern("Status"));
1040
+
1041
+ // Tuck away some symbol values so we don't have to look 'em up every time we need 'em.
1042
+ Intern_at_signature = rb_intern ("@signature");
1043
+ Intern_at_timers = rb_intern ("@timers");
1044
+ Intern_at_conns = rb_intern ("@conns");
1045
+ Intern_at_error_handler = rb_intern("@error_handler");
1046
+
1047
+ Intern_event_callback = rb_intern ("event_callback");
1048
+ Intern_run_deferred_callbacks = rb_intern ("run_deferred_callbacks");
1049
+ Intern_delete = rb_intern ("delete");
1050
+ Intern_call = rb_intern ("call");
1051
+ Intern_receive_data = rb_intern ("receive_data");
1052
+ Intern_ssl_handshake_completed = rb_intern ("ssl_handshake_completed");
1053
+ Intern_ssl_verify_peer = rb_intern ("ssl_verify_peer");
1054
+ Intern_notify_readable = rb_intern ("notify_readable");
1055
+ Intern_notify_writable = rb_intern ("notify_writable");
1056
+ Intern_proxy_target_unbound = rb_intern ("proxy_target_unbound");
1057
+
1058
+ // INCOMPLETE, we need to define class Connections inside module EventMachine
1059
+ // run_machine and run_machine_without_threads are now identical.
1060
+ // Must deprecate the without_threads variant.
1061
+ EmModule = rb_define_module ("EventMachine");
1062
+ EmConnection = rb_define_class_under (EmModule, "Connection", rb_cObject);
1063
+
1064
+ rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eRuntimeError);
1065
+ EM_eConnectionError = rb_define_class_under (EmModule, "ConnectionError", rb_eRuntimeError);
1066
+ EM_eConnectionNotBound = rb_define_class_under (EmModule, "ConnectionNotBound", rb_eRuntimeError);
1067
+ EM_eUnknownTimerFired = rb_define_class_under (EmModule, "UnknownTimerFired", rb_eRuntimeError);
1068
+ EM_eUnsupported = rb_define_class_under (EmModule, "Unsupported", rb_eRuntimeError);
1069
+
1070
+ rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0);
1071
+ rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine_without_threads, 0);
1072
+ rb_define_module_function (EmModule, "run_machine_without_threads", (VALUE(*)(...))t_run_machine_without_threads, 0);
1073
+ rb_define_module_function (EmModule, "add_oneshot_timer", (VALUE(*)(...))t_add_oneshot_timer, 1);
1074
+ rb_define_module_function (EmModule, "start_tcp_server", (VALUE(*)(...))t_start_server, 2);
1075
+ rb_define_module_function (EmModule, "stop_tcp_server", (VALUE(*)(...))t_stop_server, 1);
1076
+ rb_define_module_function (EmModule, "start_unix_server", (VALUE(*)(...))t_start_unix_server, 1);
1077
+ rb_define_module_function (EmModule, "set_tls_parms", (VALUE(*)(...))t_set_tls_parms, 4);
1078
+ rb_define_module_function (EmModule, "start_tls", (VALUE(*)(...))t_start_tls, 1);
1079
+ rb_define_module_function (EmModule, "get_peer_cert", (VALUE(*)(...))t_get_peer_cert, 1);
1080
+ rb_define_module_function (EmModule, "send_data", (VALUE(*)(...))t_send_data, 3);
1081
+ rb_define_module_function (EmModule, "send_datagram", (VALUE(*)(...))t_send_datagram, 5);
1082
+ rb_define_module_function (EmModule, "close_connection", (VALUE(*)(...))t_close_connection, 2);
1083
+ rb_define_module_function (EmModule, "report_connection_error_status", (VALUE(*)(...))t_report_connection_error_status, 1);
1084
+ rb_define_module_function (EmModule, "connect_server", (VALUE(*)(...))t_connect_server, 2);
1085
+ rb_define_module_function (EmModule, "bind_connect_server", (VALUE(*)(...))t_bind_connect_server, 4);
1086
+ rb_define_module_function (EmModule, "connect_unix_server", (VALUE(*)(...))t_connect_unix_server, 1);
1087
+
1088
+ rb_define_module_function (EmModule, "attach_fd", (VALUE (*)(...))t_attach_fd, 2);
1089
+ rb_define_module_function (EmModule, "detach_fd", (VALUE (*)(...))t_detach_fd, 1);
1090
+ rb_define_module_function (EmModule, "get_sock_opt", (VALUE (*)(...))t_get_sock_opt, 3);
1091
+ rb_define_module_function (EmModule, "set_notify_readable", (VALUE (*)(...))t_set_notify_readable, 2);
1092
+ rb_define_module_function (EmModule, "set_notify_writable", (VALUE (*)(...))t_set_notify_writable, 2);
1093
+ rb_define_module_function (EmModule, "is_notify_readable", (VALUE (*)(...))t_is_notify_readable, 1);
1094
+ rb_define_module_function (EmModule, "is_notify_writable", (VALUE (*)(...))t_is_notify_writable, 1);
1095
+
1096
+ rb_define_module_function (EmModule, "pause_connection", (VALUE (*)(...))t_pause, 1);
1097
+ rb_define_module_function (EmModule, "resume_connection", (VALUE (*)(...))t_resume, 1);
1098
+ rb_define_module_function (EmModule, "connection_paused?", (VALUE (*)(...))t_paused_p, 1);
1099
+
1100
+ rb_define_module_function (EmModule, "start_proxy", (VALUE (*)(...))t_start_proxy, 3);
1101
+ rb_define_module_function (EmModule, "stop_proxy", (VALUE (*)(...))t_stop_proxy, 1);
1102
+
1103
+ rb_define_module_function (EmModule, "watch_filename", (VALUE (*)(...))t_watch_filename, 1);
1104
+ rb_define_module_function (EmModule, "unwatch_filename", (VALUE (*)(...))t_unwatch_filename, 1);
1105
+
1106
+ rb_define_module_function (EmModule, "watch_pid", (VALUE (*)(...))t_watch_pid, 1);
1107
+ rb_define_module_function (EmModule, "unwatch_pid", (VALUE (*)(...))t_unwatch_pid, 1);
1108
+
1109
+ rb_define_module_function (EmModule, "current_time", (VALUE(*)(...))t_get_loop_time, 0);
1110
+
1111
+ rb_define_module_function (EmModule, "open_udp_socket", (VALUE(*)(...))t_open_udp_socket, 2);
1112
+ rb_define_module_function (EmModule, "read_keyboard", (VALUE(*)(...))t_read_keyboard, 0);
1113
+ rb_define_module_function (EmModule, "release_machine", (VALUE(*)(...))t_release_machine, 0);
1114
+ rb_define_module_function (EmModule, "stop", (VALUE(*)(...))t_stop, 0);
1115
+ rb_define_module_function (EmModule, "signal_loopbreak", (VALUE(*)(...))t_signal_loopbreak, 0);
1116
+ rb_define_module_function (EmModule, "library_type", (VALUE(*)(...))t_library_type, 0);
1117
+ rb_define_module_function (EmModule, "set_timer_quantum", (VALUE(*)(...))t_set_timer_quantum, 1);
1118
+ rb_define_module_function (EmModule, "get_max_timer_count", (VALUE(*)(...))t_get_max_timer_count, 0);
1119
+ rb_define_module_function (EmModule, "set_max_timer_count", (VALUE(*)(...))t_set_max_timer_count, 1);
1120
+ rb_define_module_function (EmModule, "setuid_string", (VALUE(*)(...))t_setuid_string, 1);
1121
+ rb_define_module_function (EmModule, "invoke_popen", (VALUE(*)(...))t_invoke_popen, 1);
1122
+ rb_define_module_function (EmModule, "send_file_data", (VALUE(*)(...))t_send_file_data, 2);
1123
+ rb_define_module_function (EmModule, "get_heartbeat_interval", (VALUE(*)(...))t_get_heartbeat_interval, 0);
1124
+ rb_define_module_function (EmModule, "set_heartbeat_interval", (VALUE(*)(...))t_set_heartbeat_interval, 1);
1125
+
1126
+ // Provisional:
1127
+ rb_define_module_function (EmModule, "_write_file", (VALUE(*)(...))t__write_file, 1);
1128
+
1129
+ rb_define_module_function (EmModule, "get_peername", (VALUE(*)(...))t_get_peername, 1);
1130
+ rb_define_module_function (EmModule, "get_sockname", (VALUE(*)(...))t_get_sockname, 1);
1131
+ rb_define_module_function (EmModule, "get_subprocess_pid", (VALUE(*)(...))t_get_subprocess_pid, 1);
1132
+ rb_define_module_function (EmModule, "get_subprocess_status", (VALUE(*)(...))t_get_subprocess_status, 1);
1133
+ rb_define_module_function (EmModule, "get_comm_inactivity_timeout", (VALUE(*)(...))t_get_comm_inactivity_timeout, 1);
1134
+ rb_define_module_function (EmModule, "set_comm_inactivity_timeout", (VALUE(*)(...))t_set_comm_inactivity_timeout, 2);
1135
+ rb_define_module_function (EmModule, "get_pending_connect_timeout", (VALUE(*)(...))t_get_pending_connect_timeout, 1);
1136
+ rb_define_module_function (EmModule, "set_pending_connect_timeout", (VALUE(*)(...))t_set_pending_connect_timeout, 2);
1137
+ rb_define_module_function (EmModule, "set_rlimit_nofile", (VALUE(*)(...))t_set_rlimit_nofile, 1);
1138
+ rb_define_module_function (EmModule, "get_connection_count", (VALUE(*)(...))t_get_connection_count, 0);
1139
+
1140
+ rb_define_module_function (EmModule, "epoll", (VALUE(*)(...))t__epoll, 0);
1141
+ rb_define_module_function (EmModule, "epoll=", (VALUE(*)(...))t__epoll_set, 1);
1142
+ rb_define_module_function (EmModule, "epoll?", (VALUE(*)(...))t__epoll_p, 0);
1143
+
1144
+ rb_define_module_function (EmModule, "kqueue", (VALUE(*)(...))t__kqueue, 0);
1145
+ rb_define_module_function (EmModule, "kqueue=", (VALUE(*)(...))t__kqueue_set, 1);
1146
+ rb_define_module_function (EmModule, "kqueue?", (VALUE(*)(...))t__kqueue_p, 0);
1147
+
1148
+ rb_define_module_function (EmModule, "ssl?", (VALUE(*)(...))t__ssl_p, 0);
1149
+
1150
+ rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0);
1151
+ rb_define_method (EmConnection, "associate_callback_target", (VALUE(*)(...))conn_associate_callback_target, 1);
1152
+
1153
+ rb_define_const (EmModule, "TimerFired", INT2NUM(100));
1154
+ rb_define_const (EmModule, "ConnectionData", INT2NUM(101));
1155
+ rb_define_const (EmModule, "ConnectionUnbound", INT2NUM(102));
1156
+ rb_define_const (EmModule, "ConnectionAccepted", INT2NUM(103));
1157
+ rb_define_const (EmModule, "ConnectionCompleted", INT2NUM(104));
1158
+ rb_define_const (EmModule, "LoopbreakSignalled", INT2NUM(105));
1159
+
1160
+ rb_define_const (EmModule, "ConnectionNotifyReadable", INT2NUM(106));
1161
+ rb_define_const (EmModule, "ConnectionNotifyWritable", INT2NUM(107));
1162
+
1163
+ rb_define_const (EmModule, "SslHandshakeCompleted", INT2NUM(108));
1164
+
1165
+ }
1166
+