libzmq 0.0.1

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 (300) hide show
  1. data/LICENSE +703 -0
  2. data/README.md +31 -0
  3. data/lib/libzmq.rb +17 -0
  4. data/lib/libzmq/ffi-rzmq.rb +3 -0
  5. data/libzmq/Makefile +5 -0
  6. data/libzmq/extconf.rb +24 -0
  7. data/libzmq/zeromq-2.1.7/AUTHORS +92 -0
  8. data/libzmq/zeromq-2.1.7/COPYING +674 -0
  9. data/libzmq/zeromq-2.1.7/COPYING.LESSER +206 -0
  10. data/libzmq/zeromq-2.1.7/ChangeLog +15620 -0
  11. data/libzmq/zeromq-2.1.7/INSTALL +237 -0
  12. data/libzmq/zeromq-2.1.7/MAINTAINERS +56 -0
  13. data/libzmq/zeromq-2.1.7/Makefile.am +42 -0
  14. data/libzmq/zeromq-2.1.7/Makefile.in +779 -0
  15. data/libzmq/zeromq-2.1.7/NEWS +275 -0
  16. data/libzmq/zeromq-2.1.7/README +39 -0
  17. data/libzmq/zeromq-2.1.7/acinclude.m4 +582 -0
  18. data/libzmq/zeromq-2.1.7/aclocal.m4 +1206 -0
  19. data/libzmq/zeromq-2.1.7/autogen.sh +45 -0
  20. data/libzmq/zeromq-2.1.7/builds/msvc/Makefile.am +8 -0
  21. data/libzmq/zeromq-2.1.7/builds/msvc/Makefile.in +390 -0
  22. data/libzmq/zeromq-2.1.7/builds/msvc/c_local_lat/c_local_lat.vcproj +176 -0
  23. data/libzmq/zeromq-2.1.7/builds/msvc/c_local_thr/c_local_thr.vcproj +176 -0
  24. data/libzmq/zeromq-2.1.7/builds/msvc/c_remote_lat/c_remote_lat.vcproj +176 -0
  25. data/libzmq/zeromq-2.1.7/builds/msvc/c_remote_thr/c_remote_thr.vcproj +176 -0
  26. data/libzmq/zeromq-2.1.7/builds/msvc/libzmq/libzmq.vcproj +783 -0
  27. data/libzmq/zeromq-2.1.7/builds/msvc/msvc.sln +89 -0
  28. data/libzmq/zeromq-2.1.7/builds/msvc/platform.hpp +32 -0
  29. data/libzmq/zeromq-2.1.7/builds/redhat/zeromq.spec.in +139 -0
  30. data/libzmq/zeromq-2.1.7/config/compile +143 -0
  31. data/libzmq/zeromq-2.1.7/config/config.guess +1502 -0
  32. data/libzmq/zeromq-2.1.7/config/config.sub +1714 -0
  33. data/libzmq/zeromq-2.1.7/config/depcomp +630 -0
  34. data/libzmq/zeromq-2.1.7/config/install-sh +520 -0
  35. data/libzmq/zeromq-2.1.7/config/libtool.m4 +7377 -0
  36. data/libzmq/zeromq-2.1.7/config/ltmain.sh +8413 -0
  37. data/libzmq/zeromq-2.1.7/config/ltoptions.m4 +368 -0
  38. data/libzmq/zeromq-2.1.7/config/ltsugar.m4 +123 -0
  39. data/libzmq/zeromq-2.1.7/config/ltversion.m4 +23 -0
  40. data/libzmq/zeromq-2.1.7/config/lt~obsolete.m4 +92 -0
  41. data/libzmq/zeromq-2.1.7/config/missing +376 -0
  42. data/libzmq/zeromq-2.1.7/configure +21645 -0
  43. data/libzmq/zeromq-2.1.7/configure.in +380 -0
  44. data/libzmq/zeromq-2.1.7/doc/Makefile.am +46 -0
  45. data/libzmq/zeromq-2.1.7/doc/Makefile.in +546 -0
  46. data/libzmq/zeromq-2.1.7/doc/asciidoc.conf +56 -0
  47. data/libzmq/zeromq-2.1.7/doc/zmq.7 +242 -0
  48. data/libzmq/zeromq-2.1.7/doc/zmq.html +846 -0
  49. data/libzmq/zeromq-2.1.7/doc/zmq.txt +218 -0
  50. data/libzmq/zeromq-2.1.7/doc/zmq_bind.3 +166 -0
  51. data/libzmq/zeromq-2.1.7/doc/zmq_bind.html +746 -0
  52. data/libzmq/zeromq-2.1.7/doc/zmq_bind.txt +91 -0
  53. data/libzmq/zeromq-2.1.7/doc/zmq_close.3 +81 -0
  54. data/libzmq/zeromq-2.1.7/doc/zmq_close.html +645 -0
  55. data/libzmq/zeromq-2.1.7/doc/zmq_close.txt +52 -0
  56. data/libzmq/zeromq-2.1.7/doc/zmq_connect.3 +161 -0
  57. data/libzmq/zeromq-2.1.7/doc/zmq_connect.html +732 -0
  58. data/libzmq/zeromq-2.1.7/doc/zmq_connect.txt +89 -0
  59. data/libzmq/zeromq-2.1.7/doc/zmq_cpp.7 +410 -0
  60. data/libzmq/zeromq-2.1.7/doc/zmq_cpp.html +765 -0
  61. data/libzmq/zeromq-2.1.7/doc/zmq_cpp.txt +212 -0
  62. data/libzmq/zeromq-2.1.7/doc/zmq_device.3 +140 -0
  63. data/libzmq/zeromq-2.1.7/doc/zmq_device.html +736 -0
  64. data/libzmq/zeromq-2.1.7/doc/zmq_device.txt +138 -0
  65. data/libzmq/zeromq-2.1.7/doc/zmq_epgm.7 +209 -0
  66. data/libzmq/zeromq-2.1.7/doc/zmq_epgm.html +749 -0
  67. data/libzmq/zeromq-2.1.7/doc/zmq_epgm.txt +162 -0
  68. data/libzmq/zeromq-2.1.7/doc/zmq_errno.3 +78 -0
  69. data/libzmq/zeromq-2.1.7/doc/zmq_errno.html +634 -0
  70. data/libzmq/zeromq-2.1.7/doc/zmq_errno.txt +50 -0
  71. data/libzmq/zeromq-2.1.7/doc/zmq_getsockopt.3 +944 -0
  72. data/libzmq/zeromq-2.1.7/doc/zmq_getsockopt.html +1713 -0
  73. data/libzmq/zeromq-2.1.7/doc/zmq_getsockopt.txt +407 -0
  74. data/libzmq/zeromq-2.1.7/doc/zmq_init.3 +71 -0
  75. data/libzmq/zeromq-2.1.7/doc/zmq_init.html +635 -0
  76. data/libzmq/zeromq-2.1.7/doc/zmq_init.txt +51 -0
  77. data/libzmq/zeromq-2.1.7/doc/zmq_inproc.7 +115 -0
  78. data/libzmq/zeromq-2.1.7/doc/zmq_inproc.html +669 -0
  79. data/libzmq/zeromq-2.1.7/doc/zmq_inproc.txt +89 -0
  80. data/libzmq/zeromq-2.1.7/doc/zmq_ipc.7 +109 -0
  81. data/libzmq/zeromq-2.1.7/doc/zmq_ipc.html +662 -0
  82. data/libzmq/zeromq-2.1.7/doc/zmq_ipc.txt +80 -0
  83. data/libzmq/zeromq-2.1.7/doc/zmq_msg_close.3 +81 -0
  84. data/libzmq/zeromq-2.1.7/doc/zmq_msg_close.html +647 -0
  85. data/libzmq/zeromq-2.1.7/doc/zmq_msg_close.txt +55 -0
  86. data/libzmq/zeromq-2.1.7/doc/zmq_msg_copy.3 +95 -0
  87. data/libzmq/zeromq-2.1.7/doc/zmq_msg_copy.html +656 -0
  88. data/libzmq/zeromq-2.1.7/doc/zmq_msg_copy.txt +57 -0
  89. data/libzmq/zeromq-2.1.7/doc/zmq_msg_data.3 +76 -0
  90. data/libzmq/zeromq-2.1.7/doc/zmq_msg_data.html +633 -0
  91. data/libzmq/zeromq-2.1.7/doc/zmq_msg_data.txt +48 -0
  92. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init.3 +110 -0
  93. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init.html +656 -0
  94. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init.txt +65 -0
  95. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init_data.3 +138 -0
  96. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init_data.html +678 -0
  97. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init_data.txt +83 -0
  98. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init_size.3 +97 -0
  99. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init_size.html +656 -0
  100. data/libzmq/zeromq-2.1.7/doc/zmq_msg_init_size.txt +58 -0
  101. data/libzmq/zeromq-2.1.7/doc/zmq_msg_move.3 +79 -0
  102. data/libzmq/zeromq-2.1.7/doc/zmq_msg_move.html +645 -0
  103. data/libzmq/zeromq-2.1.7/doc/zmq_msg_move.txt +52 -0
  104. data/libzmq/zeromq-2.1.7/doc/zmq_msg_size.3 +76 -0
  105. data/libzmq/zeromq-2.1.7/doc/zmq_msg_size.html +633 -0
  106. data/libzmq/zeromq-2.1.7/doc/zmq_msg_size.txt +48 -0
  107. data/libzmq/zeromq-2.1.7/doc/zmq_pgm.7 +209 -0
  108. data/libzmq/zeromq-2.1.7/doc/zmq_pgm.html +749 -0
  109. data/libzmq/zeromq-2.1.7/doc/zmq_pgm.txt +162 -0
  110. data/libzmq/zeromq-2.1.7/doc/zmq_poll.3 +204 -0
  111. data/libzmq/zeromq-2.1.7/doc/zmq_poll.html +755 -0
  112. data/libzmq/zeromq-2.1.7/doc/zmq_poll.txt +132 -0
  113. data/libzmq/zeromq-2.1.7/doc/zmq_recv.3 +172 -0
  114. data/libzmq/zeromq-2.1.7/doc/zmq_recv.html +746 -0
  115. data/libzmq/zeromq-2.1.7/doc/zmq_recv.txt +121 -0
  116. data/libzmq/zeromq-2.1.7/doc/zmq_send.3 +185 -0
  117. data/libzmq/zeromq-2.1.7/doc/zmq_send.html +755 -0
  118. data/libzmq/zeromq-2.1.7/doc/zmq_send.txt +120 -0
  119. data/libzmq/zeromq-2.1.7/doc/zmq_setsockopt.3 +878 -0
  120. data/libzmq/zeromq-2.1.7/doc/zmq_setsockopt.html +1603 -0
  121. data/libzmq/zeromq-2.1.7/doc/zmq_setsockopt.txt +382 -0
  122. data/libzmq/zeromq-2.1.7/doc/zmq_socket.3 +779 -0
  123. data/libzmq/zeromq-2.1.7/doc/zmq_socket.html +1424 -0
  124. data/libzmq/zeromq-2.1.7/doc/zmq_socket.txt +342 -0
  125. data/libzmq/zeromq-2.1.7/doc/zmq_strerror.3 +78 -0
  126. data/libzmq/zeromq-2.1.7/doc/zmq_strerror.html +634 -0
  127. data/libzmq/zeromq-2.1.7/doc/zmq_strerror.txt +55 -0
  128. data/libzmq/zeromq-2.1.7/doc/zmq_tcp.7 +244 -0
  129. data/libzmq/zeromq-2.1.7/doc/zmq_tcp.html +755 -0
  130. data/libzmq/zeromq-2.1.7/doc/zmq_tcp.txt +162 -0
  131. data/libzmq/zeromq-2.1.7/doc/zmq_term.3 +135 -0
  132. data/libzmq/zeromq-2.1.7/doc/zmq_term.html +672 -0
  133. data/libzmq/zeromq-2.1.7/doc/zmq_term.txt +65 -0
  134. data/libzmq/zeromq-2.1.7/doc/zmq_version.3 +78 -0
  135. data/libzmq/zeromq-2.1.7/doc/zmq_version.html +632 -0
  136. data/libzmq/zeromq-2.1.7/doc/zmq_version.txt +53 -0
  137. data/libzmq/zeromq-2.1.7/foreign/openpgm/Makefile.am +8 -0
  138. data/libzmq/zeromq-2.1.7/foreign/openpgm/Makefile.in +588 -0
  139. data/libzmq/zeromq-2.1.7/foreign/openpgm/libpgm-5.1.115~dfsg.tar.gz +0 -0
  140. data/libzmq/zeromq-2.1.7/foreign/xmlParser/xmlParser.cpp +2923 -0
  141. data/libzmq/zeromq-2.1.7/foreign/xmlParser/xmlParser.hpp +762 -0
  142. data/libzmq/zeromq-2.1.7/include/zmq.h +269 -0
  143. data/libzmq/zeromq-2.1.7/include/zmq.hpp +301 -0
  144. data/libzmq/zeromq-2.1.7/include/zmq_utils.h +64 -0
  145. data/libzmq/zeromq-2.1.7/perf/Makefile.am +21 -0
  146. data/libzmq/zeromq-2.1.7/perf/Makefile.in +566 -0
  147. data/libzmq/zeromq-2.1.7/perf/inproc_lat.cpp +232 -0
  148. data/libzmq/zeromq-2.1.7/perf/inproc_thr.cpp +246 -0
  149. data/libzmq/zeromq-2.1.7/perf/local_lat.cpp +108 -0
  150. data/libzmq/zeromq-2.1.7/perf/local_thr.cpp +138 -0
  151. data/libzmq/zeromq-2.1.7/perf/remote_lat.cpp +121 -0
  152. data/libzmq/zeromq-2.1.7/perf/remote_thr.cpp +104 -0
  153. data/libzmq/zeromq-2.1.7/src/Makefile.am +155 -0
  154. data/libzmq/zeromq-2.1.7/src/Makefile.in +1320 -0
  155. data/libzmq/zeromq-2.1.7/src/array.hpp +147 -0
  156. data/libzmq/zeromq-2.1.7/src/atomic_counter.hpp +164 -0
  157. data/libzmq/zeromq-2.1.7/src/atomic_ptr.hpp +159 -0
  158. data/libzmq/zeromq-2.1.7/src/blob.hpp +34 -0
  159. data/libzmq/zeromq-2.1.7/src/clock.cpp +118 -0
  160. data/libzmq/zeromq-2.1.7/src/clock.hpp +60 -0
  161. data/libzmq/zeromq-2.1.7/src/command.cpp +39 -0
  162. data/libzmq/zeromq-2.1.7/src/command.hpp +147 -0
  163. data/libzmq/zeromq-2.1.7/src/config.hpp +88 -0
  164. data/libzmq/zeromq-2.1.7/src/connect_session.cpp +119 -0
  165. data/libzmq/zeromq-2.1.7/src/connect_session.hpp +65 -0
  166. data/libzmq/zeromq-2.1.7/src/ctx.cpp +322 -0
  167. data/libzmq/zeromq-2.1.7/src/ctx.hpp +159 -0
  168. data/libzmq/zeromq-2.1.7/src/decoder.cpp +129 -0
  169. data/libzmq/zeromq-2.1.7/src/decoder.hpp +207 -0
  170. data/libzmq/zeromq-2.1.7/src/device.cpp +120 -0
  171. data/libzmq/zeromq-2.1.7/src/device.hpp +32 -0
  172. data/libzmq/zeromq-2.1.7/src/devpoll.cpp +190 -0
  173. data/libzmq/zeromq-2.1.7/src/devpoll.hpp +100 -0
  174. data/libzmq/zeromq-2.1.7/src/dist.cpp +200 -0
  175. data/libzmq/zeromq-2.1.7/src/dist.hpp +90 -0
  176. data/libzmq/zeromq-2.1.7/src/encoder.cpp +90 -0
  177. data/libzmq/zeromq-2.1.7/src/encoder.hpp +184 -0
  178. data/libzmq/zeromq-2.1.7/src/epoll.cpp +177 -0
  179. data/libzmq/zeromq-2.1.7/src/epoll.hpp +96 -0
  180. data/libzmq/zeromq-2.1.7/src/err.cpp +238 -0
  181. data/libzmq/zeromq-2.1.7/src/err.hpp +145 -0
  182. data/libzmq/zeromq-2.1.7/src/fd.hpp +45 -0
  183. data/libzmq/zeromq-2.1.7/src/fq.cpp +164 -0
  184. data/libzmq/zeromq-2.1.7/src/fq.hpp +80 -0
  185. data/libzmq/zeromq-2.1.7/src/i_engine.hpp +53 -0
  186. data/libzmq/zeromq-2.1.7/src/i_inout.hpp +50 -0
  187. data/libzmq/zeromq-2.1.7/src/i_poll_events.hpp +46 -0
  188. data/libzmq/zeromq-2.1.7/src/io_object.cpp +107 -0
  189. data/libzmq/zeromq-2.1.7/src/io_object.hpp +78 -0
  190. data/libzmq/zeromq-2.1.7/src/io_thread.cpp +109 -0
  191. data/libzmq/zeromq-2.1.7/src/io_thread.hpp +88 -0
  192. data/libzmq/zeromq-2.1.7/src/ip.cpp +339 -0
  193. data/libzmq/zeromq-2.1.7/src/ip.hpp +68 -0
  194. data/libzmq/zeromq-2.1.7/src/kqueue.cpp +194 -0
  195. data/libzmq/zeromq-2.1.7/src/kqueue.hpp +103 -0
  196. data/libzmq/zeromq-2.1.7/src/lb.cpp +174 -0
  197. data/libzmq/zeromq-2.1.7/src/lb.hpp +79 -0
  198. data/libzmq/zeromq-2.1.7/src/libzmq.pc.in +10 -0
  199. data/libzmq/zeromq-2.1.7/src/likely.hpp +33 -0
  200. data/libzmq/zeromq-2.1.7/src/mailbox.cpp +382 -0
  201. data/libzmq/zeromq-2.1.7/src/mailbox.hpp +62 -0
  202. data/libzmq/zeromq-2.1.7/src/msg_content.hpp +52 -0
  203. data/libzmq/zeromq-2.1.7/src/mutex.hpp +121 -0
  204. data/libzmq/zeromq-2.1.7/src/named_session.cpp +85 -0
  205. data/libzmq/zeromq-2.1.7/src/named_session.hpp +57 -0
  206. data/libzmq/zeromq-2.1.7/src/object.cpp +467 -0
  207. data/libzmq/zeromq-2.1.7/src/object.hpp +127 -0
  208. data/libzmq/zeromq-2.1.7/src/options.cpp +336 -0
  209. data/libzmq/zeromq-2.1.7/src/options.hpp +87 -0
  210. data/libzmq/zeromq-2.1.7/src/own.cpp +214 -0
  211. data/libzmq/zeromq-2.1.7/src/own.hpp +140 -0
  212. data/libzmq/zeromq-2.1.7/src/pair.cpp +180 -0
  213. data/libzmq/zeromq-2.1.7/src/pair.hpp +76 -0
  214. data/libzmq/zeromq-2.1.7/src/pgm_receiver.cpp +259 -0
  215. data/libzmq/zeromq-2.1.7/src/pgm_receiver.hpp +129 -0
  216. data/libzmq/zeromq-2.1.7/src/pgm_sender.cpp +215 -0
  217. data/libzmq/zeromq-2.1.7/src/pgm_sender.hpp +105 -0
  218. data/libzmq/zeromq-2.1.7/src/pgm_socket.cpp +705 -0
  219. data/libzmq/zeromq-2.1.7/src/pgm_socket.hpp +118 -0
  220. data/libzmq/zeromq-2.1.7/src/pipe.cpp +409 -0
  221. data/libzmq/zeromq-2.1.7/src/pipe.hpp +214 -0
  222. data/libzmq/zeromq-2.1.7/src/platform.hpp.in +228 -0
  223. data/libzmq/zeromq-2.1.7/src/poll.cpp +180 -0
  224. data/libzmq/zeromq-2.1.7/src/poll.hpp +104 -0
  225. data/libzmq/zeromq-2.1.7/src/poller.hpp +73 -0
  226. data/libzmq/zeromq-2.1.7/src/poller_base.cpp +99 -0
  227. data/libzmq/zeromq-2.1.7/src/poller_base.hpp +84 -0
  228. data/libzmq/zeromq-2.1.7/src/pub.cpp +31 -0
  229. data/libzmq/zeromq-2.1.7/src/pub.hpp +44 -0
  230. data/libzmq/zeromq-2.1.7/src/pull.cpp +61 -0
  231. data/libzmq/zeromq-2.1.7/src/pull.hpp +60 -0
  232. data/libzmq/zeromq-2.1.7/src/push.cpp +62 -0
  233. data/libzmq/zeromq-2.1.7/src/push.hpp +59 -0
  234. data/libzmq/zeromq-2.1.7/src/reaper.cpp +121 -0
  235. data/libzmq/zeromq-2.1.7/src/reaper.hpp +77 -0
  236. data/libzmq/zeromq-2.1.7/src/rep.cpp +131 -0
  237. data/libzmq/zeromq-2.1.7/src/rep.hpp +59 -0
  238. data/libzmq/zeromq-2.1.7/src/req.cpp +121 -0
  239. data/libzmq/zeromq-2.1.7/src/req.hpp +58 -0
  240. data/libzmq/zeromq-2.1.7/src/select.cpp +211 -0
  241. data/libzmq/zeromq-2.1.7/src/select.hpp +116 -0
  242. data/libzmq/zeromq-2.1.7/src/semaphore.hpp +189 -0
  243. data/libzmq/zeromq-2.1.7/src/session.cpp +347 -0
  244. data/libzmq/zeromq-2.1.7/src/session.hpp +150 -0
  245. data/libzmq/zeromq-2.1.7/src/socket_base.cpp +811 -0
  246. data/libzmq/zeromq-2.1.7/src/socket_base.hpp +207 -0
  247. data/libzmq/zeromq-2.1.7/src/stdint.hpp +63 -0
  248. data/libzmq/zeromq-2.1.7/src/sub.cpp +75 -0
  249. data/libzmq/zeromq-2.1.7/src/sub.hpp +50 -0
  250. data/libzmq/zeromq-2.1.7/src/swap.cpp +325 -0
  251. data/libzmq/zeromq-2.1.7/src/swap.hpp +123 -0
  252. data/libzmq/zeromq-2.1.7/src/tcp_connecter.cpp +310 -0
  253. data/libzmq/zeromq-2.1.7/src/tcp_connecter.hpp +81 -0
  254. data/libzmq/zeromq-2.1.7/src/tcp_listener.cpp +371 -0
  255. data/libzmq/zeromq-2.1.7/src/tcp_listener.hpp +73 -0
  256. data/libzmq/zeromq-2.1.7/src/tcp_socket.cpp +228 -0
  257. data/libzmq/zeromq-2.1.7/src/tcp_socket.hpp +72 -0
  258. data/libzmq/zeromq-2.1.7/src/thread.cpp +97 -0
  259. data/libzmq/zeromq-2.1.7/src/thread.hpp +78 -0
  260. data/libzmq/zeromq-2.1.7/src/transient_session.cpp +41 -0
  261. data/libzmq/zeromq-2.1.7/src/transient_session.hpp +52 -0
  262. data/libzmq/zeromq-2.1.7/src/trie.cpp +181 -0
  263. data/libzmq/zeromq-2.1.7/src/trie.hpp +59 -0
  264. data/libzmq/zeromq-2.1.7/src/uuid.cpp +233 -0
  265. data/libzmq/zeromq-2.1.7/src/uuid.hpp +111 -0
  266. data/libzmq/zeromq-2.1.7/src/windows.hpp +79 -0
  267. data/libzmq/zeromq-2.1.7/src/wire.hpp +99 -0
  268. data/libzmq/zeromq-2.1.7/src/xpub.cpp +76 -0
  269. data/libzmq/zeromq-2.1.7/src/xpub.hpp +61 -0
  270. data/libzmq/zeromq-2.1.7/src/xrep.cpp +337 -0
  271. data/libzmq/zeromq-2.1.7/src/xrep.hpp +116 -0
  272. data/libzmq/zeromq-2.1.7/src/xreq.cpp +74 -0
  273. data/libzmq/zeromq-2.1.7/src/xreq.hpp +65 -0
  274. data/libzmq/zeromq-2.1.7/src/xsub.cpp +172 -0
  275. data/libzmq/zeromq-2.1.7/src/xsub.hpp +80 -0
  276. data/libzmq/zeromq-2.1.7/src/ypipe.hpp +209 -0
  277. data/libzmq/zeromq-2.1.7/src/yqueue.hpp +198 -0
  278. data/libzmq/zeromq-2.1.7/src/zmq.cpp +798 -0
  279. data/libzmq/zeromq-2.1.7/src/zmq_connecter.cpp +166 -0
  280. data/libzmq/zeromq-2.1.7/src/zmq_connecter.hpp +92 -0
  281. data/libzmq/zeromq-2.1.7/src/zmq_engine.cpp +220 -0
  282. data/libzmq/zeromq-2.1.7/src/zmq_engine.hpp +87 -0
  283. data/libzmq/zeromq-2.1.7/src/zmq_init.cpp +216 -0
  284. data/libzmq/zeromq-2.1.7/src/zmq_init.hpp +93 -0
  285. data/libzmq/zeromq-2.1.7/src/zmq_listener.cpp +78 -0
  286. data/libzmq/zeromq-2.1.7/src/zmq_listener.hpp +67 -0
  287. data/libzmq/zeromq-2.1.7/tests/Makefile.am +30 -0
  288. data/libzmq/zeromq-2.1.7/tests/Makefile.in +713 -0
  289. data/libzmq/zeromq-2.1.7/tests/test_hwm.cpp +68 -0
  290. data/libzmq/zeromq-2.1.7/tests/test_pair_inproc.cpp +31 -0
  291. data/libzmq/zeromq-2.1.7/tests/test_pair_ipc.cpp +31 -0
  292. data/libzmq/zeromq-2.1.7/tests/test_pair_tcp.cpp +31 -0
  293. data/libzmq/zeromq-2.1.7/tests/test_reqrep_inproc.cpp +31 -0
  294. data/libzmq/zeromq-2.1.7/tests/test_reqrep_ipc.cpp +31 -0
  295. data/libzmq/zeromq-2.1.7/tests/test_reqrep_tcp.cpp +31 -0
  296. data/libzmq/zeromq-2.1.7/tests/test_shutdown_stress.cpp +87 -0
  297. data/libzmq/zeromq-2.1.7/tests/testutil.hpp +130 -0
  298. data/libzmq/zeromq-2.1.7/version.sh +21 -0
  299. data/libzmq/zeromq-2.1.7/zeromq.spec +139 -0
  300. metadata +348 -0
