polyphony 0.98 → 0.99.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -1
  3. data/.rubocop.yml +3 -3
  4. data/.yardopts +30 -0
  5. data/CHANGELOG.md +11 -0
  6. data/LICENSE +1 -1
  7. data/README.md +63 -29
  8. data/Rakefile +1 -5
  9. data/TODO.md +0 -4
  10. data/docs/{main-concepts/concurrency.md → concurrency.md} +2 -9
  11. data/docs/{main-concepts/design-principles.md → design-principles.md} +3 -9
  12. data/docs/{main-concepts/exception-handling.md → exception-handling.md} +2 -9
  13. data/docs/{main-concepts/extending.md → extending.md} +2 -9
  14. data/docs/faq.md +3 -16
  15. data/docs/{main-concepts/fiber-scheduling.md → fiber-scheduling.md} +1 -9
  16. data/docs/link_rewriter.rb +16 -0
  17. data/docs/{getting-started/overview.md → overview.md} +1 -30
  18. data/docs/{getting-started/tutorial.md → tutorial.md} +3 -28
  19. data/docs/{_posts/2020-07-26-polyphony-0.44.md → whats-new.md} +3 -1
  20. data/examples/adapters/redis_client.rb +3 -2
  21. data/examples/io/echo_server.rb +1 -1
  22. data/examples/io/echo_server_plain_ruby.rb +26 -0
  23. data/examples/io/https_server_sni_2.rb +14 -8
  24. data/ext/polyphony/backend_io_uring.c +154 -9
  25. data/ext/polyphony/backend_io_uring_context.c +21 -12
  26. data/ext/polyphony/backend_io_uring_context.h +12 -7
  27. data/ext/polyphony/backend_libev.c +1 -1
  28. data/ext/polyphony/extconf.rb +25 -8
  29. data/ext/polyphony/fiber.c +79 -2
  30. data/ext/polyphony/io_extensions.c +53 -0
  31. data/ext/polyphony/libev.h +0 -2
  32. data/ext/polyphony/pipe.c +42 -2
  33. data/ext/polyphony/polyphony.c +345 -31
  34. data/ext/polyphony/polyphony.h +9 -2
  35. data/ext/polyphony/queue.c +181 -0
  36. data/ext/polyphony/ring_buffer.c +0 -1
  37. data/ext/polyphony/runqueue.c +8 -1
  38. data/ext/polyphony/runqueue_ring_buffer.c +13 -0
  39. data/ext/polyphony/runqueue_ring_buffer.h +2 -1
  40. data/ext/polyphony/socket_extensions.c +6 -0
  41. data/ext/polyphony/thread.c +34 -2
  42. data/lib/polyphony/adapters/process.rb +11 -1
  43. data/lib/polyphony/adapters/sequel.rb +1 -1
  44. data/lib/polyphony/core/channel.rb +2 -0
  45. data/lib/polyphony/core/debug.rb +1 -1
  46. data/lib/polyphony/core/global_api.rb +25 -24
  47. data/lib/polyphony/core/resource_pool.rb +7 -6
  48. data/lib/polyphony/core/sync.rb +55 -2
  49. data/lib/polyphony/core/thread_pool.rb +3 -3
  50. data/lib/polyphony/core/timer.rb +8 -8
  51. data/lib/polyphony/extensions/exception.rb +2 -0
  52. data/lib/polyphony/extensions/fiber.rb +15 -13
  53. data/lib/polyphony/extensions/io.rb +161 -16
  54. data/lib/polyphony/extensions/kernel.rb +20 -2
  55. data/lib/polyphony/extensions/openssl.rb +101 -12
  56. data/lib/polyphony/extensions/pipe.rb +103 -7
  57. data/lib/polyphony/extensions/process.rb +13 -1
  58. data/lib/polyphony/extensions/socket.rb +93 -27
  59. data/lib/polyphony/extensions/thread.rb +9 -1
  60. data/lib/polyphony/extensions/timeout.rb +1 -1
  61. data/lib/polyphony/version.rb +2 -1
  62. data/lib/polyphony.rb +27 -7
  63. data/polyphony.gemspec +1 -8
  64. data/test/stress.rb +1 -1
  65. data/test/test_global_api.rb +45 -7
  66. data/test/test_io.rb +6 -7
  67. data/test/test_socket.rb +157 -0
  68. data/test/test_sync.rb +42 -1
  69. data/test/test_timer.rb +5 -5
  70. data/vendor/liburing/.github/workflows/build.yml +7 -16
  71. data/vendor/liburing/.gitignore +5 -0
  72. data/vendor/liburing/CHANGELOG +23 -1
  73. data/vendor/liburing/Makefile +4 -3
  74. data/vendor/liburing/Makefile.common +1 -0
  75. data/vendor/liburing/README +48 -0
  76. data/vendor/liburing/configure +76 -6
  77. data/vendor/liburing/debian/changelog +11 -0
  78. data/vendor/liburing/debian/control +7 -16
  79. data/vendor/liburing/debian/liburing-dev.manpages +3 -6
  80. data/vendor/liburing/debian/liburing2.install +1 -0
  81. data/vendor/liburing/debian/liburing2.symbols +56 -0
  82. data/vendor/liburing/debian/rules +15 -68
  83. data/vendor/liburing/examples/Makefile +4 -0
  84. data/vendor/liburing/examples/io_uring-close-test.c +123 -0
  85. data/vendor/liburing/examples/io_uring-udp.c +1 -1
  86. data/vendor/liburing/examples/send-zerocopy.c +315 -56
  87. data/vendor/liburing/examples/ucontext-cp.c +2 -17
  88. data/vendor/liburing/liburing-ffi.pc.in +12 -0
  89. data/vendor/liburing/liburing.pc.in +1 -1
  90. data/vendor/liburing/liburing.spec +1 -1
  91. data/vendor/liburing/make-debs.sh +3 -3
  92. data/vendor/liburing/man/IO_URING_CHECK_VERSION.3 +1 -0
  93. data/vendor/liburing/man/IO_URING_VERSION_MAJOR.3 +1 -0
  94. data/vendor/liburing/man/IO_URING_VERSION_MINOR.3 +1 -0
  95. data/vendor/liburing/man/io_uring_buf_ring_add.3 +6 -6
  96. data/vendor/liburing/man/io_uring_check_version.3 +72 -0
  97. data/vendor/liburing/man/io_uring_close_ring_fd.3 +43 -0
  98. data/vendor/liburing/man/io_uring_major_version.3 +1 -0
  99. data/vendor/liburing/man/io_uring_minor_version.3 +1 -0
  100. data/vendor/liburing/man/io_uring_prep_accept.3 +1 -1
  101. data/vendor/liburing/man/io_uring_prep_fgetxattr.3 +1 -0
  102. data/vendor/liburing/man/io_uring_prep_fsetxattr.3 +1 -0
  103. data/vendor/liburing/man/io_uring_prep_getxattr.3 +61 -0
  104. data/vendor/liburing/man/io_uring_prep_link_timeout.3 +94 -0
  105. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +22 -2
  106. data/vendor/liburing/man/io_uring_prep_msg_ring_cqe_flags.3 +1 -0
  107. data/vendor/liburing/man/io_uring_prep_poll_add.3 +1 -1
  108. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +18 -9
  109. data/vendor/liburing/man/io_uring_prep_readv.3 +3 -3
  110. data/vendor/liburing/man/io_uring_prep_readv2.3 +3 -3
  111. data/vendor/liburing/man/io_uring_prep_recv.3 +5 -5
  112. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +4 -4
  113. data/vendor/liburing/man/io_uring_prep_send.3 +9 -0
  114. data/vendor/liburing/man/io_uring_prep_send_set_addr.3 +38 -0
  115. data/vendor/liburing/man/io_uring_prep_send_zc.3 +39 -7
  116. data/vendor/liburing/man/io_uring_prep_send_zc_fixed.3 +1 -0
  117. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +20 -0
  118. data/vendor/liburing/man/io_uring_prep_sendmsg_zc.3 +1 -0
  119. data/vendor/liburing/man/io_uring_prep_setxattr.3 +64 -0
  120. data/vendor/liburing/man/io_uring_prep_splice.3 +40 -0
  121. data/vendor/liburing/man/io_uring_prep_writev.3 +2 -2
  122. data/vendor/liburing/man/io_uring_prep_writev2.3 +2 -2
  123. data/vendor/liburing/man/io_uring_recvmsg_out.3 +13 -9
  124. data/vendor/liburing/man/io_uring_register.2 +15 -9
  125. data/vendor/liburing/man/io_uring_register_buf_ring.3 +4 -4
  126. data/vendor/liburing/man/io_uring_register_buffers.3 +49 -6
  127. data/vendor/liburing/man/io_uring_register_buffers_sparse.3 +1 -0
  128. data/vendor/liburing/man/io_uring_register_buffers_tags.3 +1 -0
  129. data/vendor/liburing/man/io_uring_register_buffers_update_tag.3 +1 -0
  130. data/vendor/liburing/man/io_uring_register_files.3 +60 -5
  131. data/vendor/liburing/man/io_uring_register_files_tags.3 +1 -0
  132. data/vendor/liburing/man/io_uring_register_files_update.3 +1 -0
  133. data/vendor/liburing/man/io_uring_register_files_update_tag.3 +1 -0
  134. data/vendor/liburing/man/io_uring_setup.2 +31 -2
  135. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +1 -1
  136. data/vendor/liburing/src/Makefile +25 -3
  137. data/vendor/liburing/src/ffi.c +15 -0
  138. data/vendor/liburing/src/include/liburing/io_uring.h +30 -7
  139. data/vendor/liburing/src/include/liburing.h +190 -148
  140. data/vendor/liburing/src/int_flags.h +1 -0
  141. data/vendor/liburing/src/lib.h +5 -16
  142. data/vendor/liburing/src/liburing-ffi.map +172 -0
  143. data/vendor/liburing/src/liburing.map +11 -0
  144. data/vendor/liburing/src/nolibc.c +9 -2
  145. data/vendor/liburing/src/queue.c +2 -2
  146. data/vendor/liburing/src/register.c +66 -96
  147. data/vendor/liburing/src/setup.c +5 -4
  148. data/vendor/liburing/src/version.c +21 -0
  149. data/vendor/liburing/test/232c93d07b74.c +3 -3
  150. data/vendor/liburing/test/35fa71a030ca.c +3 -3
  151. data/vendor/liburing/test/500f9fbadef8.c +2 -0
  152. data/vendor/liburing/test/917257daa0fe.c +1 -1
  153. data/vendor/liburing/test/Makefile +27 -7
  154. data/vendor/liburing/test/a0908ae19763.c +2 -2
  155. data/vendor/liburing/test/a4c0b3decb33.c +2 -2
  156. data/vendor/liburing/test/accept-link.c +4 -4
  157. data/vendor/liburing/test/accept-reuse.c +5 -7
  158. data/vendor/liburing/test/accept.c +34 -31
  159. data/vendor/liburing/test/b19062a56726.c +1 -1
  160. data/vendor/liburing/test/buf-ring.c +58 -4
  161. data/vendor/liburing/test/ce593a6c480a.c +2 -2
  162. data/vendor/liburing/test/close-opath.c +2 -1
  163. data/vendor/liburing/test/connect.c +8 -0
  164. data/vendor/liburing/test/cq-overflow.c +14 -8
  165. data/vendor/liburing/test/d4ae271dfaae.c +1 -1
  166. data/vendor/liburing/test/defer-taskrun.c +64 -9
  167. data/vendor/liburing/test/defer.c +1 -1
  168. data/vendor/liburing/test/double-poll-crash.c +3 -3
  169. data/vendor/liburing/test/eeed8b54e0df.c +8 -3
  170. data/vendor/liburing/test/eploop.c +74 -0
  171. data/vendor/liburing/test/eventfd-ring.c +1 -1
  172. data/vendor/liburing/test/eventfd.c +1 -1
  173. data/vendor/liburing/test/evloop.c +73 -0
  174. data/vendor/liburing/test/exit-no-cleanup.c +1 -1
  175. data/vendor/liburing/test/fadvise.c +1 -1
  176. data/vendor/liburing/test/fc2a85cb02ef.c +3 -3
  177. data/vendor/liburing/test/fd-pass.c +35 -16
  178. data/vendor/liburing/test/file-register.c +61 -0
  179. data/vendor/liburing/test/file-verify.c +2 -2
  180. data/vendor/liburing/test/files-exit-hang-timeout.c +2 -2
  181. data/vendor/liburing/test/fixed-link.c +1 -1
  182. data/vendor/liburing/test/fsnotify.c +118 -0
  183. data/vendor/liburing/test/hardlink.c +1 -1
  184. data/vendor/liburing/test/helpers.c +54 -2
  185. data/vendor/liburing/test/helpers.h +4 -0
  186. data/vendor/liburing/test/io-cancel.c +3 -1
  187. data/vendor/liburing/test/io_uring_passthrough.c +39 -8
  188. data/vendor/liburing/test/io_uring_setup.c +3 -80
  189. data/vendor/liburing/test/iopoll-overflow.c +118 -0
  190. data/vendor/liburing/test/iopoll.c +90 -4
  191. data/vendor/liburing/test/lfs-openat-write.c +7 -9
  192. data/vendor/liburing/test/lfs-openat.c +6 -8
  193. data/vendor/liburing/test/link_drain.c +31 -5
  194. data/vendor/liburing/test/madvise.c +1 -1
  195. data/vendor/liburing/test/msg-ring-flags.c +192 -0
  196. data/vendor/liburing/test/msg-ring-overflow.c +159 -0
  197. data/vendor/liburing/test/msg-ring.c +173 -13
  198. data/vendor/liburing/test/multicqes_drain.c +22 -19
  199. data/vendor/liburing/test/nvme.h +4 -3
  200. data/vendor/liburing/test/pipe-bug.c +95 -0
  201. data/vendor/liburing/test/poll-link.c +3 -3
  202. data/vendor/liburing/test/poll-many.c +41 -19
  203. data/vendor/liburing/test/poll-mshot-overflow.c +105 -2
  204. data/vendor/liburing/test/poll-race-mshot.c +292 -0
  205. data/vendor/liburing/test/poll-race.c +105 -0
  206. data/vendor/liburing/test/poll.c +244 -26
  207. data/vendor/liburing/test/pollfree.c +5 -5
  208. data/vendor/liburing/test/read-before-exit.c +20 -3
  209. data/vendor/liburing/test/read-write.c +2 -0
  210. data/vendor/liburing/test/recv-multishot.c +96 -3
  211. data/vendor/liburing/test/reg-reg-ring.c +90 -0
  212. data/vendor/liburing/test/rename.c +1 -1
  213. data/vendor/liburing/test/ring-leak.c +0 -1
  214. data/vendor/liburing/test/ring-leak2.c +1 -1
  215. data/vendor/liburing/test/ringbuf-read.c +10 -6
  216. data/vendor/liburing/test/send-zerocopy.c +273 -103
  217. data/vendor/liburing/test/send_recv.c +7 -4
  218. data/vendor/liburing/test/sendmsg_fs_cve.c +2 -2
  219. data/vendor/liburing/test/single-issuer.c +7 -9
  220. data/vendor/liburing/test/skip-cqe.c +3 -4
  221. data/vendor/liburing/test/socket.c +0 -1
  222. data/vendor/liburing/test/sq-poll-dup.c +10 -3
  223. data/vendor/liburing/test/sq-poll-kthread.c +1 -1
  224. data/vendor/liburing/test/sq-poll-share.c +3 -2
  225. data/vendor/liburing/test/sqpoll-cancel-hang.c +17 -6
  226. data/vendor/liburing/test/sqpoll-disable-exit.c +4 -4
  227. data/vendor/liburing/test/symlink.c +2 -1
  228. data/vendor/liburing/test/test.h +2 -1
  229. data/vendor/liburing/test/timeout-new.c +11 -7
  230. data/vendor/liburing/test/timeout.c +1 -2
  231. data/vendor/liburing/test/unlink.c +1 -1
  232. data/vendor/liburing/test/version.c +25 -0
  233. data/vendor/liburing/test/wakeup-hang.c +1 -1
  234. data/vendor/liburing/test/xattr.c +8 -4
  235. metadata +57 -44
  236. data/docs/_config.yml +0 -64
  237. data/docs/_includes/head.html +0 -40
  238. data/docs/_includes/title.html +0 -1
  239. data/docs/_sass/custom/custom.scss +0 -10
  240. data/docs/_sass/overrides.scss +0 -0
  241. data/docs/api-reference/exception.md +0 -31
  242. data/docs/api-reference/fiber.md +0 -425
  243. data/docs/api-reference/index.md +0 -9
  244. data/docs/api-reference/io.md +0 -36
  245. data/docs/api-reference/object.md +0 -99
  246. data/docs/api-reference/polyphony-baseexception.md +0 -33
  247. data/docs/api-reference/polyphony-cancel.md +0 -26
  248. data/docs/api-reference/polyphony-moveon.md +0 -24
  249. data/docs/api-reference/polyphony-net.md +0 -20
  250. data/docs/api-reference/polyphony-process.md +0 -28
  251. data/docs/api-reference/polyphony-resourcepool.md +0 -59
  252. data/docs/api-reference/polyphony-restart.md +0 -18
  253. data/docs/api-reference/polyphony-terminate.md +0 -18
  254. data/docs/api-reference/polyphony-threadpool.md +0 -67
  255. data/docs/api-reference/polyphony-throttler.md +0 -77
  256. data/docs/api-reference/polyphony.md +0 -36
  257. data/docs/api-reference/thread.md +0 -88
  258. data/docs/favicon.ico +0 -0
  259. data/docs/getting-started/index.md +0 -10
  260. data/docs/getting-started/installing.md +0 -34
  261. data/vendor/liburing/debian/compat +0 -1
  262. data/vendor/liburing/debian/liburing1-udeb.install +0 -1
  263. data/vendor/liburing/debian/liburing1.install +0 -1
  264. data/vendor/liburing/debian/liburing1.symbols +0 -32
  265. /data/{docs/assets/img → assets}/echo-fibers.svg +0 -0
  266. /data/{docs → assets}/polyphony-logo.png +0 -0
  267. /data/{docs/assets/img → assets}/sleeping-fiber.svg +0 -0
