rbczmq 1.6.2 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (398) hide show
  1. data/.gitignore +4 -3
  2. data/.gitmodules +6 -0
  3. data/.travis.yml +5 -1
  4. data/CHANGELOG.rdoc +15 -0
  5. data/Gemfile.lock +2 -2
  6. data/README.rdoc +5 -2
  7. data/Rakefile +8 -3
  8. data/ext/czmq/.gitignore +52 -0
  9. data/ext/czmq/.travis.yml +18 -0
  10. data/ext/czmq/AUTHORS +9 -0
  11. data/ext/czmq/COPYING +674 -0
  12. data/ext/czmq/COPYING.LESSER +178 -0
  13. data/ext/czmq/ChangeLog +0 -0
  14. data/ext/czmq/Makefile.am +22 -0
  15. data/ext/czmq/NEWS +263 -0
  16. data/ext/czmq/README +0 -0
  17. data/ext/czmq/README.md +1122 -0
  18. data/ext/czmq/README.txt +327 -0
  19. data/ext/czmq/autogen.sh +46 -0
  20. data/ext/czmq/builds/android/Android.mk +35 -0
  21. data/ext/czmq/builds/android/Application.mk +1 -0
  22. data/ext/czmq/builds/android/build.sh +59 -0
  23. data/ext/czmq/builds/android/clean.sh +26 -0
  24. data/ext/czmq/builds/mingw32/Makefile.mingw32 +38 -0
  25. data/ext/czmq/builds/mingw32/platform.h +0 -0
  26. data/ext/czmq/builds/msvc/.gitignore +18 -0
  27. data/ext/czmq/builds/msvc/README.txt +17 -0
  28. data/ext/czmq/builds/msvc/czmq.sln +69 -0
  29. data/ext/czmq/builds/msvc/czmq.vcproj +2246 -0
  30. data/ext/czmq/builds/msvc/czmq.vcxproj +329 -0
  31. data/ext/czmq/builds/msvc/czmq.vcxproj.filters +117 -0
  32. data/ext/czmq/builds/msvc/czmq11.sln +36 -0
  33. data/ext/czmq/builds/msvc/czmq_selftest.vcproj +840 -0
  34. data/ext/czmq/builds/msvc/czmq_selftest.vcxproj +189 -0
  35. data/ext/czmq/builds/msvc/czmq_selftest.vcxproj.filters +14 -0
  36. data/ext/czmq/c +520 -0
  37. data/ext/czmq/configure.ac +229 -0
  38. data/ext/czmq/doc/Makefile.am +49 -0
  39. data/ext/czmq/doc/asciidoc.conf +57 -0
  40. data/ext/czmq/doc/czmq.txt +334 -0
  41. data/ext/czmq/doc/mkman +100 -0
  42. data/ext/czmq/doc/mksite +65 -0
  43. data/ext/czmq/doc/wdput +43 -0
  44. data/ext/czmq/doc/xml2wd.pl +242 -0
  45. data/ext/czmq/doc/zbeacon.txt +173 -0
  46. data/ext/czmq/doc/zclock.txt +51 -0
  47. data/ext/czmq/doc/zconfig.txt +92 -0
  48. data/ext/czmq/doc/zctx.txt +111 -0
  49. data/ext/czmq/doc/zfile.txt +77 -0
  50. data/ext/czmq/doc/zframe.txt +222 -0
  51. data/ext/czmq/doc/zhash.txt +225 -0
  52. data/ext/czmq/doc/zlist.txt +176 -0
  53. data/ext/czmq/doc/zloop.txt +106 -0
  54. data/ext/czmq/doc/zmsg.txt +315 -0
  55. data/ext/czmq/doc/zmutex.txt +54 -0
  56. data/ext/czmq/doc/zsocket.txt +110 -0
  57. data/ext/czmq/doc/zsockopt.txt +528 -0
  58. data/ext/czmq/doc/zstr.txt +80 -0
  59. data/ext/czmq/doc/zsys.txt +44 -0
  60. data/ext/czmq/doc/zthread.txt +126 -0
  61. data/ext/czmq/doc/ztree.txt +236 -0
  62. data/ext/czmq/images/README_1.png +0 -0
  63. data/ext/czmq/images/README_2.png +0 -0
  64. data/ext/czmq/include/czmq.h +64 -0
  65. data/ext/czmq/include/czmq_prelude.h +504 -0
  66. data/ext/czmq/include/zbeacon.h +91 -0
  67. data/ext/czmq/include/zclock.h +56 -0
  68. data/ext/czmq/include/zconfig.h +117 -0
  69. data/ext/czmq/include/zctx.h +96 -0
  70. data/ext/czmq/include/zfile.h +82 -0
  71. data/ext/czmq/include/zframe.h +145 -0
  72. data/ext/czmq/include/zhash.h +127 -0
  73. data/ext/czmq/include/zlist.h +113 -0
  74. data/ext/czmq/include/zloop.h +98 -0
  75. data/ext/czmq/include/zmsg.h +165 -0
  76. data/ext/czmq/include/zmutex.h +62 -0
  77. data/ext/czmq/include/zsocket.h +104 -0
  78. data/ext/czmq/include/zsockopt.h +249 -0
  79. data/ext/czmq/include/zstr.h +69 -0
  80. data/ext/czmq/include/zsys.h +66 -0
  81. data/ext/czmq/include/zthread.h +62 -0
  82. data/ext/czmq/include/ztree.h +133 -0
  83. data/ext/czmq/mkdoc +14 -0
  84. data/ext/czmq/model/generate +2 -0
  85. data/ext/czmq/model/sockopts.xml +101 -0
  86. data/ext/czmq/notes.txt +21 -0
  87. data/ext/czmq/scripts/sockopts.gsl +325 -0
  88. data/ext/czmq/src/Makefile.am +61 -0
  89. data/ext/czmq/src/czmq_selftest.c +60 -0
  90. data/ext/czmq/src/libczmq.pc.in +11 -0
  91. data/ext/czmq/src/selftest +7 -0
  92. data/ext/czmq/src/selftest.cfg +5 -0
  93. data/ext/czmq/src/valgrind.supp +14 -0
  94. data/ext/czmq/src/vg +2 -0
  95. data/ext/czmq/src/zbeacon.c +787 -0
  96. data/ext/czmq/src/zclock.c +143 -0
  97. data/ext/czmq/src/zconfig.c +691 -0
  98. data/ext/czmq/src/zctx.c +287 -0
  99. data/ext/czmq/src/zfile.c +237 -0
  100. data/ext/czmq/src/zframe.c +551 -0
  101. data/ext/czmq/src/zhash.c +664 -0
  102. data/ext/czmq/src/zlist.c +459 -0
  103. data/ext/czmq/src/zloop.c +496 -0
  104. data/ext/czmq/src/zmsg.c +854 -0
  105. data/ext/czmq/src/zmutex.c +134 -0
  106. data/ext/czmq/src/zsocket.c +313 -0
  107. data/ext/czmq/src/zsockopt.c +1756 -0
  108. data/ext/czmq/src/zstr.c +297 -0
  109. data/ext/czmq/src/zsys.c +136 -0
  110. data/ext/czmq/src/zthread.c +269 -0
  111. data/ext/czmq/src/ztree.c +888 -0
  112. data/ext/czmq/version.sh +21 -0
  113. data/ext/rbczmq/extconf.rb +1 -18
  114. data/ext/rbczmq/poller.c +4 -1
  115. data/ext/rbczmq/socket.c +28 -5
  116. data/ext/rbczmq/socket.h +1 -0
  117. data/ext/zeromq/AUTHORS +110 -0
  118. data/ext/zeromq/CMakeLists.txt +392 -0
  119. data/ext/zeromq/COPYING +674 -0
  120. data/ext/zeromq/COPYING.LESSER +179 -0
  121. data/ext/zeromq/INSTALL +246 -0
  122. data/ext/zeromq/MAINTAINERS +56 -0
  123. data/ext/zeromq/Makefile.am +40 -0
  124. data/ext/zeromq/NEWS +333 -0
  125. data/ext/zeromq/README +39 -0
  126. data/ext/zeromq/acinclude.m4 +930 -0
  127. data/ext/zeromq/autogen.sh +45 -0
  128. data/ext/zeromq/branding.bmp +0 -0
  129. data/ext/zeromq/builds/msvc/Makefile.am +33 -0
  130. data/ext/zeromq/builds/msvc/c_local_lat/c_local_lat.vcproj +176 -0
  131. data/ext/zeromq/builds/msvc/c_local_lat/c_local_lat.vcxproj +87 -0
  132. data/ext/zeromq/builds/msvc/c_local_thr/c_local_thr.vcproj +176 -0
  133. data/ext/zeromq/builds/msvc/c_local_thr/c_local_thr.vcxproj +87 -0
  134. data/ext/zeromq/builds/msvc/c_remote_lat/c_remote_lat.vcproj +176 -0
  135. data/ext/zeromq/builds/msvc/c_remote_lat/c_remote_lat.vcxproj +87 -0
  136. data/ext/zeromq/builds/msvc/c_remote_thr/c_remote_thr.vcproj +176 -0
  137. data/ext/zeromq/builds/msvc/c_remote_thr/c_remote_thr.vcxproj +87 -0
  138. data/ext/zeromq/builds/msvc/errno.cpp +32 -0
  139. data/ext/zeromq/builds/msvc/errno.hpp +56 -0
  140. data/ext/zeromq/builds/msvc/inproc_lat/inproc_lat.vcproj +174 -0
  141. data/ext/zeromq/builds/msvc/inproc_lat/inproc_lat.vcxproj +86 -0
  142. data/ext/zeromq/builds/msvc/inproc_thr/inproc_thr.vcproj +174 -0
  143. data/ext/zeromq/builds/msvc/inproc_thr/inproc_thr.vcxproj +86 -0
  144. data/ext/zeromq/builds/msvc/libzmq/libzmq.vcproj +804 -0
  145. data/ext/zeromq/builds/msvc/libzmq/libzmq.vcxproj +252 -0
  146. data/ext/zeromq/builds/msvc/libzmq/libzmq.vcxproj.filters +431 -0
  147. data/ext/zeromq/builds/msvc/msvc.sln +89 -0
  148. data/ext/zeromq/builds/msvc/msvc10.sln +116 -0
  149. data/ext/zeromq/builds/msvc/platform.hpp +32 -0
  150. data/ext/zeromq/builds/msvc/properties/Common.props +21 -0
  151. data/ext/zeromq/builds/msvc/properties/Debug.props +19 -0
  152. data/ext/zeromq/builds/msvc/properties/Dynamic.props +20 -0
  153. data/ext/zeromq/builds/msvc/properties/Executable.props +19 -0
  154. data/ext/zeromq/builds/msvc/properties/Precompiled.props +14 -0
  155. data/ext/zeromq/builds/msvc/properties/Release.props +22 -0
  156. data/ext/zeromq/builds/msvc/properties/Win32.props +12 -0
  157. data/ext/zeromq/builds/msvc/properties/Win32_Release.props +17 -0
  158. data/ext/zeromq/builds/msvc/properties/WithOpenPGM.props +12 -0
  159. data/ext/zeromq/builds/msvc/properties/ZeroMQ.props +23 -0
  160. data/ext/zeromq/builds/msvc/properties/x64.props +12 -0
  161. data/ext/zeromq/builds/redhat/zeromq.spec.in +160 -0
  162. data/ext/zeromq/builds/valgrind/valgrind.supp +14 -0
  163. data/ext/zeromq/builds/valgrind/vg +1 -0
  164. data/ext/zeromq/cmake/Modules/TestZMQVersion.cmake +35 -0
  165. data/ext/zeromq/cmake/Modules/zmq_version.cpp +31 -0
  166. data/ext/zeromq/cmake/NSIS.template32.in +952 -0
  167. data/ext/zeromq/cmake/NSIS.template64.in +960 -0
  168. data/ext/zeromq/configure.in +428 -0
  169. data/ext/zeromq/doc/Makefile.am +51 -0
  170. data/ext/zeromq/doc/asciidoc.conf +56 -0
  171. data/ext/zeromq/doc/zmq.txt +233 -0
  172. data/ext/zeromq/doc/zmq_bind.txt +102 -0
  173. data/ext/zeromq/doc/zmq_close.txt +52 -0
  174. data/ext/zeromq/doc/zmq_connect.txt +98 -0
  175. data/ext/zeromq/doc/zmq_ctx_destroy.txt +66 -0
  176. data/ext/zeromq/doc/zmq_ctx_get.txt +67 -0
  177. data/ext/zeromq/doc/zmq_ctx_new.txt +49 -0
  178. data/ext/zeromq/doc/zmq_ctx_set.txt +75 -0
  179. data/ext/zeromq/doc/zmq_disconnect.txt +67 -0
  180. data/ext/zeromq/doc/zmq_epgm.txt +162 -0
  181. data/ext/zeromq/doc/zmq_errno.txt +50 -0
  182. data/ext/zeromq/doc/zmq_getsockopt.txt +516 -0
  183. data/ext/zeromq/doc/zmq_init.txt +52 -0
  184. data/ext/zeromq/doc/zmq_inproc.txt +85 -0
  185. data/ext/zeromq/doc/zmq_ipc.txt +85 -0
  186. data/ext/zeromq/doc/zmq_msg_close.txt +55 -0
  187. data/ext/zeromq/doc/zmq_msg_copy.txt +57 -0
  188. data/ext/zeromq/doc/zmq_msg_data.txt +48 -0
  189. data/ext/zeromq/doc/zmq_msg_get.txt +72 -0
  190. data/ext/zeromq/doc/zmq_msg_init.txt +65 -0
  191. data/ext/zeromq/doc/zmq_msg_init_data.txt +85 -0
  192. data/ext/zeromq/doc/zmq_msg_init_size.txt +58 -0
  193. data/ext/zeromq/doc/zmq_msg_more.txt +63 -0
  194. data/ext/zeromq/doc/zmq_msg_move.txt +52 -0
  195. data/ext/zeromq/doc/zmq_msg_recv.txt +125 -0
  196. data/ext/zeromq/doc/zmq_msg_send.txt +122 -0
  197. data/ext/zeromq/doc/zmq_msg_set.txt +45 -0
  198. data/ext/zeromq/doc/zmq_msg_size.txt +48 -0
  199. data/ext/zeromq/doc/zmq_pgm.txt +162 -0
  200. data/ext/zeromq/doc/zmq_poll.txt +132 -0
  201. data/ext/zeromq/doc/zmq_proxy.txt +97 -0
  202. data/ext/zeromq/doc/zmq_recv.txt +93 -0
  203. data/ext/zeromq/doc/zmq_recvmsg.txt +123 -0
  204. data/ext/zeromq/doc/zmq_send.txt +100 -0
  205. data/ext/zeromq/doc/zmq_sendmsg.txt +119 -0
  206. data/ext/zeromq/doc/zmq_setsockopt.txt +523 -0
  207. data/ext/zeromq/doc/zmq_socket.txt +369 -0
  208. data/ext/zeromq/doc/zmq_socket_monitor.txt +288 -0
  209. data/ext/zeromq/doc/zmq_strerror.txt +55 -0
  210. data/ext/zeromq/doc/zmq_tcp.txt +101 -0
  211. data/ext/zeromq/doc/zmq_term.txt +66 -0
  212. data/ext/zeromq/doc/zmq_unbind.txt +65 -0
  213. data/ext/zeromq/doc/zmq_version.txt +53 -0
  214. data/ext/zeromq/foreign/openpgm/Makefile.am +8 -0
  215. data/ext/zeromq/foreign/openpgm/libpgm-5.1.118~dfsg.tar.gz +0 -0
  216. data/ext/zeromq/include/zmq.h +402 -0
  217. data/ext/zeromq/include/zmq_utils.h +64 -0
  218. data/ext/zeromq/installer.ico +0 -0
  219. data/ext/zeromq/perf/Makefile.am +22 -0
  220. data/ext/zeromq/perf/inproc_lat.cpp +233 -0
  221. data/ext/zeromq/perf/inproc_thr.cpp +241 -0
  222. data/ext/zeromq/perf/local_lat.cpp +109 -0
  223. data/ext/zeromq/perf/local_thr.cpp +133 -0
  224. data/ext/zeromq/perf/remote_lat.cpp +122 -0
  225. data/ext/zeromq/perf/remote_thr.cpp +105 -0
  226. data/ext/zeromq/src/Makefile.am +171 -0
  227. data/ext/zeromq/src/address.cpp +78 -0
  228. data/ext/zeromq/src/address.hpp +52 -0
  229. data/ext/zeromq/src/array.hpp +155 -0
  230. data/ext/zeromq/src/atomic_counter.hpp +197 -0
  231. data/ext/zeromq/src/atomic_ptr.hpp +196 -0
  232. data/ext/zeromq/src/blob.hpp +129 -0
  233. data/ext/zeromq/src/clock.cpp +147 -0
  234. data/ext/zeromq/src/clock.hpp +60 -0
  235. data/ext/zeromq/src/command.hpp +154 -0
  236. data/ext/zeromq/src/config.hpp +89 -0
  237. data/ext/zeromq/src/ctx.cpp +352 -0
  238. data/ext/zeromq/src/ctx.hpp +173 -0
  239. data/ext/zeromq/src/dealer.cpp +133 -0
  240. data/ext/zeromq/src/dealer.hpp +92 -0
  241. data/ext/zeromq/src/decoder.cpp +166 -0
  242. data/ext/zeromq/src/decoder.hpp +248 -0
  243. data/ext/zeromq/src/devpoll.cpp +190 -0
  244. data/ext/zeromq/src/devpoll.hpp +105 -0
  245. data/ext/zeromq/src/dist.cpp +194 -0
  246. data/ext/zeromq/src/dist.hpp +105 -0
  247. data/ext/zeromq/src/encoder.cpp +102 -0
  248. data/ext/zeromq/src/encoder.hpp +200 -0
  249. data/ext/zeromq/src/epoll.cpp +178 -0
  250. data/ext/zeromq/src/epoll.hpp +101 -0
  251. data/ext/zeromq/src/err.cpp +291 -0
  252. data/ext/zeromq/src/err.hpp +155 -0
  253. data/ext/zeromq/src/fd.hpp +45 -0
  254. data/ext/zeromq/src/fq.cpp +141 -0
  255. data/ext/zeromq/src/fq.hpp +74 -0
  256. data/ext/zeromq/src/i_decoder.hpp +49 -0
  257. data/ext/zeromq/src/i_encoder.hpp +55 -0
  258. data/ext/zeromq/src/i_engine.hpp +55 -0
  259. data/ext/zeromq/src/i_msg_sink.hpp +43 -0
  260. data/ext/zeromq/src/i_msg_source.hpp +44 -0
  261. data/ext/zeromq/src/i_poll_events.hpp +47 -0
  262. data/ext/zeromq/src/io_object.cpp +108 -0
  263. data/ext/zeromq/src/io_object.hpp +81 -0
  264. data/ext/zeromq/src/io_thread.cpp +104 -0
  265. data/ext/zeromq/src/io_thread.hpp +91 -0
  266. data/ext/zeromq/src/ip.cpp +109 -0
  267. data/ext/zeromq/src/ip.hpp +41 -0
  268. data/ext/zeromq/src/ipc_address.cpp +84 -0
  269. data/ext/zeromq/src/ipc_address.hpp +67 -0
  270. data/ext/zeromq/src/ipc_connecter.cpp +265 -0
  271. data/ext/zeromq/src/ipc_connecter.hpp +128 -0
  272. data/ext/zeromq/src/ipc_listener.cpp +206 -0
  273. data/ext/zeromq/src/ipc_listener.hpp +99 -0
  274. data/ext/zeromq/src/kqueue.cpp +201 -0
  275. data/ext/zeromq/src/kqueue.hpp +107 -0
  276. data/ext/zeromq/src/lb.cpp +148 -0
  277. data/ext/zeromq/src/lb.hpp +73 -0
  278. data/ext/zeromq/src/libzmq.pc.in +10 -0
  279. data/ext/zeromq/src/likely.hpp +33 -0
  280. data/ext/zeromq/src/mailbox.cpp +87 -0
  281. data/ext/zeromq/src/mailbox.hpp +75 -0
  282. data/ext/zeromq/src/msg.cpp +299 -0
  283. data/ext/zeromq/src/msg.hpp +148 -0
  284. data/ext/zeromq/src/mtrie.cpp +428 -0
  285. data/ext/zeromq/src/mtrie.hpp +93 -0
  286. data/ext/zeromq/src/mutex.hpp +118 -0
  287. data/ext/zeromq/src/object.cpp +393 -0
  288. data/ext/zeromq/src/object.hpp +134 -0
  289. data/ext/zeromq/src/options.cpp +562 -0
  290. data/ext/zeromq/src/options.hpp +135 -0
  291. data/ext/zeromq/src/own.cpp +206 -0
  292. data/ext/zeromq/src/own.hpp +145 -0
  293. data/ext/zeromq/src/pair.cpp +136 -0
  294. data/ext/zeromq/src/pair.hpp +79 -0
  295. data/ext/zeromq/src/pgm_receiver.cpp +283 -0
  296. data/ext/zeromq/src/pgm_receiver.hpp +141 -0
  297. data/ext/zeromq/src/pgm_sender.cpp +218 -0
  298. data/ext/zeromq/src/pgm_sender.hpp +113 -0
  299. data/ext/zeromq/src/pgm_socket.cpp +706 -0
  300. data/ext/zeromq/src/pgm_socket.hpp +124 -0
  301. data/ext/zeromq/src/pipe.cpp +447 -0
  302. data/ext/zeromq/src/pipe.hpp +207 -0
  303. data/ext/zeromq/src/poll.cpp +176 -0
  304. data/ext/zeromq/src/poll.hpp +105 -0
  305. data/ext/zeromq/src/poller.hpp +82 -0
  306. data/ext/zeromq/src/poller_base.cpp +99 -0
  307. data/ext/zeromq/src/poller_base.hpp +86 -0
  308. data/ext/zeromq/src/precompiled.cpp +21 -0
  309. data/ext/zeromq/src/precompiled.hpp +47 -0
  310. data/ext/zeromq/src/proxy.cpp +150 -0
  311. data/ext/zeromq/src/proxy.hpp +32 -0
  312. data/ext/zeromq/src/pub.cpp +57 -0
  313. data/ext/zeromq/src/pub.hpp +69 -0
  314. data/ext/zeromq/src/pull.cpp +79 -0
  315. data/ext/zeromq/src/pull.hpp +81 -0
  316. data/ext/zeromq/src/push.cpp +76 -0
  317. data/ext/zeromq/src/push.hpp +80 -0
  318. data/ext/zeromq/src/random.cpp +52 -0
  319. data/ext/zeromq/src/random.hpp +37 -0
  320. data/ext/zeromq/src/reaper.cpp +117 -0
  321. data/ext/zeromq/src/reaper.hpp +80 -0
  322. data/ext/zeromq/src/rep.cpp +137 -0
  323. data/ext/zeromq/src/rep.hpp +80 -0
  324. data/ext/zeromq/src/req.cpp +185 -0
  325. data/ext/zeromq/src/req.hpp +91 -0
  326. data/ext/zeromq/src/router.cpp +364 -0
  327. data/ext/zeromq/src/router.hpp +138 -0
  328. data/ext/zeromq/src/select.cpp +216 -0
  329. data/ext/zeromq/src/select.hpp +126 -0
  330. data/ext/zeromq/src/session_base.cpp +503 -0
  331. data/ext/zeromq/src/session_base.hpp +156 -0
  332. data/ext/zeromq/src/signaler.cpp +406 -0
  333. data/ext/zeromq/src/signaler.hpp +63 -0
  334. data/ext/zeromq/src/socket_base.cpp +1236 -0
  335. data/ext/zeromq/src/socket_base.hpp +255 -0
  336. data/ext/zeromq/src/stdint.hpp +63 -0
  337. data/ext/zeromq/src/stream_engine.cpp +594 -0
  338. data/ext/zeromq/src/stream_engine.hpp +149 -0
  339. data/ext/zeromq/src/sub.cpp +93 -0
  340. data/ext/zeromq/src/sub.hpp +71 -0
  341. data/ext/zeromq/src/tcp.cpp +131 -0
  342. data/ext/zeromq/src/tcp.hpp +38 -0
  343. data/ext/zeromq/src/tcp_address.cpp +613 -0
  344. data/ext/zeromq/src/tcp_address.hpp +100 -0
  345. data/ext/zeromq/src/tcp_connecter.cpp +319 -0
  346. data/ext/zeromq/src/tcp_connecter.hpp +123 -0
  347. data/ext/zeromq/src/tcp_listener.cpp +293 -0
  348. data/ext/zeromq/src/tcp_listener.hpp +91 -0
  349. data/ext/zeromq/src/thread.cpp +107 -0
  350. data/ext/zeromq/src/thread.hpp +79 -0
  351. data/ext/zeromq/src/trie.cpp +337 -0
  352. data/ext/zeromq/src/trie.hpp +79 -0
  353. data/ext/zeromq/src/v1_decoder.cpp +162 -0
  354. data/ext/zeromq/src/v1_decoder.hpp +68 -0
  355. data/ext/zeromq/src/v1_encoder.cpp +103 -0
  356. data/ext/zeromq/src/v1_encoder.hpp +60 -0
  357. data/ext/zeromq/src/v1_protocol.hpp +43 -0
  358. data/ext/zeromq/src/version.rc.in +93 -0
  359. data/ext/zeromq/src/windows.hpp +181 -0
  360. data/ext/zeromq/src/wire.hpp +99 -0
  361. data/ext/zeromq/src/xpub.cpp +200 -0
  362. data/ext/zeromq/src/xpub.hpp +110 -0
  363. data/ext/zeromq/src/xsub.cpp +242 -0
  364. data/ext/zeromq/src/xsub.hpp +108 -0
  365. data/ext/zeromq/src/ypipe.hpp +210 -0
  366. data/ext/zeromq/src/yqueue.hpp +199 -0
  367. data/ext/zeromq/src/zmq.cpp +1058 -0
  368. data/ext/zeromq/src/zmq_utils.cpp +61 -0
  369. data/ext/zeromq/tests/Makefile.am +55 -0
  370. data/ext/zeromq/tests/test_connect_delay.cpp +260 -0
  371. data/ext/zeromq/tests/test_connect_resolve.cpp +54 -0
  372. data/ext/zeromq/tests/test_disconnect_inproc.cpp +120 -0
  373. data/ext/zeromq/tests/test_hwm.cpp +83 -0
  374. data/ext/zeromq/tests/test_invalid_rep.cpp +92 -0
  375. data/ext/zeromq/tests/test_last_endpoint.cpp +60 -0
  376. data/ext/zeromq/tests/test_monitor.cpp +289 -0
  377. data/ext/zeromq/tests/test_msg_flags.cpp +78 -0
  378. data/ext/zeromq/tests/test_pair_inproc.cpp +53 -0
  379. data/ext/zeromq/tests/test_pair_ipc.cpp +53 -0
  380. data/ext/zeromq/tests/test_pair_tcp.cpp +54 -0
  381. data/ext/zeromq/tests/test_reqrep_device.cpp +143 -0
  382. data/ext/zeromq/tests/test_reqrep_inproc.cpp +53 -0
  383. data/ext/zeromq/tests/test_reqrep_ipc.cpp +53 -0
  384. data/ext/zeromq/tests/test_reqrep_tcp.cpp +54 -0
  385. data/ext/zeromq/tests/test_router_mandatory.cpp +62 -0
  386. data/ext/zeromq/tests/test_shutdown_stress.cpp +93 -0
  387. data/ext/zeromq/tests/test_sub_forward.cpp +99 -0
  388. data/ext/zeromq/tests/test_term_endpoint.cpp +118 -0
  389. data/ext/zeromq/tests/test_timeo.cpp +119 -0
  390. data/ext/zeromq/tests/testutil.hpp +77 -0
  391. data/ext/zeromq/version.sh +21 -0
  392. data/lib/zmq/version.rb +1 -1
  393. data/rbczmq.gemspec +16 -3
  394. data/test/test_socket.rb +13 -1
  395. metadata +398 -9
  396. checksums.yaml +0 -15
  397. data/ext/czmq-1.4.1.tar.gz +0 -0
  398. data/ext/zeromq-3.2.3.tar.gz +0 -0
