polyphony 0.94 → 0.95

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -2
  3. data/.gitignore +3 -3
  4. data/CHANGELOG.md +14 -0
  5. data/docs/api-reference/fiber.md +2 -2
  6. data/docs/api-reference/object.md +3 -3
  7. data/docs/main-concepts/exception-handling.md +2 -2
  8. data/ext/polyphony/backend_common.c +3 -3
  9. data/ext/polyphony/backend_io_uring.c +18 -16
  10. data/ext/polyphony/event.c +1 -1
  11. data/ext/polyphony/extconf.rb +5 -3
  12. data/ext/polyphony/fiber.c +5 -13
  13. data/ext/polyphony/io_extensions.c +1 -1
  14. data/ext/polyphony/pipe.c +1 -1
  15. data/ext/polyphony/polyphony.c +1 -1
  16. data/ext/polyphony/polyphony_ext.c +1 -1
  17. data/ext/polyphony/queue.c +1 -1
  18. data/ext/polyphony/ring_buffer.c +1 -0
  19. data/ext/polyphony/socket_extensions.c +1 -1
  20. data/ext/polyphony/thread.c +1 -1
  21. data/lib/polyphony/extensions/enumerator.rb +16 -0
  22. data/lib/polyphony/extensions/socket.rb +2 -0
  23. data/lib/polyphony/extensions.rb +1 -0
  24. data/lib/polyphony/version.rb +1 -1
  25. data/polyphony.gemspec +2 -2
  26. data/test/test_backend.rb +5 -1
  27. data/test/test_enumerator.rb +46 -0
  28. data/test/test_io.rb +241 -216
  29. data/test/test_socket.rb +1 -1
  30. data/test/test_thread_pool.rb +3 -3
  31. data/vendor/liburing/.github/workflows/build.yml +51 -5
  32. data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
  33. data/vendor/liburing/.gitignore +6 -123
  34. data/vendor/liburing/CHANGELOG +35 -0
  35. data/vendor/liburing/CITATION.cff +11 -0
  36. data/vendor/liburing/LICENSE +16 -3
  37. data/vendor/liburing/Makefile +3 -1
  38. data/vendor/liburing/Makefile.common +1 -0
  39. data/vendor/liburing/README +14 -2
  40. data/vendor/liburing/SECURITY.md +6 -0
  41. data/vendor/liburing/configure +16 -15
  42. data/vendor/liburing/examples/Makefile +4 -1
  43. data/vendor/liburing/examples/io_uring-udp.c +395 -0
  44. data/vendor/liburing/examples/poll-bench.c +101 -0
  45. data/vendor/liburing/examples/send-zerocopy.c +339 -0
  46. data/vendor/liburing/liburing.spec +1 -1
  47. data/vendor/liburing/man/io_uring.7 +38 -11
  48. data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
  49. data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
  50. data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
  51. data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
  52. data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
  53. data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
  54. data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
  55. data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
  56. data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
  57. data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
  58. data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
  59. data/vendor/liburing/man/io_uring_enter.2 +249 -32
  60. data/vendor/liburing/man/io_uring_enter2.2 +1 -0
  61. data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
  62. data/vendor/liburing/man/io_uring_get_events.3 +33 -0
  63. data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
  64. data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
  65. data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
  66. data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
  67. data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
  68. data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
  69. data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
  70. data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
  71. data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
  72. data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
  73. data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
  74. data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
  75. data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
  76. data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
  77. data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
  78. data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
  79. data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
  80. data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
  81. data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
  82. data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
  83. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
  84. data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
  85. data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
  86. data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
  87. data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
  88. data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
  89. data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
  90. data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
  91. data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
  92. data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
  93. data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
  94. data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
  95. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
  96. data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
  97. data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
  98. data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
  99. data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
  100. data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
  101. data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
  102. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
  103. data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
  104. data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
  105. data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
  106. data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
  107. data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
  108. data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
  109. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
  110. data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
  111. data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
  112. data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
  113. data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
  114. data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
  115. data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
  116. data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
  117. data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
  118. data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
  119. data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
  120. data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
  121. data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
  122. data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
  123. data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
  124. data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
  125. data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
  126. data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
  127. data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
  128. data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
  129. data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
  130. data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
  131. data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
  132. data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
  133. data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
  134. data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
  135. data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
  136. data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
  137. data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
  138. data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
  139. data/vendor/liburing/man/io_uring_register.2 +153 -13
  140. data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
  141. data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
  142. data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
  143. data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
  144. data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
  145. data/vendor/liburing/man/io_uring_register_files.3 +33 -11
  146. data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
  147. data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
  148. data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
  149. data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
  150. data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
  151. data/vendor/liburing/man/io_uring_setup.2 +119 -13
  152. data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
  153. data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
  154. data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
  155. data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
  156. data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
  157. data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
  158. data/vendor/liburing/man/io_uring_submit.3 +29 -12
  159. data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
  160. data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
  161. data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
  162. data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
  163. data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
  164. data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
  165. data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
  166. data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
  167. data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
  168. data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
  169. data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
  170. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
  171. data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
  172. data/vendor/liburing/src/Makefile +8 -7
  173. data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
  174. data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
  175. data/vendor/liburing/src/arch/generic/lib.h +0 -4
  176. data/vendor/liburing/src/arch/generic/syscall.h +29 -16
  177. data/vendor/liburing/src/arch/syscall-defs.h +41 -14
  178. data/vendor/liburing/src/arch/x86/lib.h +0 -21
  179. data/vendor/liburing/src/arch/x86/syscall.h +146 -10
  180. data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
  181. data/vendor/liburing/src/include/liburing.h +468 -35
  182. data/vendor/liburing/src/int_flags.h +1 -0
  183. data/vendor/liburing/src/lib.h +20 -16
  184. data/vendor/liburing/src/liburing.map +16 -0
  185. data/vendor/liburing/src/nolibc.c +1 -1
  186. data/vendor/liburing/src/queue.c +87 -55
  187. data/vendor/liburing/src/register.c +129 -53
  188. data/vendor/liburing/src/setup.c +65 -28
  189. data/vendor/liburing/src/syscall.c +14 -32
  190. data/vendor/liburing/src/syscall.h +12 -64
  191. data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
  192. data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
  193. data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
  194. data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
  195. data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
  196. data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
  197. data/vendor/liburing/test/Makefile +60 -62
  198. data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
  199. data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
  200. data/vendor/liburing/test/accept-link.c +5 -4
  201. data/vendor/liburing/test/accept-reuse.c +17 -16
  202. data/vendor/liburing/test/accept-test.c +14 -10
  203. data/vendor/liburing/test/accept.c +529 -107
  204. data/vendor/liburing/test/across-fork.c +7 -6
  205. data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
  206. data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
  207. data/vendor/liburing/test/buf-ring.c +420 -0
  208. data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
  209. data/vendor/liburing/test/connect.c +8 -7
  210. data/vendor/liburing/test/cq-full.c +5 -4
  211. data/vendor/liburing/test/cq-overflow.c +242 -12
  212. data/vendor/liburing/test/cq-peek-batch.c +5 -4
  213. data/vendor/liburing/test/cq-ready.c +5 -4
  214. data/vendor/liburing/test/cq-size.c +5 -4
  215. data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
  216. data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
  217. data/vendor/liburing/test/defer-taskrun.c +336 -0
  218. data/vendor/liburing/test/defer.c +26 -14
  219. data/vendor/liburing/test/double-poll-crash.c +15 -5
  220. data/vendor/liburing/test/drop-submit.c +5 -3
  221. data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
  222. data/vendor/liburing/test/empty-eownerdead.c +4 -4
  223. data/vendor/liburing/test/eventfd-disable.c +48 -20
  224. data/vendor/liburing/test/eventfd-reg.c +10 -9
  225. data/vendor/liburing/test/eventfd-ring.c +13 -12
  226. data/vendor/liburing/test/eventfd.c +13 -12
  227. data/vendor/liburing/test/exit-no-cleanup.c +1 -1
  228. data/vendor/liburing/test/fadvise.c +3 -3
  229. data/vendor/liburing/test/fallocate.c +16 -9
  230. data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
  231. data/vendor/liburing/test/fd-pass.c +187 -0
  232. data/vendor/liburing/test/file-register.c +302 -36
  233. data/vendor/liburing/test/file-update.c +62 -4
  234. data/vendor/liburing/test/file-verify.c +6 -2
  235. data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
  236. data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
  237. data/vendor/liburing/test/fixed-buf-iter.c +115 -0
  238. data/vendor/liburing/test/fixed-link.c +10 -10
  239. data/vendor/liburing/test/fixed-reuse.c +160 -0
  240. data/vendor/liburing/test/fpos.c +6 -3
  241. data/vendor/liburing/test/fsync.c +3 -3
  242. data/vendor/liburing/test/hardlink.c +10 -6
  243. data/vendor/liburing/test/helpers.c +137 -4
  244. data/vendor/liburing/test/helpers.h +27 -0
  245. data/vendor/liburing/test/io-cancel.c +16 -11
  246. data/vendor/liburing/test/io_uring_enter.c +46 -81
  247. data/vendor/liburing/test/io_uring_passthrough.c +451 -0
  248. data/vendor/liburing/test/io_uring_register.c +59 -229
  249. data/vendor/liburing/test/io_uring_setup.c +24 -29
  250. data/vendor/liburing/test/iopoll-leak.c +85 -0
  251. data/vendor/liburing/test/iopoll.c +16 -9
  252. data/vendor/liburing/test/lfs-openat-write.c +3 -1
  253. data/vendor/liburing/test/link-timeout.c +4 -3
  254. data/vendor/liburing/test/link.c +8 -7
  255. data/vendor/liburing/test/madvise.c +2 -2
  256. data/vendor/liburing/test/mkdir.c +9 -5
  257. data/vendor/liburing/test/msg-ring.c +46 -20
  258. data/vendor/liburing/test/multicqes_drain.c +51 -12
  259. data/vendor/liburing/test/nolibc.c +60 -0
  260. data/vendor/liburing/test/nop.c +78 -16
  261. data/vendor/liburing/test/nvme.h +168 -0
  262. data/vendor/liburing/test/open-direct-link.c +188 -0
  263. data/vendor/liburing/test/open-direct-pick.c +180 -0
  264. data/vendor/liburing/test/openat2.c +3 -3
  265. data/vendor/liburing/test/poll-cancel-all.c +472 -0
  266. data/vendor/liburing/test/poll-link.c +9 -18
  267. data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
  268. data/vendor/liburing/test/poll-mshot-update.c +83 -33
  269. data/vendor/liburing/test/pollfree.c +2 -2
  270. data/vendor/liburing/test/read-before-exit.c +112 -0
  271. data/vendor/liburing/test/read-write.c +83 -1
  272. data/vendor/liburing/test/recv-msgall-stream.c +398 -0
  273. data/vendor/liburing/test/recv-msgall.c +265 -0
  274. data/vendor/liburing/test/recv-multishot.c +505 -0
  275. data/vendor/liburing/test/rename.c +2 -5
  276. data/vendor/liburing/test/ring-leak.c +97 -0
  277. data/vendor/liburing/test/ringbuf-read.c +200 -0
  278. data/vendor/liburing/test/rsrc_tags.c +25 -13
  279. data/vendor/liburing/test/runtests-quiet.sh +11 -0
  280. data/vendor/liburing/test/runtests.sh +18 -20
  281. data/vendor/liburing/test/rw_merge_test.c +3 -2
  282. data/vendor/liburing/test/send-zerocopy.c +684 -0
  283. data/vendor/liburing/test/send_recv.c +49 -2
  284. data/vendor/liburing/test/send_recvmsg.c +165 -55
  285. data/vendor/liburing/test/shutdown.c +3 -4
  286. data/vendor/liburing/test/sigfd-deadlock.c +22 -8
  287. data/vendor/liburing/test/single-issuer.c +171 -0
  288. data/vendor/liburing/test/socket-rw-eagain.c +2 -12
  289. data/vendor/liburing/test/socket-rw-offset.c +2 -11
  290. data/vendor/liburing/test/socket-rw.c +2 -11
  291. data/vendor/liburing/test/socket.c +409 -0
  292. data/vendor/liburing/test/sq-poll-dup.c +1 -1
  293. data/vendor/liburing/test/sq-poll-share.c +1 -1
  294. data/vendor/liburing/test/statx.c +2 -2
  295. data/vendor/liburing/test/submit-and-wait.c +108 -0
  296. data/vendor/liburing/test/submit-link-fail.c +5 -3
  297. data/vendor/liburing/test/submit-reuse.c +0 -2
  298. data/vendor/liburing/test/sync-cancel.c +235 -0
  299. data/vendor/liburing/test/test.h +35 -0
  300. data/vendor/liburing/test/timeout-overflow.c +11 -11
  301. data/vendor/liburing/test/timeout.c +7 -7
  302. data/vendor/liburing/test/tty-write-dpoll.c +60 -0
  303. data/vendor/liburing/test/unlink.c +1 -1
  304. data/vendor/liburing/test/xattr.c +425 -0
  305. metadata +143 -22
  306. data/Gemfile.lock +0 -78