@@ -192,13 +192,13 @@ static int do_send(void)
192
192
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
193
193
  if (sockfd < 0) {
194
194
  perror("socket");
195
- return 1;
195
+ goto err2;
196
196
  }
197
197
 
198
198
  ret = connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
199
199
  if (ret < 0) {
200
200
  perror("connect");
201
- return 1;
201
+ goto err;
202
202
  }
203
203
 
204
204
  sqe = io_uring_get_sqe(&ring);
@@ -214,8 +214,7 @@ static int do_send(void)
214
214
  ret = io_uring_wait_cqe(&ring, &cqe);
215
215
  if (cqe->res == -EINVAL) {
216
216
  fprintf(stdout, "send not supported, skipping\n");
217
- close(sockfd);
218
- return 0;
217
+ goto err;
219
218
  }
220
219
  if (cqe->res != iov.iov_len) {
221
220
  fprintf(stderr, "failed cqe: %d\n", cqe->res);
@@ -223,9 +222,13 @@ static int do_send(void)
223
222
  }
224
223
 
225
224
  close(sockfd);
225
+ io_uring_queue_exit(&ring);
226
226
  return 0;
227
+
227
228
  err:
228
229
  close(sockfd);
230
+ err2:
231
+ io_uring_queue_exit(&ring);
229
232
  return 1;