@@ -0,0 +1,706 @@
1
+ /*
2
+ Copyright (c) 2009-2011 250bpm s.r.o.
3
+ Copyright (c) 2007-2009 iMatix Corporation
4
+ Copyright (c) 2010-2011 Miru Limited
5
+ Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
6
+
7
+ This file is part of 0MQ.
8
+
9
+ 0MQ is free software; you can redistribute it and/or modify it under
10
+ the terms of the GNU Lesser General Public License as published by
11
+ the Free Software Foundation; either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ 0MQ is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General Public License
20
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+
23
+ #include "platform.hpp"
24
+
25
+ #ifdef ZMQ_HAVE_OPENPGM
26
+
27
+ #ifdef ZMQ_HAVE_WINDOWS
28
+ #include "windows.hpp"
29
+ #endif
30
+
31
+ #ifdef ZMQ_HAVE_LINUX
32
+ #include <poll.h>
33
+ #endif
34
+
35
+ #include <stdlib.h>
36
+ #include <string.h>
37
+ #include <string>
38
+
39
+ #include "options.hpp"
40
+ #include "pgm_socket.hpp"
41
+ #include "config.hpp"
42
+ #include "err.hpp"
43
+ #include "random.hpp"
44
+ #include "stdint.hpp"
45
+
46
+ #ifndef MSG_ERRQUEUE
47
+ #define MSG_ERRQUEUE 0x2000
48
+ #endif
49
+
50
+ zmq::pgm_socket_t::pgm_socket_t (bool receiver_, const options_t &options_) :
51
+ sock (NULL),
52
+ options (options_),
53
+ receiver (receiver_),
54
+ pgm_msgv (NULL),
55
+ pgm_msgv_len (0),
56
+ nbytes_rec (0),
57
+ nbytes_processed (0),
58
+ pgm_msgv_processed (0)
59
+ {
60
+ }
61
+
62
+ // Resolve PGM socket address.
63
+ // network_ of the form <interface & multicast group decls>:<IP port>
64
+ // e.g. eth0;239.192.0.1:7500
65
+ // link-local;224.250.0.1,224.250.0.2;224.250.0.3:8000
66
+ // ;[fe80::1%en0]:7500
67
+ int zmq::pgm_socket_t::init_address (const char *network_,
68
+ struct pgm_addrinfo_t **res, uint16_t *port_number)
69
+ {
70
+ // Parse port number, start from end for IPv6
71
+ const char *port_delim = strrchr (network_, ':');
72
+ if (!port_delim) {
73
+ errno = EINVAL;
74
+ return -1;
75
+ }
76
+
77
+ *port_number = atoi (port_delim + 1);
78
+
79
+ char network [256];
80
+ if (port_delim - network_ >= (int) sizeof (network) - 1) {
81
+ errno = EINVAL;
82
+ return -1;
83
+ }
84
+ memset (network, '\0', sizeof (network));
85
+ memcpy (network, network_, port_delim - network_);
86
+
87
+ pgm_error_t *pgm_error = NULL;
88
+ struct pgm_addrinfo_t hints;
89
+
90
+ memset (&hints, 0, sizeof (hints));
91
+ hints.ai_family = AF_UNSPEC;
92
+ if (!pgm_getaddrinfo (network, NULL, res, &pgm_error)) {
93
+
94
+ // Invalid parameters don't set pgm_error_t.
95
+ zmq_assert (pgm_error != NULL);
96
+ if (pgm_error->domain == PGM_ERROR_DOMAIN_IF &&
97
+
98
+ // NB: cannot catch EAI_BADFLAGS.
99
+ ( pgm_error->code != PGM_ERROR_SERVICE &&
100
+ pgm_error->code != PGM_ERROR_SOCKTNOSUPPORT)) {
101
+
102
+ // User, host, or network configuration or transient error.
103
+ pgm_error_free (pgm_error);
104
+ errno = EINVAL;
105
+ return -1;
106
+ }
107
+
108
+ // Fatal OpenPGM internal error.
109
+ zmq_assert (false);
110
+ }
111
+ return 0;
112
+ }
113
+
114
+ // Create, bind and connect PGM socket.
115
+ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
116
+ {
117
+ // Can not open transport before destroying old one.
118
+ zmq_assert (sock == NULL);
119
+ zmq_assert (options.rate > 0);
120
+
121
+ // Zero counter used in msgrecv.
122
+ nbytes_rec = 0;
123
+ nbytes_processed = 0;
124
+ pgm_msgv_processed = 0;
125
+
126
+ uint16_t port_number;
127
+ struct pgm_addrinfo_t *res = NULL;
128
+ sa_family_t sa_family;
129
+
130
+ pgm_error_t *pgm_error = NULL;
131
+
132
+ if (init_address(network_, &res, &port_number) < 0) {
133
+ goto err_abort;
134
+ }
135
+
136
+ zmq_assert (res != NULL);
137
+
138
+ // Pick up detected IP family.
139
+ sa_family = res->ai_send_addrs[0].gsr_group.ss_family;
140
+
141
+ // Create IP/PGM or UDP/PGM socket.
142
+ if (udp_encapsulation_) {
143
+ if (!pgm_socket (&sock, sa_family, SOCK_SEQPACKET, IPPROTO_UDP,
144
+ &pgm_error)) {
145
+
146
+ // Invalid parameters don't set pgm_error_t.
147
+ zmq_assert (pgm_error != NULL);
148
+ if (pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET && (
149
+ pgm_error->code != PGM_ERROR_BADF &&
150
+ pgm_error->code != PGM_ERROR_FAULT &&
151
+ pgm_error->code != PGM_ERROR_NOPROTOOPT &&
152
+ pgm_error->code != PGM_ERROR_FAILED))
153
+
154
+ // User, host, or network configuration or transient error.
155
+ goto err_abort;
156
+
157
+ // Fatal OpenPGM internal error.
158
+ zmq_assert (false);
159
+ }
160
+
161
+ // All options are of data type int
162
+ const int encapsulation_port = port_number;
163
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_UDP_ENCAP_UCAST_PORT,
164
+ &encapsulation_port, sizeof (encapsulation_port)))
165
+ goto err_abort;
166
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_UDP_ENCAP_MCAST_PORT,
167
+ &encapsulation_port, sizeof (encapsulation_port)))
168
+ goto err_abort;
169
+ }
170
+ else {
171
+ if (!pgm_socket (&sock, sa_family, SOCK_SEQPACKET, IPPROTO_PGM,
172
+ &pgm_error)) {
173
+
174
+ // Invalid parameters don't set pgm_error_t.
175
+ zmq_assert (pgm_error != NULL);
176
+ if (pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET && (
177
+ pgm_error->code != PGM_ERROR_BADF &&
178
+ pgm_error->code != PGM_ERROR_FAULT &&
179
+ pgm_error->code != PGM_ERROR_NOPROTOOPT &&
180
+ pgm_error->code != PGM_ERROR_FAILED))
181
+
182
+ // User, host, or network configuration or transient error.
183
+ goto err_abort;
184
+
185
+ // Fatal OpenPGM internal error.
186
+ zmq_assert (false);
187
+ }
188
+ }
189
+
190
+ {
191
+ const int rcvbuf = (int) options.rcvbuf;
192
+ if (rcvbuf) {
193
+ if (!pgm_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &rcvbuf,
194
+ sizeof (rcvbuf)))
195
+ goto err_abort;
196
+ }
197
+
198
+ const int sndbuf = (int) options.sndbuf;
199
+ if (sndbuf) {
200
+ if (!pgm_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, &sndbuf,
201
+ sizeof (sndbuf)))
202
+ goto err_abort;
203
+ }
204
+
205
+ const int max_tpdu = (int) pgm_max_tpdu;
206
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MTU, &max_tpdu,
207
+ sizeof (max_tpdu)))
208
+ goto err_abort;
209
+ }
210
+
211
+ if (receiver) {
212
+ const int recv_only = 1,
213
+ rxw_max_tpdu = (int) pgm_max_tpdu,
214
+ rxw_sqns = compute_sqns (rxw_max_tpdu),
215
+ peer_expiry = pgm_secs (300),
216
+ spmr_expiry = pgm_msecs (25),
217
+ nak_bo_ivl = pgm_msecs (50),
218
+ nak_rpt_ivl = pgm_msecs (200),
219
+ nak_rdata_ivl = pgm_msecs (200),
220
+ nak_data_retries = 50,
221
+ nak_ncf_retries = 50;
222
+
223
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_RECV_ONLY, &recv_only,
224
+ sizeof (recv_only)) ||
225
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_RXW_SQNS, &rxw_sqns,
226
+ sizeof (rxw_sqns)) ||
227
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_PEER_EXPIRY, &peer_expiry,
228
+ sizeof (peer_expiry)) ||
229
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_SPMR_EXPIRY, &spmr_expiry,
230
+ sizeof (spmr_expiry)) ||
231
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_NAK_BO_IVL, &nak_bo_ivl,
232
+ sizeof (nak_bo_ivl)) ||
233
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_NAK_RPT_IVL, &nak_rpt_ivl,
234
+ sizeof (nak_rpt_ivl)) ||
235
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_NAK_RDATA_IVL,
236
+ &nak_rdata_ivl, sizeof (nak_rdata_ivl)) ||
237
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_NAK_DATA_RETRIES,
238
+ &nak_data_retries, sizeof (nak_data_retries)) ||
239
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_NAK_NCF_RETRIES,
240
+ &nak_ncf_retries, sizeof (nak_ncf_retries)))
241
+ goto err_abort;
242
+ } else {
243
+ const int send_only = 1,
244
+ max_rte = (int) ((options.rate * 1000) / 8),
245
+ txw_max_tpdu = (int) pgm_max_tpdu,
246
+ txw_sqns = compute_sqns (txw_max_tpdu),
247
+ ambient_spm = pgm_secs (30),
248
+ heartbeat_spm[] = { pgm_msecs (100),
249
+ pgm_msecs (100),
250
+ pgm_msecs (100),
251
+ pgm_msecs (100),
252
+ pgm_msecs (1300),
253
+ pgm_secs (7),
254
+ pgm_secs (16),
255
+ pgm_secs (25),
256
+ pgm_secs (30) };
257
+
258
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_SEND_ONLY,
259
+ &send_only, sizeof (send_only)) ||
260
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_ODATA_MAX_RTE,
261
+ &max_rte, sizeof (max_rte)) ||
262
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_TXW_SQNS,
263
+ &txw_sqns, sizeof (txw_sqns)) ||
264
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_AMBIENT_SPM,
265
+ &ambient_spm, sizeof (ambient_spm)) ||
266
+ !pgm_setsockopt (sock, IPPROTO_PGM, PGM_HEARTBEAT_SPM,
267
+ &heartbeat_spm, sizeof (heartbeat_spm)))
268
+ goto err_abort;
269
+ }
270
+
271
+ // PGM transport GSI.
272
+ struct pgm_sockaddr_t addr;
273
+
274
+ memset (&addr, 0, sizeof(addr));
275
+ addr.sa_port = port_number;
276
+ addr.sa_addr.sport = DEFAULT_DATA_SOURCE_PORT;
277
+
278
+ // Create random GSI.
279
+ uint32_t buf [2];
280
+ buf [0] = generate_random ();
281
+ buf [1] = generate_random ();
282
+ if (!pgm_gsi_create_from_data (&addr.sa_addr.gsi, (uint8_t*) buf, 8))
283
+ goto err_abort;
284
+
285
+
286
+ // Bind a transport to the specified network devices.
287
+ struct pgm_interface_req_t if_req;
288
+ memset (&if_req, 0, sizeof(if_req));
289
+ if_req.ir_interface = res->ai_recv_addrs[0].gsr_interface;
290
+ if_req.ir_scope_id = 0;
291
+ if (AF_INET6 == sa_family) {
292
+ struct sockaddr_in6 sa6;
293
+ memcpy (&sa6, &res->ai_recv_addrs[0].gsr_group, sizeof (sa6));
294
+ if_req.ir_scope_id = sa6.sin6_scope_id;
295
+ }
296
+ if (!pgm_bind3 (sock, &addr, sizeof (addr), &if_req, sizeof (if_req),
297
+ &if_req, sizeof (if_req), &pgm_error)) {
298
+
299
+ // Invalid parameters don't set pgm_error_t.
300
+ zmq_assert (pgm_error != NULL);
301
+ if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
302
+ pgm_error->domain == PGM_ERROR_DOMAIN_IF) && (
303
+ pgm_error->code != PGM_ERROR_INVAL &&
304
+ pgm_error->code != PGM_ERROR_BADF &&
305
+ pgm_error->code != PGM_ERROR_FAULT))
306
+
307
+ // User, host, or network configuration or transient error.
308
+ goto err_abort;
309
+
310
+ // Fatal OpenPGM internal error.
311
+ zmq_assert (false);
312
+ }
313
+
314
+ // Join IP multicast groups.
315
+ for (unsigned i = 0; i < res->ai_recv_addrs_len; i++) {
316
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_JOIN_GROUP,
317
+ &res->ai_recv_addrs [i], sizeof (struct group_req)))
318
+ goto err_abort;
319
+ }
320
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_SEND_GROUP,
321
+ &res->ai_send_addrs [0], sizeof (struct group_req)))
322
+ goto err_abort;
323
+
324
+ pgm_freeaddrinfo (res);
325
+ res = NULL;
326
+
327
+ // Set IP level parameters.
328
+ {
329
+ // Multicast loopback disabled by default
330
+ const int multicast_loop = 0;
331
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MULTICAST_LOOP,
332
+ &multicast_loop, sizeof (multicast_loop)))
333
+ goto err_abort;
334
+
335
+ const int multicast_hops = options.multicast_hops;
336
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MULTICAST_HOPS,
337
+ &multicast_hops, sizeof (multicast_hops)))
338
+ goto err_abort;
339
+
340
+ // Expedited Forwarding PHB for network elements, no ECN.
341
+ // Ignore return value due to varied runtime support.
342
+ const int dscp = 0x2e << 2;
343
+ if (AF_INET6 != sa_family)
344
+ pgm_setsockopt (sock, IPPROTO_PGM, PGM_TOS,
345
+ &dscp, sizeof (dscp));
346
+
347
+ const int nonblocking = 1;
348
+ if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_NOBLOCK,
349
+ &nonblocking, sizeof (nonblocking)))
350
+ goto err_abort;
351
+ }
352
+
353
+ // Connect PGM transport to start state machine.
354
+ if (!pgm_connect (sock, &pgm_error)) {
355
+
356
+ // Invalid parameters don't set pgm_error_t.
357
+ zmq_assert (pgm_error != NULL);
358
+ goto err_abort;
359
+ }
360
+
361
+ // For receiver transport preallocate pgm_msgv array.
362
+ if (receiver) {
363
+ zmq_assert (in_batch_size > 0);
364
+ size_t max_tsdu_size = get_max_tsdu_size ();
365
+ pgm_msgv_len = (int) in_batch_size / max_tsdu_size;
366
+ if ((int) in_batch_size % max_tsdu_size)
367
+ pgm_msgv_len++;
368
+ zmq_assert (pgm_msgv_len);
369
+
370
+ pgm_msgv = (pgm_msgv_t*) malloc (sizeof (pgm_msgv_t) * pgm_msgv_len);
371
+ alloc_assert (pgm_msgv);
372
+ }
373
+
374
+ return 0;
375
+
376
+ err_abort:
377
+ if (sock != NULL) {
378
+ pgm_close (sock, FALSE);
379
+ sock = NULL;
380
+ }
381
+ if (res != NULL) {
382
+ pgm_freeaddrinfo (res);
383
+ res = NULL;
384
+ }
385
+ if (pgm_error != NULL) {
386
+ pgm_error_free (pgm_error);
387
+ pgm_error = NULL;
388
+ }
389
+ errno = EINVAL;
390
+ return -1;
391
+ }
392
+
393
+ zmq::pgm_socket_t::~pgm_socket_t ()
394
+ {
395
+ if (pgm_msgv)
396
+ free (pgm_msgv);
397
+ if (sock)
398
+ pgm_close (sock, TRUE);
399
+ }
400
+
401
+ // Get receiver fds. receive_fd_ is signaled for incoming packets,
402
+ // waiting_pipe_fd_ is signaled for state driven events and data.
403
+ void zmq::pgm_socket_t::get_receiver_fds (fd_t *receive_fd_,
404
+ fd_t *waiting_pipe_fd_)
405
+ {
406
+ socklen_t socklen;
407
+ bool rc;
408
+
409
+ zmq_assert (receive_fd_);
410
+ zmq_assert (waiting_pipe_fd_);
411
+
412
+ socklen = sizeof (*receive_fd_);
413
+ rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_RECV_SOCK, receive_fd_,
414
+ &socklen);
415
+ zmq_assert (rc);
416
+ zmq_assert (socklen == sizeof (*receive_fd_));
417
+
418
+ socklen = sizeof (*waiting_pipe_fd_);
419
+ rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_PENDING_SOCK, waiting_pipe_fd_,
420
+ &socklen);
421
+ zmq_assert (rc);
422
+ zmq_assert (socklen == sizeof (*waiting_pipe_fd_));
423
+ }
424
+
425
+ // Get fds and store them into user allocated memory.
426
+ // send_fd is for non-blocking send wire notifications.
427
+ // receive_fd_ is for incoming back-channel protocol packets.
428
+ // rdata_notify_fd_ is raised for waiting repair transmissions.
429
+ // pending_notify_fd_ is for state driven events.
430
+ void zmq::pgm_socket_t::get_sender_fds (fd_t *send_fd_, fd_t *receive_fd_,
431
+ fd_t *rdata_notify_fd_, fd_t *pending_notify_fd_)
432
+ {
433
+ socklen_t socklen;
434
+ bool rc;
435
+
436
+ zmq_assert (send_fd_);
437
+ zmq_assert (receive_fd_);
438
+ zmq_assert (rdata_notify_fd_);
439
+ zmq_assert (pending_notify_fd_);
440
+
441
+ socklen = sizeof (*send_fd_);
442
+ rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_SEND_SOCK, send_fd_, &socklen);
443
+ zmq_assert (rc);
444
+ zmq_assert (socklen == sizeof (*receive_fd_));
445
+
446
+ socklen = sizeof (*receive_fd_);
447
+ rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_RECV_SOCK, receive_fd_,
448
+ &socklen);
449
+ zmq_assert (rc);
450
+ zmq_assert (socklen == sizeof (*receive_fd_));
451
+
452
+ socklen = sizeof (*rdata_notify_fd_);
453
+ rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_REPAIR_SOCK, rdata_notify_fd_,
454
+ &socklen);
455
+ zmq_assert (rc);
456
+ zmq_assert (socklen == sizeof (*rdata_notify_fd_));
457
+
458
+ socklen = sizeof (*pending_notify_fd_);
459
+ rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_PENDING_SOCK,
460
+ pending_notify_fd_, &socklen);
461
+ zmq_assert (rc);
462
+ zmq_assert (socklen == sizeof (*pending_notify_fd_));
463
+ }
464
+
465
+ // Send one APDU, transmit window owned memory.
466
+ // data_len_ must be less than one TPDU.
467
+ size_t zmq::pgm_socket_t::send (unsigned char *data_, size_t data_len_)
468
+ {
469
+ size_t nbytes = 0;
470
+
471
+ const int status = pgm_send (sock, data_, data_len_, &nbytes);
472
+
473
+ // We have to write all data as one packet.
474
+ if (nbytes > 0) {
475
+ zmq_assert (status == PGM_IO_STATUS_NORMAL);
476
+ zmq_assert (nbytes == data_len_);
477
+ } else {
478
+ zmq_assert (status == PGM_IO_STATUS_RATE_LIMITED ||
479
+ status == PGM_IO_STATUS_WOULD_BLOCK);
480
+
481
+ if (status == PGM_IO_STATUS_RATE_LIMITED)
482
+ errno = ENOMEM;
483
+ else
484
+ errno = EBUSY;
485
+ }
486
+
487
+ // Save return value.
488
+ last_tx_status = status;
489
+
490
+ return nbytes;
491
+ }
492
+
493
+ long zmq::pgm_socket_t::get_rx_timeout ()
494
+ {
495
+ if (last_rx_status != PGM_IO_STATUS_RATE_LIMITED &&
496
+ last_rx_status != PGM_IO_STATUS_TIMER_PENDING)
497
+ return -1;
498
+
499
+ struct timeval tv;
500
+ socklen_t optlen = sizeof (tv);
501
+ const bool rc = pgm_getsockopt (sock, IPPROTO_PGM,
502
+ last_rx_status == PGM_IO_STATUS_RATE_LIMITED ? PGM_RATE_REMAIN :
503
+ PGM_TIME_REMAIN, &tv, &optlen);
504
+ zmq_assert (rc);
505
+
506
+ const long timeout = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
507
+
508
+ return timeout;
509
+ }
510
+
511
+ long zmq::pgm_socket_t::get_tx_timeout ()
512
+ {
513
+ if (last_tx_status != PGM_IO_STATUS_RATE_LIMITED)
514
+ return -1;
515
+
516
+ struct timeval tv;
517
+ socklen_t optlen = sizeof (tv);
518
+ const bool rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_RATE_REMAIN, &tv,
519
+ &optlen);
520
+ zmq_assert (rc);
521
+
522
+ const long timeout = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
523
+
524
+ return timeout;
525
+ }
526
+
527
+ // Return max TSDU size without fragmentation from current PGM transport.
528
+ size_t zmq::pgm_socket_t::get_max_tsdu_size ()
529
+ {
530
+ int max_tsdu = 0;
531
+ socklen_t optlen = sizeof (max_tsdu);
532
+
533
+ bool rc = pgm_getsockopt (sock, IPPROTO_PGM, PGM_MSS, &max_tsdu, &optlen);
534
+ zmq_assert (rc);
535
+ zmq_assert (optlen == sizeof (max_tsdu));
536
+ return (size_t) max_tsdu;
537
+ }
538
+
539
+ // pgm_recvmsgv is called to fill the pgm_msgv array up to pgm_msgv_len.
540
+ // In subsequent calls data from pgm_msgv structure are returned.
541
+ ssize_t zmq::pgm_socket_t::receive (void **raw_data_, const pgm_tsi_t **tsi_)
542
+ {
543
+ size_t raw_data_len = 0;
544
+
545
+ // We just sent all data from pgm_transport_recvmsgv up
546
+ // and have to return 0 that another engine in this thread is scheduled.
547
+ if (nbytes_rec == nbytes_processed && nbytes_rec > 0) {
548
+
549
+ // Reset all the counters.
550
+ nbytes_rec = 0;
551
+ nbytes_processed = 0;
552
+ pgm_msgv_processed = 0;
553
+ errno = EAGAIN;
554
+ return 0;
555
+ }
556
+
557
+ // If we have are going first time or if we have processed all pgm_msgv_t
558
+ // structure previously read from the pgm socket.
559
+ if (nbytes_rec == nbytes_processed) {
560
+
561
+ // Check program flow.
562
+ zmq_assert (pgm_msgv_processed == 0);
563
+ zmq_assert (nbytes_processed == 0);
564
+ zmq_assert (nbytes_rec == 0);
565
+
566
+ // Receive a vector of Application Protocol Domain Unit's (APDUs)
567
+ // from the transport.
568
+ pgm_error_t *pgm_error = NULL;
569
+
570
+ const int status = pgm_recvmsgv (sock, pgm_msgv,
571
+ pgm_msgv_len, MSG_ERRQUEUE, &nbytes_rec, &pgm_error);
572
+
573
+ // Invalid parameters.
574
+ zmq_assert (status != PGM_IO_STATUS_ERROR);
575
+
576
+ last_rx_status = status;
577
+
578
+ // In a case when no ODATA/RDATA fired POLLIN event (SPM...)
579
+ // pgm_recvmsg returns PGM_IO_STATUS_TIMER_PENDING.
580
+ if (status == PGM_IO_STATUS_TIMER_PENDING) {
581
+
582
+ zmq_assert (nbytes_rec == 0);
583
+
584
+ // In case if no RDATA/ODATA caused POLLIN 0 is
585
+ // returned.
586
+ nbytes_rec = 0;
587
+ errno = EBUSY;
588
+ return 0;
589
+ }
590
+
591
+ // Send SPMR, NAK, ACK is rate limited.
592
+ if (status == PGM_IO_STATUS_RATE_LIMITED) {
593
+
594
+ zmq_assert (nbytes_rec == 0);
595
+
596
+ // In case if no RDATA/ODATA caused POLLIN 0 is returned.
597
+ nbytes_rec = 0;
598
+ errno = ENOMEM;
599
+ return 0;
600
+ }
601
+
602
+ // No peers and hence no incoming packets.
603
+ if (status == PGM_IO_STATUS_WOULD_BLOCK) {
604
+
605
+ zmq_assert (nbytes_rec == 0);
606
+
607
+ // In case if no RDATA/ODATA caused POLLIN 0 is returned.
608
+ nbytes_rec = 0;
609
+ errno = EAGAIN;
610
+ return 0;
611
+ }
612
+
613
+ // Data loss.
614
+ if (status == PGM_IO_STATUS_RESET) {
615
+
616
+ struct pgm_sk_buff_t* skb = pgm_msgv [0].msgv_skb [0];
617
+
618
+ // Save lost data TSI.
619
+ *tsi_ = &skb->tsi;
620
+ nbytes_rec = 0;
621
+
622
+ // In case of dala loss -1 is returned.
623
+ errno = EINVAL;
624
+ pgm_free_skb (skb);
625
+ return -1;
626
+ }
627
+
628
+ zmq_assert (status == PGM_IO_STATUS_NORMAL);
629
+ }
630
+ else
631
+ {
632
+ zmq_assert (pgm_msgv_processed <= pgm_msgv_len);
633
+ }
634
+
635
+ // Zero byte payloads are valid in PGM, but not 0MQ protocol.
636
+ zmq_assert (nbytes_rec > 0);
637
+
638
+ // Only one APDU per pgm_msgv_t structure is allowed.
639
+ zmq_assert (pgm_msgv [pgm_msgv_processed].msgv_len == 1);
640
+
641
+ struct pgm_sk_buff_t* skb =
642
+ pgm_msgv [pgm_msgv_processed].msgv_skb [0];
643
+
644
+ // Take pointers from pgm_msgv_t structure.
645
+ *raw_data_ = skb->data;
646
+ raw_data_len = skb->len;
647
+
648
+ // Save current TSI.
649
+ *tsi_ = &skb->tsi;
650
+
651
+ // Move the the next pgm_msgv_t structure.
652
+ pgm_msgv_processed++;
653
+ zmq_assert (pgm_msgv_processed <= pgm_msgv_len);
654
+ nbytes_processed +=raw_data_len;
655
+
656
+ return raw_data_len;
657
+ }
658
+
659
+ void zmq::pgm_socket_t::process_upstream ()
660
+ {
661
+ pgm_msgv_t dummy_msg;
662
+
663
+ size_t dummy_bytes = 0;
664
+ pgm_error_t *pgm_error = NULL;
665
+
666
+ const int status = pgm_recvmsgv (sock, &dummy_msg,
667
+ 1, MSG_ERRQUEUE, &dummy_bytes, &pgm_error);
668
+
669
+ // Invalid parameters.
670
+ zmq_assert (status != PGM_IO_STATUS_ERROR);
671
+
672
+ // No data should be returned.
673
+ zmq_assert (dummy_bytes == 0 && (status == PGM_IO_STATUS_TIMER_PENDING ||
674
+ status == PGM_IO_STATUS_RATE_LIMITED ||
675
+ status == PGM_IO_STATUS_WOULD_BLOCK));
676
+
677
+ last_rx_status = status;
678
+
679
+ if (status == PGM_IO_STATUS_TIMER_PENDING)
680
+ errno = EBUSY;
681
+ else if (status == PGM_IO_STATUS_RATE_LIMITED)
682
+ errno = ENOMEM;
683
+ else
684
+ errno = EAGAIN;
685
+ }
686
+
687
+ int zmq::pgm_socket_t::compute_sqns (int tpdu_)
688
+ {
689
+ // Convert rate into B/ms.
690
+ uint64_t rate = uint64_t (options.rate) / 8;
691
+
692
+ // Compute the size of the buffer in bytes.
693
+ uint64_t size = uint64_t (options.recovery_ivl) * rate;
694
+
695
+ // Translate the size into number of packets.
696
+ uint64_t sqns = size / tpdu_;
697
+
698
+ // Buffer should be able to hold at least one packet.
699
+ if (sqns == 0)
700
+ sqns = 1;
701
+
702
+ return (int) sqns;
703
+ }
704
+
705
+ #endif
706
+