@@ -0,0 +1,684 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+ #include <stdint.h>
5
+ #include <assert.h>
6
+ #include <errno.h>
7
+ #include <error.h>
8
+ #include <limits.h>
9
+ #include <fcntl.h>
10
+ #include <unistd.h>
11
+ #include <stdbool.h>
12
+ #include <string.h>
13
+
14
+ #include <arpa/inet.h>
15
+ #include <linux/errqueue.h>
16
+ #include <linux/if_packet.h>
17
+ #include <linux/ipv6.h>
18
+ #include <linux/socket.h>
19
+ #include <linux/sockios.h>
20
+ #include <net/ethernet.h>
21
+ #include <net/if.h>
22
+ #include <netinet/ip.h>
23
+ #include <netinet/in.h>
24
+ #include <netinet/ip6.h>
25
+ #include <netinet/tcp.h>
26
+ #include <netinet/udp.h>
27
+ #include <sys/socket.h>
28
+ #include <sys/time.h>
29
+ #include <sys/resource.h>
30
+ #include <sys/un.h>
31
+ #include <sys/ioctl.h>
32
+ #include <sys/socket.h>
33
+ #include <sys/stat.h>
34
+ #include <sys/time.h>
35
+ #include <sys/types.h>
36
+ #include <sys/wait.h>
37
+
38
+ #include "liburing.h"
39
+ #include "helpers.h"
40
+
41
+ #define MAX_MSG 128
42
+
43
+ #define PORT 10200
44
+ #define HOST "127.0.0.1"
45
+ #define HOSTV6 "::1"
46
+
47
+ #define CORK_REQS 5
48
+ #define RX_TAG 10000
49
+ #define BUFFER_OFFSET 41
50
+
51
+ #ifndef ARRAY_SIZE
52
+ #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
53
+ #endif
54
+
55
+ enum {
56
+ BUF_T_NORMAL,
57
+ BUF_T_SMALL,
58
+ BUF_T_NONALIGNED,
59
+ BUF_T_LARGE,
60
+ };
61
+
62
+ static char *tx_buffer, *rx_buffer;
63
+ static struct iovec buffers_iov[4];
64
+ static bool has_sendmsg;
65
+
66
+ static bool check_cq_empty(struct io_uring *ring)
67
+ {
68
+ struct io_uring_cqe *cqe = NULL;
69
+ int ret;
70
+
71
+ ret = io_uring_peek_cqe(ring, &cqe); /* nothing should be there */
72
+ return ret == -EAGAIN;
73
+ }
74
+
75
+ static int test_basic_send(struct io_uring *ring, int sock_tx, int sock_rx)
76
+ {
77
+ struct io_uring_sqe *sqe;
78
+ struct io_uring_cqe *cqe;
79
+ int msg_flags = 0;
80
+ unsigned zc_flags = 0;
81
+ int payload_size = 100;
82
+ int ret;
83
+
84
+ sqe = io_uring_get_sqe(ring);
85
+ io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
86
+ msg_flags, zc_flags);
87
+ sqe->user_data = 1;
88
+
89
+ ret = io_uring_submit(ring);
90
+ assert(ret == 1);
91
+
92
+ ret = io_uring_wait_cqe(ring, &cqe);
93
+ assert(!ret && cqe->user_data == 1);
94
+ if (cqe->res == -EINVAL) {
95
+ assert(!(cqe->flags & IORING_CQE_F_MORE));
96
+ return T_EXIT_SKIP;
97
+ } else if (cqe->res != payload_size) {
98
+ fprintf(stderr, "send failed %i\n", cqe->res);
99
+ return T_EXIT_FAIL;
100
+ }
101
+
102
+ assert(cqe->flags & IORING_CQE_F_MORE);
103
+ io_uring_cqe_seen(ring, cqe);
104
+
105
+ ret = io_uring_wait_cqe(ring, &cqe);
106
+ assert(!ret);
107
+ assert(cqe->user_data == 1);
108
+ assert(cqe->flags & IORING_CQE_F_NOTIF);
109
+ assert(!(cqe->flags & IORING_CQE_F_MORE));
110
+ io_uring_cqe_seen(ring, cqe);
111
+ assert(check_cq_empty(ring));
112
+
113
+ ret = recv(sock_rx, rx_buffer, payload_size, MSG_TRUNC);
114
+ assert(ret == payload_size);
115
+ return T_EXIT_PASS;
116
+ }
117
+
118
+ static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx)
119
+ {
120
+ struct io_uring_sqe *sqe;
121
+ struct io_uring_cqe *cqe;
122
+ int msg_flags = 0;
123
+ unsigned zc_flags = 0;
124
+ int payload_size = 100;
125
+ int ret, i, nr_cqes = 2;
126
+
127
+ sqe = io_uring_get_sqe(ring);
128
+ io_uring_prep_send_zc(sqe, sock_tx, (void *)1UL, payload_size,
129
+ msg_flags, zc_flags);
130
+ sqe->user_data = 1;
131
+
132
+ sqe = io_uring_get_sqe(ring);
133
+ io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
134
+ msg_flags, zc_flags);
135
+ sqe->user_data = 2;
136
+ io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)1UL,
137
+ sizeof(struct sockaddr_in6));
138
+
139
+ ret = io_uring_submit(ring);
140
+ assert(ret == 2);
141
+
142
+ for (i = 0; i < nr_cqes; i++) {
143
+ ret = io_uring_wait_cqe(ring, &cqe);
144
+ assert(!ret);
145
+ assert(cqe->user_data <= 2);
146
+
147
+ if (!(cqe->flags & IORING_CQE_F_NOTIF)) {
148
+ assert(cqe->res == -EFAULT);
149
+ if (cqe->flags & IORING_CQE_F_MORE)
150
+ nr_cqes++;
151
+ }
152
+ io_uring_cqe_seen(ring, cqe);
153
+ }
154
+ assert(check_cq_empty(ring));
155
+ return T_EXIT_PASS;
156
+ }
157
+
158
+ static int create_socketpair_ip(struct sockaddr_storage *addr,
159
+ int *sock_client, int *sock_server,
160
+ bool ipv6, bool client_connect,
161
+ bool msg_zc, bool tcp)
162
+ {
163
+ int family, addr_size;
164
+ int ret, val;
165
+ int listen_sock = -1;
166
+ int sock;
167
+
168
+ memset(addr, 0, sizeof(*addr));
169
+ if (ipv6) {
170
+ struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)addr;
171
+
172
+ family = AF_INET6;
173
+ saddr->sin6_family = family;
174
+ saddr->sin6_port = htons(PORT);
175
+ addr_size = sizeof(*saddr);
176
+ } else {
177
+ struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
178
+
179
+ family = AF_INET;
180
+ saddr->sin_family = family;
181
+ saddr->sin_port = htons(PORT);
182
+ saddr->sin_addr.s_addr = htonl(INADDR_ANY);
183
+ addr_size = sizeof(*saddr);
184
+ }
185
+
186
+ /* server sock setup */
187
+ if (tcp) {
188
+ sock = listen_sock = socket(family, SOCK_STREAM, IPPROTO_TCP);
189
+ } else {
190
+ sock = *sock_server = socket(family, SOCK_DGRAM, 0);
191
+ }
192
+ if (sock < 0) {
193
+ perror("socket");
194
+ return 1;
195
+ }
196
+ val = 1;
197
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
198
+ val = 1;
199
+ setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
200
+
201
+ ret = bind(sock, (struct sockaddr *)addr, addr_size);
202
+ if (ret < 0) {
203
+ perror("bind");
204
+ return 1;
205
+ }
206
+ if (tcp) {
207
+ ret = listen(sock, 128);
208
+ assert(ret != -1);
209
+ }
210
+
211
+ if (ipv6) {
212
+ struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)addr;
213
+
214
+ inet_pton(AF_INET6, HOSTV6, &(saddr->sin6_addr));
215
+ } else {
216
+ struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
217
+
218
+ inet_pton(AF_INET, HOST, &saddr->sin_addr);
219
+ }
220
+
221
+ /* client sock setup */
222
+ if (tcp) {
223
+ *sock_client = socket(family, SOCK_STREAM, IPPROTO_TCP);
224
+ assert(client_connect);
225
+ } else {
226
+ *sock_client = socket(family, SOCK_DGRAM, 0);
227
+ }
228
+ if (*sock_client < 0) {
229
+ perror("socket");
230
+ return 1;
231
+ }
232
+ if (client_connect) {
233
+ ret = connect(*sock_client, (struct sockaddr *)addr, addr_size);
234
+ if (ret < 0) {
235
+ perror("connect");
236
+ return 1;
237
+ }
238
+ }
239
+ if (msg_zc) {
240
+ val = 1;
241
+ if (setsockopt(*sock_client, SOL_SOCKET, SO_ZEROCOPY, &val, sizeof(val))) {
242
+ perror("setsockopt zc");
243
+ return 1;
244
+ }
245
+ }
246
+ if (tcp) {
247
+ *sock_server = accept(listen_sock, NULL, NULL);
248
+ if (!*sock_server) {
249
+ fprintf(stderr, "can't accept\n");
250
+ return 1;
251
+ }
252
+ close(listen_sock);
253
+ }
254
+ return 0;
255
+ }
256
+
257
+ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server,
258
+ bool fixed_buf, struct sockaddr_storage *addr,
259
+ bool cork, bool mix_register,
260
+ int buf_idx, bool force_async, bool use_sendmsg)
261
+ {
262
+ struct iovec iov[CORK_REQS];
263
+ struct msghdr msghdr[CORK_REQS];
264
+ const unsigned zc_flags = 0;
265
+ struct io_uring_sqe *sqe;
266
+ struct io_uring_cqe *cqe;
267
+ int nr_reqs = cork ? CORK_REQS : 1;
268
+ int i, ret, nr_cqes, addr_len = 0;
269
+ size_t send_size = buffers_iov[buf_idx].iov_len;
270
+ size_t chunk_size = send_size / nr_reqs;
271
+ size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1);
272
+ char *buf = buffers_iov[buf_idx].iov_base;
273
+
274
+ if (addr) {
275
+ sa_family_t fam = ((struct sockaddr_in *)addr)->sin_family;
276
+
277
+ addr_len = (fam == AF_INET) ? sizeof(struct sockaddr_in) :
278
+ sizeof(struct sockaddr_in6);
279
+ }
280
+
281
+ memset(rx_buffer, 0, send_size);
282
+
283
+ for (i = 0; i < nr_reqs; i++) {
284
+ bool real_fixed_buf = fixed_buf;
285
+ size_t cur_size = chunk_size;
286
+ int msg_flags = MSG_WAITALL;
287
+
288
+ if (mix_register)
289
+ real_fixed_buf = rand() & 1;
290
+
291
+ if (cork && i != nr_reqs - 1)
292
+ msg_flags |= MSG_MORE;
293
+ if (i == nr_reqs - 1)
294
+ cur_size = chunk_size_last;
295
+
296
+ sqe = io_uring_get_sqe(ring);
297
+
298
+ if (!use_sendmsg) {
299
+ io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size,
300
+ cur_size, msg_flags, zc_flags);
301
+ if (real_fixed_buf) {
302
+ sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
303
+ sqe->buf_index = buf_idx;
304
+ }
305
+ if (addr)
306
+ io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)addr,
307
+ addr_len);
308
+ } else {
309
+ io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags);
310
+
311
+ memset(&msghdr[i], 0, sizeof(msghdr[i]));
312
+ iov[i].iov_len = cur_size;
313
+ iov[i].iov_base = buf + i * chunk_size;
314
+ msghdr[i].msg_iov = &iov[i];
315
+ msghdr[i].msg_iovlen = 1;
316
+ if (addr) {
317
+ msghdr[i].msg_name = addr;
318
+ msghdr[i].msg_namelen = addr_len;
319
+ }
320
+ }
321
+ sqe->user_data = i;
322
+ if (force_async)
323
+ sqe->flags |= IOSQE_ASYNC;
324
+ if (i != nr_reqs - 1)
325
+ sqe->flags |= IOSQE_IO_LINK;
326
+ }
327
+
328
+ sqe = io_uring_get_sqe(ring);
329
+ io_uring_prep_recv(sqe, sock_server, rx_buffer, send_size, MSG_WAITALL);
330
+ sqe->user_data = RX_TAG;
331
+
332
+ ret = io_uring_submit(ring);
333
+ if (ret != nr_reqs + 1) {
334
+ fprintf(stderr, "submit failed, got %i expected %i\n", ret, nr_reqs);
335
+ return 1;
336
+ }
337
+
338
+ nr_cqes = 2 * nr_reqs + 1;
339
+ for (i = 0; i < nr_cqes; i++) {
340
+ int expected = chunk_size;
341
+
342
+ ret = io_uring_wait_cqe(ring, &cqe);
343
+ if (ret) {
344
+ fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
345
+ return 1;
346
+ }
347
+ if (cqe->user_data == RX_TAG) {
348
+ if (cqe->res != send_size) {
349
+ fprintf(stderr, "rx failed %i\n", cqe->res);
350
+ return 1;
351
+ }
352
+ io_uring_cqe_seen(ring, cqe);
353
+ continue;
354
+ }
355
+
356
+ if (cqe->user_data >= nr_reqs) {
357
+ fprintf(stderr, "invalid user_data %lu\n",
358
+ (unsigned long)cqe->user_data);
359
+ return 1;
360
+ }
361
+ if (!(cqe->flags & IORING_CQE_F_NOTIF)) {
362
+ if (cqe->user_data == nr_reqs - 1)
363
+ expected = chunk_size_last;
364
+ if (cqe->res != expected) {
365
+ fprintf(stderr, "invalid cqe->res %d expected %d\n",
366
+ cqe->res, expected);
367
+ return 1;
368
+ }
369
+ }
370
+ if ((cqe->flags & IORING_CQE_F_MORE) ==
371
+ (cqe->flags & IORING_CQE_F_NOTIF)) {
372
+ fprintf(stderr, "unexpected cflags %i res %i\n",
373
+ cqe->flags, cqe->res);
374
+ return 1;
375
+ }
376
+ io_uring_cqe_seen(ring, cqe);
377
+ }
378
+
379
+ for (i = 0; i < send_size; i++) {
380
+ if (buf[i] != rx_buffer[i]) {
381
+ fprintf(stderr, "botched data, first mismated byte %i, "
382
+ "%u vs %u\n", i, buf[i], rx_buffer[i]);
383
+ return 1;
384
+ }
385
+ }
386
+ return 0;
387
+ }
388
+
389
+ static int test_inet_send(struct io_uring *ring)
390
+ {
391
+ struct sockaddr_storage addr;
392
+ int sock_client = -1, sock_server = -1;
393
+ int ret, j, i;
394
+
395
+ for (j = 0; j < 16; j++) {
396
+ bool ipv6 = j & 1;
397
+ bool client_connect = j & 2;
398
+ bool msg_zc_set = j & 4;
399
+ bool tcp = j & 8;
400
+
401
+ if (tcp && !client_connect)
402
+ continue;
403
+
404
+ ret = create_socketpair_ip(&addr, &sock_client, &sock_server, ipv6,
405
+ client_connect, msg_zc_set, tcp);
406
+ if (ret) {
407
+ fprintf(stderr, "sock prep failed %d\n", ret);
408
+ return 1;
409
+ }
410
+
411
+ for (i = 0; i < 256; i++) {
412
+ int buf_flavour = i & 3;
413
+ bool fixed_buf = i & 4;
414
+ struct sockaddr_storage *addr_arg = (i & 8) ? &addr : NULL;
415
+ bool cork = i & 16;
416
+ bool mix_register = i & 32;
417
+ bool force_async = i & 64;
418
+ bool use_sendmsg = i & 128;
419
+
420
+ if (buf_flavour == BUF_T_LARGE && !tcp)
421
+ continue;
422
+ if (!buffers_iov[buf_flavour].iov_base)
423
+ continue;
424
+ if (tcp && (cork || addr_arg))
425
+ continue;
426
+ if (mix_register && (!cork || fixed_buf))
427
+ continue;
428
+ if (!client_connect && addr_arg == NULL)
429
+ continue;
430
+ if (use_sendmsg && (mix_register || fixed_buf || !has_sendmsg))
431
+ continue;
432
+
433
+ ret = do_test_inet_send(ring, sock_client, sock_server, fixed_buf,
434
+ addr_arg, cork, mix_register,
435
+ buf_flavour, force_async, use_sendmsg);
436
+ if (ret) {
437
+ fprintf(stderr, "send failed fixed buf %i, conn %i, addr %i, "
438
+ "cork %i\n",
439
+ fixed_buf, client_connect, !!addr_arg,
440
+ cork);
441
+ return 1;
442
+ }
443
+ }
444
+
445
+ close(sock_client);
446
+ close(sock_server);
447
+ }
448
+ return 0;
449
+ }
450
+
451
+ static int test_async_addr(struct io_uring *ring)
452
+ {
453
+ struct io_uring_sqe *sqe;
454
+ struct io_uring_cqe *cqe;
455
+ struct sockaddr_storage addr;
456
+ int sock_tx = -1, sock_rx = -1;
457
+ struct __kernel_timespec ts;
458
+ int ret;
459
+
460
+ ts.tv_sec = 1;
461
+ ts.tv_nsec = 0;
462
+ ret = create_socketpair_ip(&addr, &sock_tx, &sock_rx, true, false, false, false);
463
+ if (ret) {
464
+ fprintf(stderr, "sock prep failed %d\n", ret);
465
+ return 1;
466
+ }
467
+
468
+ sqe = io_uring_get_sqe(ring);
469
+ io_uring_prep_timeout(sqe, &ts, 0, IORING_TIMEOUT_ETIME_SUCCESS);
470
+ sqe->user_data = 1;
471
+ sqe->flags |= IOSQE_IO_LINK;
472
+
473
+ sqe = io_uring_get_sqe(ring);
474
+ io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, 1, 0, 0);
475
+ sqe->user_data = 2;
476
+ io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)&addr,
477
+ sizeof(struct sockaddr_in6));
478
+
479
+ ret = io_uring_submit(ring);
480
+ assert(ret == 2);
481
+ memset(&addr, 0, sizeof(addr));
482
+
483
+ ret = io_uring_wait_cqe(ring, &cqe);
484
+ if (ret) {
485
+ fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
486
+ return 1;
487
+ }
488
+ if (cqe->user_data != 1 || cqe->res != -ETIME) {
489
+ fprintf(stderr, "invalid timeout res %i %i\n",
490
+ (int)cqe->user_data, cqe->res);
491
+ return 1;
492
+ }
493
+ io_uring_cqe_seen(ring, cqe);
494
+
495
+ ret = io_uring_wait_cqe(ring, &cqe);
496
+ if (ret) {
497
+ fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
498
+ return 1;
499
+ }
500
+ if (cqe->user_data != 2 || cqe->res != 1) {
501
+ fprintf(stderr, "invalid send %i %i\n",
502
+ (int)cqe->user_data, cqe->res);
503
+ return 1;
504
+ }
505
+ io_uring_cqe_seen(ring, cqe);
506
+ ret = recv(sock_rx, rx_buffer, 1, MSG_TRUNC);
507
+ assert(ret == 1);
508
+
509
+ ret = io_uring_wait_cqe(ring, &cqe);
510
+ if (ret) {
511
+ fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
512
+ return 1;
513
+ }
514
+ assert(cqe->flags & IORING_CQE_F_NOTIF);
515
+ io_uring_cqe_seen(ring, cqe);
516
+
517
+ close(sock_tx);
518
+ close(sock_rx);
519
+ return 0;
520
+ }
521
+
522
+ static bool io_check_zc_sendmsg(struct io_uring *ring)
523
+ {
524
+ struct io_uring_probe *p;
525
+ int ret;
526
+
527
+ p = t_calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
528
+ if (!p) {
529
+ fprintf(stderr, "probe allocation failed\n");
530
+ return false;
531
+ }
532
+ ret = io_uring_register_probe(ring, p, 256);
533
+ if (ret)
534
+ return false;
535
+ return p->ops_len > IORING_OP_SENDMSG_ZC;
536
+ }
537
+
538
+ /* see also send_recv.c:test_invalid */
539
+ static int test_invalid_zc(int fds[2])
540
+ {
541
+ struct io_uring ring;
542
+ int ret;
543
+ struct io_uring_cqe *cqe;
544
+ struct io_uring_sqe *sqe;
545
+ bool notif = false;
546
+
547
+ if (!has_sendmsg)
548
+ return 0;
549
+
550
+ ret = t_create_ring(8, &ring, 0);
551
+ if (ret)
552
+ return ret;
553
+
554
+ sqe = io_uring_get_sqe(&ring);
555
+ io_uring_prep_sendmsg(sqe, fds[0], NULL, MSG_WAITALL);
556
+ sqe->opcode = IORING_OP_SENDMSG_ZC;
557
+ sqe->flags |= IOSQE_ASYNC;
558
+
559
+ ret = io_uring_submit(&ring);
560
+ if (ret != 1) {
561
+ fprintf(stderr, "submit failed %i\n", ret);
562
+ return ret;
563
+ }
564
+ ret = io_uring_wait_cqe(&ring, &cqe);
565
+ if (ret)
566
+ return 1;
567
+ if (cqe->flags & IORING_CQE_F_MORE)
568
+ notif = true;
569
+ io_uring_cqe_seen(&ring, cqe);
570
+
571
+ if (notif) {
572
+ ret = io_uring_wait_cqe(&ring, &cqe);
573
+ if (ret)
574
+ return 1;
575
+ io_uring_cqe_seen(&ring, cqe);
576
+ }
577
+ io_uring_queue_exit(&ring);
578
+ return 0;
579
+ }
580
+
581
+ int main(int argc, char *argv[])
582
+ {
583
+ struct sockaddr_storage addr;
584
+ struct io_uring ring;
585
+ int i, ret, sp[2];
586
+ size_t len;
587
+
588
+ if (argc > 1)
589
+ return T_EXIT_SKIP;
590
+
591
+ /* create TCP IPv6 pair */
592
+ ret = create_socketpair_ip(&addr, &sp[0], &sp[1], true, true, false, true);
593
+ if (ret) {
594
+ fprintf(stderr, "sock prep failed %d\n", ret);
595
+ return T_EXIT_FAIL;
596
+ }
597
+
598
+ len = 1U << 25; /* 32MB, should be enough to trigger a short send */
599
+ tx_buffer = aligned_alloc(4096, len);
600
+ rx_buffer = aligned_alloc(4096, len);
601
+ if (tx_buffer && rx_buffer) {
602
+ buffers_iov[BUF_T_LARGE].iov_base = tx_buffer;
603
+ buffers_iov[BUF_T_LARGE].iov_len = len;
604
+ } else {
605
+ printf("skip large buffer tests, can't alloc\n");
606
+
607
+ len = 8192;
608
+ tx_buffer = aligned_alloc(4096, len);
609
+ rx_buffer = aligned_alloc(4096, len);
610
+ }
611
+ if (!tx_buffer || !rx_buffer) {
612
+ fprintf(stderr, "can't allocate buffers\n");
613
+ return T_EXIT_FAIL;
614
+ }
615
+
616
+ buffers_iov[BUF_T_NORMAL].iov_base = tx_buffer + 4096;
617
+ buffers_iov[BUF_T_NORMAL].iov_len = 4096;
618
+ buffers_iov[BUF_T_SMALL].iov_base = tx_buffer;
619
+ buffers_iov[BUF_T_SMALL].iov_len = 137;
620
+ buffers_iov[BUF_T_NONALIGNED].iov_base = tx_buffer + BUFFER_OFFSET;
621
+ buffers_iov[BUF_T_NONALIGNED].iov_len = 8192 - BUFFER_OFFSET - 13;
622
+
623
+ ret = io_uring_queue_init(32, &ring, 0);
624
+ if (ret) {
625
+ fprintf(stderr, "queue init failed: %d\n", ret);
626
+ return T_EXIT_FAIL;
627
+ }
628
+
629
+ srand((unsigned)time(NULL));
630
+ for (i = 0; i < len; i++)
631
+ tx_buffer[i] = i;
632
+ memset(rx_buffer, 0, len);
633
+
634
+ ret = test_basic_send(&ring, sp[0], sp[1]);
635
+ if (ret == T_EXIT_SKIP)
636
+ return ret;
637
+ if (ret) {
638
+ fprintf(stderr, "test_basic_send() failed\n");
639
+ return T_EXIT_FAIL;
640
+ }
641
+
642
+ has_sendmsg = io_check_zc_sendmsg(&ring);
643
+
644
+ ret = test_send_faults(&ring, sp[0], sp[1]);
645
+ if (ret) {
646
+ fprintf(stderr, "test_send_faults() failed\n");
647
+ return T_EXIT_FAIL;
648
+ }
649
+
650
+ ret = test_invalid_zc(sp);
651
+ if (ret) {
652
+ fprintf(stderr, "test_invalid_zc() failed\n");
653
+ return T_EXIT_FAIL;
654
+ }
655
+
656
+ close(sp[0]);
657
+ close(sp[1]);
658
+
659
+ ret = test_async_addr(&ring);
660
+ if (ret) {
661
+ fprintf(stderr, "test_async_addr() failed\n");
662
+ return T_EXIT_FAIL;
663
+ }
664
+
665
+ ret = t_register_buffers(&ring, buffers_iov, ARRAY_SIZE(buffers_iov));
666
+ if (ret == T_SETUP_SKIP) {
667
+ fprintf(stderr, "can't register bufs, skip\n");
668
+ goto out;
669
+ } else if (ret != T_SETUP_OK) {
670
+ fprintf(stderr, "buffer registration failed %i\n", ret);
671
+ return T_EXIT_FAIL;
672
+ }
673
+
674
+ ret = test_inet_send(&ring);
675
+ if (ret) {
676
+ fprintf(stderr, "test_inet_send() failed\n");
677
+ return T_EXIT_FAIL;
678
+ }
679
+ out:
680
+ io_uring_queue_exit(&ring);
681
+ close(sp[0]);
682
+ close(sp[1]);
683
+ return T_EXIT_PASS;
684
+ }