230
233
  }
231
234
 
@@ -1,4 +1,4 @@
1
- /* SPDX-License-Identifier: MIT */
1
+ /* SPDX-License-Identifier: GPL-2.0-or-later */
2
2
  /*
3
3
  * repro-CVE-2020-29373 -- Reproducer for CVE-2020-29373.
4
4
  *
@@ -16,7 +16,7 @@
16
16
  * GNU General Public License for more details.
17
17
  *
18
18
  * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
19
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
21
 
22
22
  #include <unistd.h>
@@ -5,7 +5,6 @@
5
5
  #include <stdlib.h>
6
6
  #include <string.h>
7
7
  #include <fcntl.h>
8
- #include <error.h>
9
8
  #include <sys/types.h>
10
9
  #include <sys/wait.h>
11
10
 
@@ -56,13 +55,13 @@ static int try_submit(struct io_uring *ring)
56
55
  return ret;
57
56
 
58
57
  if (ret != 1)
59
- error(1, ret, "submit %i", ret);
58
+ t_error(1, ret, "submit %i", ret);
60
59
  ret = io_uring_wait_cqe(ring, &cqe);
61
60
  if (ret)
62
- error(1, ret, "wait fail %i", ret);
61
+ t_error(1, ret, "wait fail %i", ret);
63
62
 
64
63
  if (cqe->res || cqe->user_data != 42)
65
- error(1, ret, "invalid cqe");
64
+ t_error(1, ret, "invalid cqe");
66
65
 
67
66
  io_uring_cqe_seen(ring, cqe);
68
67
  return 0;
@@ -78,7 +77,6 @@ int main(int argc, char *argv[])
78
77
 
79
78
  ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER);
80
79
  if (ret == -EINVAL) {
81
- fprintf(stderr, "SETUP_SINGLE_ISSUER is not supported, skip\n");
82
80
  return T_EXIT_SKIP;
83
81
  } else if (ret) {
84
82
  fprintf(stderr, "io_uring_queue_init() failed %i\n", ret);
@@ -106,7 +104,7 @@ int main(int argc, char *argv[])
106
104
  ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
107
105
  IORING_SETUP_R_DISABLED);
108
106
  if (ret)
109
- error(1, ret, "ring init (2) %i", ret);
107
+ t_error(1, ret, "ring init (2) %i", ret);
110
108
 
111
109
  if (!fork_t()) {
112
110
  io_uring_enable_rings(&ring);
@@ -122,7 +120,7 @@ int main(int argc, char *argv[])
122
120
  ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
123
121
  IORING_SETUP_R_DISABLED);
124
122
  if (ret)
125
- error(1, ret, "ring init (3) %i", ret);
123
+ t_error(1, ret, "ring init (3) %i", ret);
126
124
 
127
125
  io_uring_enable_rings(&ring);
128
126
  if (!fork_t()) {
@@ -137,7 +135,7 @@ int main(int argc, char *argv[])
137
135
  /* test that anyone can submit to a SQPOLL|SINGLE_ISSUER ring */