@@ -0,0 +1,207 @@
1
+ /*
2
+ Copyright (c) 2007-2011 iMatix Corporation
3
+ Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4
+
5
+ This file is part of 0MQ.
6
+
7
+ 0MQ is free software; you can redistribute it and/or modify it under
8
+ the terms of the GNU Lesser General Public License as published by
9
+ the Free Software Foundation; either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ 0MQ is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+ #ifndef __ZMQ_SOCKET_BASE_HPP_INCLUDED__
22
+ #define __ZMQ_SOCKET_BASE_HPP_INCLUDED__
23
+
24
+ #include <map>
25
+ #include <vector>
26
+
27
+ #include "../include/zmq.h"
28
+
29
+ #include "own.hpp"
30
+ #include "array.hpp"
31
+ #include "mutex.hpp"
32
+ #include "stdint.hpp"
33
+ #include "poller.hpp"
34
+ #include "atomic_counter.hpp"
35
+ #include "i_poll_events.hpp"
36
+ #include "mailbox.hpp"
37
+ #include "stdint.hpp"
38
+ #include "blob.hpp"
39
+ #include "own.hpp"
40
+
41
+ namespace zmq
42
+ {
43
+
44
+ class socket_base_t :
45
+ public own_t,
46
+ public array_item_t,
47
+ public i_poll_events
48
+ {
49
+ friend class reaper_t;
50
+
51
+ public:
52
+
53
+ // Returns false if object is not a socket.
54
+ bool check_tag ();
55
+
56
+ // Create a socket of a specified type.
57
+ static socket_base_t *create (int type_, class ctx_t *parent_,
58
+ uint32_t tid_);
59
+
60
+ // Returns the mailbox associated with this socket.
61
+ mailbox_t *get_mailbox ();
62
+
63
+ // Interrupt blocking call if the socket is stuck in one.
64
+ // This function can be called from a different thread!
65
+ void stop ();
66
+
67
+ // Interface for communication with the API layer.
68
+ int setsockopt (int option_, const void *optval_, size_t optvallen_);
69
+ int getsockopt (int option_, void *optval_, size_t *optvallen_);
70
+ int bind (const char *addr_);
71
+ int connect (const char *addr_);
72
+ int send (zmq_msg_t *msg_, int flags_);
73
+ int recv (zmq_msg_t *msg_, int flags_);
74
+ int close ();
75
+
76
+ // These functions are used by the polling mechanism to determine
77
+ // which events are to be reported from this socket.
78
+ bool has_in ();
79
+ bool has_out ();
80
+
81
+ // Registry of named sessions.
82
+ bool register_session (const blob_t &name_, class session_t *session_);
83
+ void unregister_session (const blob_t &name_);
84
+ class session_t *find_session (const blob_t &name_);
85
+
86
+ // i_reader_events interface implementation.
87
+ void activated (class reader_t *pipe_);
88
+ void terminated (class reader_t *pipe_);
89
+
90
+ // i_writer_events interface implementation.
91
+ void activated (class writer_t *pipe_);
92
+ void terminated (class writer_t *pipe_);
93
+
94
+ // Using this function reaper thread ask the socket to regiter with
95
+ // its poller.
96
+ void start_reaping (poller_t *poller_);
97
+
98
+ // i_poll_events implementation. This interface is used when socket
99
+ // is handled by the poller in the reaper thread.
100
+ void in_event ();
101
+ void out_event ();
102
+ void timer_event (int id_);
103
+
104
+ // To be called after processing commands or invoking any command
105
+ // handlers explicitly. If required, it will deallocate the socket.
106
+ void check_destroy ();
107
+
108
+ protected:
109
+
110
+ socket_base_t (class ctx_t *parent_, uint32_t tid_);
111
+ virtual ~socket_base_t ();
112
+
113
+ // Concrete algorithms for the x- methods are to be defined by
114
+ // individual socket types.
115
+ virtual void xattach_pipes (class reader_t *inpipe_,
116
+ class writer_t *outpipe_, const blob_t &peer_identity_) = 0;
117
+
118
+ // The default implementation assumes there are no specific socket
119
+ // options for the particular socket type. If not so, overload this
120
+ // method.
121
+ virtual int xsetsockopt (int option_, const void *optval_,
122
+ size_t optvallen_);
123
+
124
+ // The default implementation assumes that send is not supported.
125
+ virtual bool xhas_out ();
126
+ virtual int xsend (zmq_msg_t *msg_, int options_);
127
+
128
+ // The default implementation assumes that recv in not supported.
129
+ virtual bool xhas_in ();
130
+ virtual int xrecv (zmq_msg_t *msg_, int options_);
131
+
132
+ // We are declaring termination handler as protected so that
133
+ // individual socket types can hook into the termination process
134
+ // by overloading it.
135
+ void process_term (int linger_);
136
+
137
+ // Delay actual destruction of the socket.
138
+ void process_destroy ();
139
+
140
+ private:
141
+
142
+ // Used to check whether the object is a socket.
143
+ uint32_t tag;
144
+
145
+ // If true, associated context was already terminated.
146
+ bool ctx_terminated;
147
+
148
+ // If true, object should have been already destroyed. However,
149
+ // destruction is delayed while we unwind the stack to the point
150
+ // where it doesn't intersect the object being destroyed.
151
+ bool destroyed;
152
+
153
+ // Parse URI string.
154
+ int parse_uri (const char *uri_, std::string &protocol_,
155
+ std::string &address_);
156
+
157
+ // Check whether transport protocol, as specified in connect or
158
+ // bind, is available and compatible with the socket type.
159
+ int check_protocol (const std::string &protocol_);
160
+
161
+ // If no identity set generate one and call xattach_pipes ().
162
+ void attach_pipes (class reader_t *inpipe_, class writer_t *outpipe_,
163
+ const blob_t &peer_identity_);
164
+
165
+ // Processes commands sent to this socket (if any). If 'block' is
166
+ // set to true, returns only after at least one command was processed.
167
+ // If throttle argument is true, commands are processed at most once
168
+ // in a predefined time period.
169
+ int process_commands (bool block_, bool throttle_);
170
+
171
+ // Handlers for incoming commands.
172
+ void process_stop ();
173
+ void process_bind (class reader_t *in_pipe_, class writer_t *out_pipe_,
174
+ const blob_t &peer_identity_);
175
+ void process_unplug ();
176
+
177
+ // Socket's mailbox object.
178
+ mailbox_t mailbox;
179
+
180
+ // Reaper's poller and handle of this socket within it.
181
+ poller_t *poller;
182
+ poller_t::handle_t handle;
183
+
184
+ // Timestamp of when commands were processed the last time.
185
+ uint64_t last_tsc;
186
+
187
+ // Number of messages received since last command processing.
188
+ int ticks;
189
+
190
+ // If true there's a half-read message in the socket.
191
+ bool rcvmore;
192
+
193
+ // Lists of existing sessions. This list is never referenced from
194
+ // within the socket, instead it is used by objects owned by
195
+ // the socket. As those objects can live in different threads,
196
+ // the access is synchronised by mutex.
197
+ typedef std::map <blob_t, session_t*> sessions_t;
198
+ sessions_t sessions;
199
+ mutex_t sessions_sync;
200
+
201
+ socket_base_t (const socket_base_t&);
202
+ const socket_base_t &operator = (const socket_base_t&);
203
+ };
204
+
205
+ }
206
+
207
+ #endif
@@ -0,0 +1,63 @@
1
+ /*
2
+ Copyright (c) 2007-2011 iMatix Corporation
3
+ Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4
+
5
+ This file is part of 0MQ.
6
+
7
+ 0MQ is free software; you can redistribute it and/or modify it under
8
+ the terms of the GNU Lesser General Public License as published by
9
+ the Free Software Foundation; either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ 0MQ is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+ #ifndef __ZMQ_STDINT_HPP_INCLUDED__
22
+ #define __ZMQ_STDINT_HPP_INCLUDED__
23
+
24
+ #include "platform.hpp"
25
+
26
+ #if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
27
+
28
+ #include <inttypes.h>
29
+
30
+ #elif defined _MSC_VER
31
+
32
+ #ifndef int8_t
33
+ typedef __int8 int8_t;
34
+ #endif
35
+ #ifndef int16_t
36
+ typedef __int16 int16_t;
37
+ #endif
38
+ #ifndef int32_t
39
+ typedef __int32 int32_t;
40
+ #endif
41
+ #ifndef int64_t
42
+ typedef __int64 int64_t;
43
+ #endif
44
+ #ifndef uint8_t
45
+ typedef unsigned __int8 uint8_t;
46
+ #endif
47
+ #ifndef uint16_t
48
+ typedef unsigned __int16 uint16_t;
49
+ #endif
50
+ #ifndef uint32_t
51
+ typedef unsigned __int32 uint32_t;
52
+ #endif
53
+ #ifndef uint64_t
54
+ typedef unsigned __int64 uint64_t;
55
+ #endif
56
+
57
+ #else
58
+
59
+ #include <stdint.h>
60
+
61
+ #endif
62
+
63
+ #endif
@@ -0,0 +1,75 @@
1
+ /*
2
+ Copyright (c) 2007-2011 iMatix Corporation
3
+ Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4
+
5
+ This file is part of 0MQ.
6
+
7
+ 0MQ is free software; you can redistribute it and/or modify it under
8
+ the terms of the GNU Lesser General Public License as published by
9
+ the Free Software Foundation; either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ 0MQ is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+ #include "../include/zmq.h"
22
+
23
+ #include "sub.hpp"
24
+
25
+ zmq::sub_t::sub_t (class ctx_t *parent_, uint32_t tid_) :
26
+ xsub_t (parent_, tid_)
27
+ {
28
+ options.type = ZMQ_SUB;
29
+ }
30
+
31
+ zmq::sub_t::~sub_t ()
32
+ {
33
+ }
34
+
35
+ int zmq::sub_t::xsetsockopt (int option_, const void *optval_,
36
+ size_t optvallen_)
37
+ {
38
+ if (option_ != ZMQ_SUBSCRIBE && option_ != ZMQ_UNSUBSCRIBE) {
39
+ errno = EINVAL;
40
+ return -1;
41
+ }
42
+
43
+ // Create the subscription message.
44
+ zmq_msg_t msg;
45
+ zmq_msg_init_size (&msg, optvallen_ + 1);
46
+ unsigned char *data = (unsigned char*) zmq_msg_data (&msg);
47
+ if (option_ == ZMQ_SUBSCRIBE)
48
+ *data = 1;
49
+ else if (option_ == ZMQ_UNSUBSCRIBE)
50
+ *data = 0;
51
+ memcpy (data + 1, optval_, optvallen_);
52
+
53
+ // Pass it further on in the stack.
54
+ int err = 0;
55
+ int rc = xsub_t::xsend (&msg, 0);
56
+ if (rc != 0)
57
+ err = errno;
58
+ zmq_msg_close (&msg);
59
+ if (rc != 0)
60
+ errno = err;
61
+ return rc;
62
+ }
63
+
64
+ int zmq::sub_t::xsend (zmq_msg_t *msg_, int options_)
65
+ {
66
+ // Overload the XSUB's send.
67
+ errno = ENOTSUP;
68
+ return -1;
69
+ }
70
+
71
+ bool zmq::sub_t::xhas_out ()
72
+ {
73
+ // Overload the XSUB's send.
74
+ return false;
75
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ Copyright (c) 2007-2011 iMatix Corporation
3
+ Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4
+
5
+ This file is part of 0MQ.
6
+
7
+ 0MQ is free software; you can redistribute it and/or modify it under
8
+ the terms of the GNU Lesser General Public License as published by
9
+ the Free Software Foundation; either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ 0MQ is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+ #ifndef __ZMQ_SUB_HPP_INCLUDED__
22
+ #define __ZMQ_SUB_HPP_INCLUDED__
23
+
24
+ #include "xsub.hpp"
25
+
26
+ namespace zmq
27
+ {
28
+
29
+ class sub_t : public xsub_t
30
+ {
31
+ public:
32
+
33
+ sub_t (class ctx_t *parent_, uint32_t tid_);
34
+ ~sub_t ();
35
+
36
+ protected:
37
+
38
+ int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
39
+ int xsend (zmq_msg_t *msg_, int options_);
40
+ bool xhas_out ();
41
+
42
+ private:
43
+
44
+ sub_t (const sub_t&);
45
+ const sub_t &operator = (const sub_t&);
46
+ };
47
+
48
+ }
49
+
50
+ #endif
@@ -0,0 +1,325 @@
1
+ /*
2
+ Copyright (c) 2007-2011 iMatix Corporation
3
+ Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4
+
5
+ This file is part of 0MQ.
6
+
7
+ 0MQ is free software; you can redistribute it and/or modify it under
8
+ the terms of the GNU Lesser General Public License as published by
9
+ the Free Software Foundation; either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ 0MQ is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+ #include "platform.hpp"
22
+
23
+ #ifdef ZMQ_HAVE_WINDOWS
24
+ #include "windows.hpp"
25
+ #include <io.h>
26
+ #else
27
+ #include <unistd.h>
28
+ #endif
29
+
30
+ #include "../include/zmq.h"
31
+
32
+ #include <sys/types.h>
33
+ #include <sys/stat.h>
34
+ #include <fcntl.h>
35
+ #include <string.h>
36
+ #include <sstream>
37
+ #include <algorithm>
38
+
39
+ #include "swap.hpp"
40
+ #include "config.hpp"
41
+ #include "atomic_counter.hpp"
42
+ #include "err.hpp"
43
+
44
+ zmq::swap_t::swap_t (int64_t filesize_) :
45
+ fd (-1),
46
+ filesize (filesize_),
47
+ file_pos (0),
48
+ write_pos (0),
49
+ read_pos (0),
50
+ block_size (swap_block_size),
51
+ write_buf_start_addr (0)
52
+ {
53
+ zmq_assert (filesize > 0);
54
+ zmq_assert (block_size > 0);
55
+
56
+ buf1 = new (std::nothrow) char [block_size];
57
+ alloc_assert (buf1);
58
+
59
+ buf2 = new (std::nothrow) char [block_size];
60
+ alloc_assert (buf2);
61
+
62
+ read_buf = write_buf = buf1;
63
+ }
64
+
65
+ zmq::swap_t::~swap_t ()
66
+ {
67
+ delete [] buf1;
68
+ delete [] buf2;
69
+
70
+ if (fd == -1)
71
+ return;
72
+
73
+ #ifdef ZMQ_HAVE_WINDOWS
74
+ int rc = _close (fd);
75
+ #else
76
+ int rc = close (fd);
77
+ #endif
78
+ errno_assert (rc == 0);
79
+
80
+ #ifdef ZMQ_HAVE_WINDOWS
81
+ rc = _unlink (filename.c_str ());
82
+ #else
83
+ rc = unlink (filename.c_str ());
84
+ #endif
85
+ errno_assert (rc == 0);
86
+ }
87
+
88
+ int zmq::swap_t::init ()
89
+ {
90
+ static zmq::atomic_counter_t seqnum (0);
91
+
92
+ // Get process ID.
93
+ #ifdef ZMQ_HAVE_WINDOWS
94
+ int pid = GetCurrentThreadId ();
95
+ #else
96
+ pid_t pid = getpid ();
97
+ #endif
98
+
99
+ std::ostringstream outs;
100
+ outs << "zmq_" << pid << '_' << seqnum.get () << ".swap";
101
+ filename = outs.str ();
102
+
103
+ seqnum.add (1);
104
+
105
+ // Open the backing file.
106
+ #ifdef ZMQ_HAVE_WINDOWS
107
+ fd = _open (filename.c_str (), _O_RDWR | _O_CREAT, 0600);
108
+ #else
109
+ fd = open (filename.c_str (), O_RDWR | O_CREAT, 0600);
110
+ #endif
111
+ if (fd == -1)
112
+ return -1;
113
+
114
+ #ifdef ZMQ_HAVE_LINUX
115
+ // Enable more aggresive read-ahead optimization.
116
+ posix_fadvise (fd, 0, filesize, POSIX_FADV_SEQUENTIAL);
117
+ #endif
118
+ return 0;
119
+ }
120
+
121
+ bool zmq::swap_t::store (zmq_msg_t *msg_)
122
+ {
123
+ size_t msg_size = zmq_msg_size (msg_);
124
+
125
+ // Check buffer space availability.
126
+ // NOTE: We always keep one byte open.
127
+ if (buffer_space () <= (int64_t) (sizeof msg_size + 1 + msg_size))
128
+ return false;
129
+
130
+ // Don't store the ZMQ_MSG_SHARED flag.
131
+ uint8_t msg_flags = msg_->flags & ~ZMQ_MSG_SHARED;
132
+
133
+ // Write message length, flags, and message body.
134
+ copy_to_file (&msg_size, sizeof msg_size);
135
+ copy_to_file (&msg_flags, sizeof msg_flags);
136
+ copy_to_file (zmq_msg_data (msg_), msg_size);
137
+
138
+ zmq_msg_close (msg_);
139
+
140
+ return true;
141
+ }
142
+
143
+ void zmq::swap_t::fetch (zmq_msg_t *msg_)
144
+ {
145
+ // There must be at least one message available.
146
+ zmq_assert (read_pos != write_pos);
147
+
148
+ // Retrieve the message size.
149
+ size_t msg_size;
150
+ copy_from_file (&msg_size, sizeof msg_size);
151
+
152
+ // Initialize the message.
153
+ zmq_msg_init_size (msg_, msg_size);
154
+
155
+ // Retrieve the message flags.
156
+ copy_from_file (&msg_->flags, sizeof msg_->flags);
157
+
158
+ // Retrieve the message payload.
159
+ copy_from_file (zmq_msg_data (msg_), msg_size);
160
+ }
161
+
162
+ void zmq::swap_t::commit ()
163
+ {
164
+ commit_pos = write_pos;
165
+ }
166
+
167
+ void zmq::swap_t::rollback ()
168
+ {
169
+ if (commit_pos == write_pos || read_pos == write_pos)
170
+ return;
171
+
172
+ if (write_pos > read_pos)
173
+ zmq_assert (read_pos <= commit_pos && commit_pos <= write_pos);
174
+ else
175
+ zmq_assert (read_pos <= commit_pos || commit_pos <= write_pos);
176
+
177
+ if (commit_pos / block_size == read_pos / block_size) {
178
+ write_buf_start_addr = commit_pos % block_size;
179
+ write_buf = read_buf;
180
+ }
181
+ else if (commit_pos / block_size != write_pos / block_size) {
182
+ write_buf_start_addr = commit_pos % block_size;
183
+ fill_buf (write_buf, write_buf_start_addr);
184
+ }
185
+ write_pos = commit_pos;
186
+ }
187
+
188
+ bool zmq::swap_t::empty ()
189
+ {
190
+ return read_pos == write_pos;
191
+ }
192
+
193
+ /*
194
+ bool zmq::swap_t::full ()
195
+ {
196
+ // Check that at least the message size can be written to the swap.
197
+ return buffer_space () < (int64_t) (sizeof (size_t) + 1);
198
+ }
199
+ */
200
+
201
+ bool zmq::swap_t::fits (zmq_msg_t *msg_)
202
+ {
203
+ // Check whether whole binary representation of the message
204
+ // fits into the swap.
205
+ size_t msg_size = zmq_msg_size (msg_);
206
+ if (buffer_space () <= (int64_t) (sizeof msg_size + 1 + msg_size))
207
+ return false;
208
+ return true;
209
+ }
210
+
211
+ void zmq::swap_t::copy_from_file (void *buffer_, size_t count_)
212
+ {
213
+ char *dest_ptr = (char *) buffer_;
214
+ size_t chunk_size, remainder = count_;
215
+
216
+ while (remainder > 0) {
217
+ chunk_size = std::min (remainder,
218
+ std::min ((size_t) (filesize - read_pos),
219
+ (size_t) (block_size - read_pos % block_size)));
220
+
221
+ memcpy (dest_ptr, &read_buf [read_pos % block_size], chunk_size);
222
+ dest_ptr += chunk_size;
223
+
224
+ read_pos = (read_pos + chunk_size) % filesize;
225
+ if (read_pos % block_size == 0) {
226
+ if (read_pos / block_size == write_pos / block_size)
227
+ read_buf = write_buf;
228
+ else
229
+ fill_buf (read_buf, read_pos);
230
+ }
231
+ remainder -= chunk_size;
232
+ }
233
+ }
234
+
235
+ void zmq::swap_t::copy_to_file (const void *buffer_, size_t count_)
236
+ {
237
+ char *source_ptr = (char *) buffer_;
238
+ size_t chunk_size, remainder = count_;
239
+
240
+ while (remainder > 0) {
241
+ chunk_size = std::min (remainder,
242
+ std::min ((size_t) (filesize - write_pos),
243
+ (size_t) (block_size - write_pos % block_size)));
244
+
245
+ memcpy (&write_buf [write_pos % block_size], source_ptr, chunk_size);
246
+ source_ptr += chunk_size;
247
+
248
+ write_pos = (write_pos + chunk_size) % filesize;
249
+ if (write_pos % block_size == 0) {
250
+ save_write_buf ();
251
+ write_buf_start_addr = write_pos;
252
+
253
+ if (write_buf == read_buf) {
254
+ if (read_buf == buf2)
255
+ write_buf = buf1;
256
+ else
257
+ write_buf = buf2;
258
+ }
259
+ }
260
+ remainder -= chunk_size;
261
+ }
262
+ }
263
+
264
+ void zmq::swap_t::fill_buf (char *buf, int64_t pos)
265
+ {
266
+ if (file_pos != pos) {
267
+ #ifdef ZMQ_HAVE_WINDOWS
268
+ __int64 offset = _lseeki64 (fd, pos, SEEK_SET);
269
+ #else
270
+ off_t offset = lseek (fd, (off_t) pos, SEEK_SET);
271
+ #endif
272
+ errno_assert (offset == pos);
273
+ file_pos = pos;
274
+ }
275
+ size_t octets_stored = 0;
276
+ size_t octets_total = std::min (block_size, (size_t) (filesize - file_pos));
277
+
278
+ while (octets_stored < octets_total) {
279
+ #ifdef ZMQ_HAVE_WINDOWS
280
+ int rc = _read (fd, &buf [octets_stored], octets_total - octets_stored);
281
+ #else
282
+ ssize_t rc = read (fd, &buf [octets_stored],
283
+ octets_total - octets_stored);
284
+ #endif
285
+ errno_assert (rc > 0);
286
+ octets_stored += rc;
287
+ }
288
+ file_pos += octets_total;
289
+ }
290
+
291
+ void zmq::swap_t::save_write_buf ()
292
+ {
293
+ if (file_pos != write_buf_start_addr) {
294
+ #ifdef ZMQ_HAVE_WINDOWS
295
+ __int64 offset = _lseeki64 (fd, write_buf_start_addr, SEEK_SET);
296
+ #else
297
+ off_t offset = lseek (fd, (off_t) write_buf_start_addr, SEEK_SET);
298
+ #endif
299
+ errno_assert (offset == write_buf_start_addr);
300
+ file_pos = write_buf_start_addr;
301
+ }
302
+ size_t octets_stored = 0;
303
+ size_t octets_total = std::min (block_size, (size_t) (filesize - file_pos));
304
+
305
+ while (octets_stored < octets_total) {
306
+ #ifdef ZMQ_HAVE_WINDOWS
307
+ int rc = _write (fd, &write_buf [octets_stored],
308
+ octets_total - octets_stored);
309
+ #else
310
+ ssize_t rc = write (fd, &write_buf [octets_stored],
311
+ octets_total - octets_stored);
312
+ #endif
313
+ errno_assert (rc > 0);
314
+ octets_stored += rc;
315
+ }
316
+ file_pos += octets_total;
317
+ }
318
+
319
+ int64_t zmq::swap_t::buffer_space ()
320
+ {
321
+ if (write_pos < read_pos)
322
+ return read_pos - write_pos;
323
+
324
+ return filesize - (write_pos - read_pos);
325
+ }