138
136
  ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_SQPOLL);
139
137
  if (ret)
140
- error(1, ret, "ring init (4) %i", ret);
138
+ t_error(1, ret, "ring init (4) %i", ret);
141
139
 
142
140
  ret = try_submit(&ring);
143
141
  if (ret) {
@@ -157,7 +155,7 @@ int main(int argc, char *argv[])
157
155
  /* test that IORING_ENTER_REGISTERED_RING doesn't break anything */
158
156
  ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER);
159
157
  if (ret)
160
- error(1, ret, "ring init (5) %i", ret);
158
+ t_error(1, ret, "ring init (5) %i", ret);
161
159
 
162
160
  if (!fork_t()) {
163
161
  ret = try_submit(&ring);
@@ -8,6 +8,7 @@
8
8
  #include <assert.h>
9
9
 
10
10
  #include "liburing.h"
11
+ #include "helpers.h"
11
12
 
12
13
  #define LINK_SIZE 6
13
14
  #define TIMEOUT_USER_DATA (-1)
@@ -323,10 +324,8 @@ int main(int argc, char *argv[])
323
324
  return 1;
324
325
  }
325
326
 
326
- if (!(ring.features & IORING_FEAT_CQE_SKIP)) {
327
- printf("IOSQE_CQE_SKIP_SUCCESS is not supported, skip\n");
328
- return 0;
329
- }
327
+ if (!(ring.features & IORING_FEAT_CQE_SKIP))
328
+ return T_EXIT_SKIP;
330
329
 
331
330
  for (i = 0; i < 4; i++) {
332
331
  bool skip_last = i & 1;
@@ -272,7 +272,6 @@ static int do_send(int socket_direct, int alloc)
272
272
  }
273
273
  if (cqe->res < 0) {
274
274
  if (cqe->res == -EINVAL) {
275
- fprintf(stdout, "No socket support, skipping\n");
276
275
  no_socket = 1;
277
276
  io_uring_cqe_seen(&ring, cqe);
278
277
  return fallback_send(&ring, &saddr);
@@ -171,14 +171,21 @@ int main(int argc, char *argv[])
171
171
  vecs = t_create_buffers(BUFFERS, BS);
172
172
 
173
173
  fd = open(fname, O_RDONLY | O_DIRECT);
174
- if (fname != argv[1])
175
- unlink(fname);
176
-
177
174
  if (fd < 0) {
175
+ int __e = errno;
176
+
177
+ if (fname != argv[1])
178
+ unlink(fname);
179
+
180
+ if (__e == EINVAL)
181
+ return T_EXIT_SKIP;
178
182
  perror("open");
179
183
  return -1;
180
184
  }
181
185
 
186
+ if (fname != argv[1])
187
+ unlink(fname);
188
+
182
189
  ret = test(fd, 0, 0);
183
190
  if (ret) {
184
191
  fprintf(stderr, "test 0 0 failed\n");
@@ -117,7 +117,7 @@ err_pipe:
117
117
  return ret;
118
118
  }
119
119
 
120
- int test_sq_poll_kthread_stopped(bool do_exit)
120
+ static int test_sq_poll_kthread_stopped(bool do_exit)
121
121
  {
122
122
  pid_t pid;
123
123
  int status = 0;
@@ -89,13 +89,14 @@ int main(int argc, char *argv[])
89
89
  vecs = t_create_buffers(BUFFERS, BS);
90
90
 
91
91
  fd = open(fname, O_RDONLY | O_DIRECT);
92
- if (fname != argv[1])
93
- unlink(fname);
94
92
  if (fd < 0) {
95
93
  perror("open");
96
94
  return -1;
97
95
  }
98
96
 
97
+ if (fname != argv[1])
98
+ unlink(fname);
99
+
99
100
  for (i = 0; i < NR_RINGS; i++) {
100
101
  struct io_uring_params p = { };
101
102
 
@@ -9,8 +9,16 @@
9
9
  #include <time.h>
10
10
  #include <unistd.h>
11
11
  #include "liburing.h"
12
+ #include "helpers.h"
12
13
  #include "../src/syscall.h"
13
14
 
15
+ /*
16
+ * This syzbot test is known broken on some archs, just allow the ones that
17
+ * are regularly tested.
18
+ */
19
+ #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
20
+ defined(__aarch64__)
21
+
14
22
  static uint64_t current_time_ms(void)
15
23
  {
16
24
  struct timespec ts;
@@ -39,7 +47,7 @@ static void kill_and_wait(int pid, int* status)
39
47
 
40
48
  #define WAIT_FLAGS __WALL
41
49
 
42
- uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0};
50
+ static uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0};
43
51
 
44
52
  static long syz_io_uring_setup(volatile long a0, volatile long a1,
45
53
  volatile long a2, volatile long a3, volatile long a4, volatile long
@@ -92,7 +100,7 @@ SIZEOF_IO_URING_CQE + 63) & ~63;
92
100
  }
93
101
 
94
102
 
95
- void trigger_bug(void)
103
+ static void trigger_bug(void)
96
104
  {
97
105
  intptr_t res = 0;
98
106
  *(uint32_t*)0x20000204 = 0;
@@ -133,7 +141,7 @@ void trigger_bug(void)
133
141
  }
134
142
  int main(void)
135
143
  {
136
- mmap((void *)0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
144
+ mmap((void *)0x20000000ul, 0x1000000ul, 7ul, MAP_ANON|MAP_PRIVATE, -1, 0ul);
137
145
  int pid = fork();
138
146
  if (pid < 0)
139
147
  exit(1);
@@ -152,6 +160,9 @@ int main(void)
152
160
  }
153
161
  return 0;
154
162
  }
155
-
156
-
157
-
163
+ #else
164
+ int main(void)
165
+ {
166
+ return T_EXIT_SKIP;
167
+ }
168
+ #endif
@@ -136,7 +136,7 @@ static void kill_and_wait(int pid, int* status)
136
136
  }
137
137
  }
138
138
 
139
- static void setup_test()
139
+ static void setup_test(void)
140
140
  {
141
141
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
142
142
  setpgrp();
@@ -188,9 +188,9 @@ void execute_one(void)
188
188
  }
189
189
  int main(void)
190
190
  {
191
- mmap((void *)0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
192
- mmap((void *)0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
193
- mmap((void *)0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
191
+ mmap((void *)0x1ffff000ul, 0x1000ul, 0ul, MAP_ANON|MAP_PRIVATE, -1, 0ul);
192
+ mmap((void *)0x20000000ul, 0x1000000ul, 7ul, MAP_ANON|MAP_PRIVATE, -1, 0ul);
193
+ mmap((void *)0x21000000ul, 0x1000ul, 0ul, MAP_ANON|MAP_PRIVATE, -1, 0ul);
194
194
  loop();
195
195
  return 0;
196
196
  }
@@ -43,7 +43,8 @@ err:
43
43
  return 1;
44
44
  }
45
45
 
46
- int test_link_contents(const char* linkname, const char *expected_contents)
46
+ static int test_link_contents(const char* linkname,
47
+ const char *expected_contents)
47
48
  {
48
49
  char buf[128];
49
50
  int ret = readlink(linkname, buf, 127);
@@ -14,7 +14,8 @@ typedef struct io_uring_test_config {
14
14
  const char *description;
15
15
  } io_uring_test_config;
16
16
 
17
- io_uring_test_config io_uring_test_configs[] = {
17
+ __attribute__((__unused__))
18
+ static io_uring_test_config io_uring_test_configs[] = {
18
19
  { 0, "default" },
19
20
  { IORING_SETUP_SQE128, "large SQE"},
20
21
  { IORING_SETUP_CQE32, "large CQE"},
@@ -12,9 +12,9 @@
12
12
  #define TIMEOUT_MSEC 200
13
13
  #define TIMEOUT_SEC 10
14
14
 
15
- int thread_ret0, thread_ret1;
16
- int cnt = 0;
17
- pthread_mutex_t mutex;
15
+ static int thread_ret0, thread_ret1;
16
+ static int cnt = 0;
17
+ static pthread_mutex_t mutex;
18
18
 
19
19
  static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
20
20
  {
@@ -111,7 +111,8 @@ static int test_return_after_timeout(struct io_uring *ring)
111
111
  return 0;
112
112
  }
113
113
 
114
- int __reap_thread_fn(void *data) {
114
+ static int __reap_thread_fn(void *data)
115
+ {
115
116
  struct io_uring *ring = (struct io_uring *)data;
116
117
  struct io_uring_cqe *cqe;
117
118
  struct __kernel_timespec ts;
@@ -123,12 +124,14 @@ int __reap_thread_fn(void *data) {
123
124
  return io_uring_wait_cqe_timeout(ring, &cqe, &ts);
124
125
  }
125
126
 
126
- void *reap_thread_fn0(void *data) {
127
+ static void *reap_thread_fn0(void *data)
128
+ {
127
129
  thread_ret0 = __reap_thread_fn(data);
128
130
  return NULL;
129
131
  }
130
132
 
131
- void *reap_thread_fn1(void *data) {
133
+ static void *reap_thread_fn1(void *data)
134
+ {
132
135
  thread_ret1 = __reap_thread_fn(data);
133
136
  return NULL;
134
137
  }
@@ -137,7 +140,8 @@ void *reap_thread_fn1(void *data) {
137
140
  * This is to test issuing a sqe in main thread and reaping it in two child-thread
138
141
  * at the same time. To see if timeout feature works or not.
139
142
  */
140
- int test_multi_threads_timeout() {
143
+ static int test_multi_threads_timeout(void)
144
+ {
141
145
  struct io_uring ring;
142
146
  int ret;
143
147
  bool both_wait = false;
@@ -176,7 +176,7 @@ static int test_single_timeout_nr(struct io_uring *ring, int nr)
176
176
  goto err;
177
177
  }
178
178
  i++;
179
- };
179
+ }
180
180
 
181
181
  return 0;
182
182
  err:
@@ -1303,7 +1303,6 @@ static int test_not_failing_links(void)
1303
1303
  fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
1304
1304
  return 1;
1305
1305
  } else if (cqe->user_data == 1 && cqe->res == -EINVAL) {
1306
- fprintf(stderr, "ETIME_SUCCESS is not supported, skip\n");
1307
1306
  goto done;
1308
1307
  } else if (cqe->res != -ETIME || cqe->user_data != 1) {
1309
1308
  fprintf(stderr, "timeout failed %i %i\n", cqe->res,
@@ -1,6 +1,6 @@
1
1
  /* SPDX-License-Identifier: MIT */
2
2
  /*
3
- * Description: run various nop tests
3
+ * Description: run various unlink tests
4
4
  *
5
5
  */
6
6
  #include <errno.h>
@@ -0,0 +1,25 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Description: check version macros and runtime checks work
4
+ *
5
+ */
6
+ #include "liburing.h"
7
+ #include "helpers.h"
8
+
9
+ int main(int argc, char *argv[])
10
+ {
11
+ if (!IO_URING_CHECK_VERSION(io_uring_major_version(), io_uring_minor_version()))
12
+ return T_EXIT_FAIL;
13
+
14
+ if (io_uring_major_version() != IO_URING_VERSION_MAJOR)
15
+ return T_EXIT_FAIL;
16
+
17
+ if (io_uring_minor_version() != IO_URING_VERSION_MINOR)
18
+ return T_EXIT_FAIL;
19
+
20
+ #if !IO_URING_CHECK_VERSION(IO_URING_VERSION_MAJOR, IO_URING_VERSION_MINOR)
21
+ return T_EXIT_FAIL;
22
+ #endif
23
+
24
+ return T_EXIT_PASS;
25
+ }
@@ -5,10 +5,10 @@
5
5
  #include <stdlib.h>
6
6
  #include <string.h>
7
7
  #include <pthread.h>
8
- #include <liburing.h>
9
8
  #include <fcntl.h>
10
9
  #include <poll.h>
11
10
  #include <sys/time.h>
11
+ #include "liburing.h"
12
12
 
13
13
  struct thread_data {
14
14
  struct io_uring *ring;
@@ -51,10 +51,11 @@ static int io_uring_fsetxattr(struct io_uring *ring, int fd, const char *name,
51
51
  }
52
52
 
53
53
  ret = cqe->res;
54
- if (ret == -EINVAL)
55
- no_xattr = 1;
54
+ if (ret < 0) {
55
+ if (cqe->res == -EINVAL || cqe->res == -EOPNOTSUPP)
56
+ no_xattr = 1;
57
+ }
56
58
  io_uring_cqe_seen(ring, cqe);
57
-
58
59
  return ret;
59
60
  }
60
61
 
@@ -126,8 +127,11 @@ static int io_uring_setxattr(struct io_uring *ring, const char *path,
126
127
  }
127
128
 
128
129
  ret = cqe->res;
130
+ if (ret < 0) {
131
+ if (ret == -EINVAL || ret == -EOPNOTSUPP)
132
+ no_xattr = 1;
133
+ }
129
134
  io_uring_cqe_seen(ring, cqe);
130
-
131
135
  return ret;
132
136
  }
133
137