polyphony 0.98 → 0.99.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 (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
@@ -42,6 +42,8 @@ int main(int argc, char *argv[])
42
42
  sprintf(buf, "./XXXXXX");
43
43
  fd = mkostemp(buf, O_WRONLY | O_DIRECT | O_CREAT);
44
44
  if (fd < 0) {
45
+ if (errno == EINVAL)
46
+ return T_EXIT_SKIP;
45
47
  perror("mkostemp");
46
48
  return T_EXIT_FAIL;
47
49
  }
@@ -19,7 +19,7 @@ int main(int argc, char *argv[])
19
19
  if (argc > 1)
20
20
  return T_EXIT_SKIP;
21
21
 
22
- mmap((void *) 0x20000000, 0x1000000, 3, 0x32, -1, 0);
22
+ mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0);
23
23
 
24
24
  *(uint32_t*)0x20000000 = 0;
25
25
  *(uint32_t*)0x20000004 = 0;
@@ -13,7 +13,8 @@ override CPPFLAGS += \
13
13
  -D_GNU_SOURCE \
14
14
  -D__SANE_USERSPACE_TYPES__ \
15
15
  -I../src/include/ \
16
- -include ../config-host.h
16
+ -include ../config-host.h \
17
+ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
17
18
 
18
19
  CFLAGS ?= -g -O3 -Wall -Wextra
19
20
  XCFLAGS = -Wno-unused-parameter -Wno-sign-compare
@@ -67,10 +68,12 @@ test_srcs := \
67
68
  drop-submit.c \
68
69
  eeed8b54e0df.c \
69
70
  empty-eownerdead.c \
71
+ eploop.c \
70
72
  eventfd.c \
71
73
  eventfd-disable.c \
72
74
  eventfd-reg.c \
73
75
  eventfd-ring.c \
76
+ evloop.c \
74
77
  exec-target.c \
75
78
  exit-no-cleanup.c \
76
79
  fadvise.c \
@@ -86,11 +89,13 @@ test_srcs := \
86
89
  fixed-link.c \
87
90
  fixed-reuse.c \
88
91
  fpos.c \
92
+ fsnotify.c \
89
93
  fsync.c \
90
94
  hardlink.c \
91
95
  io-cancel.c \
92
96
  iopoll.c \
93
97
  iopoll-leak.c \
98
+ iopoll-overflow.c \
94
99
  io_uring_enter.c \
95
100
  io_uring_passthrough.c \
96
101
  io_uring_register.c \
@@ -103,6 +108,8 @@ test_srcs := \
103
108
  madvise.c \
104
109
  mkdir.c \
105
110
  msg-ring.c \
111
+ msg-ring-flags.c \
112
+ msg-ring-overflow.c \
106
113
  multicqes_drain.c \
107
114
  nolibc.c \
108
115
  nop-all-sizes.c \
@@ -112,6 +119,7 @@ test_srcs := \
112
119
  open-direct-link.c \
113
120
  open-direct-pick.c \
114
121
  personality.c \
122
+ pipe-bug.c \
115
123
  pipe-eof.c \
116
124
  pipe-reuse.c \
117
125
  poll.c \
@@ -120,8 +128,10 @@ test_srcs := \
120
128
  poll-cancel-ton.c \
121
129
  poll-link.c \
122
130
  poll-many.c \
123
- poll-mshot-update.c \
124
131
  poll-mshot-overflow.c \
132
+ poll-mshot-update.c \
133
+ poll-race.c \
134
+ poll-race-mshot.c \
125
135
  poll-ring.c \
126
136
  poll-v-poll.c \
127
137
  pollfree.c \
@@ -131,6 +141,7 @@ test_srcs := \
131
141
  recv-msgall.c \
132
142
  recv-msgall-stream.c \
133
143
  recv-multishot.c \
144
+ reg-reg-ring.c \
134
145
  register-restrictions.c \
135
146
  rename.c \
136
147
  ringbuf-read.c \
@@ -142,10 +153,12 @@ test_srcs := \
142
153
  sendmsg_fs_cve.c \
143
154
  send_recv.c \
144
155
  send_recvmsg.c \
156
+ send-zerocopy.c \
145
157
  shared-wq.c \
146
158
  short-read.c \
147
159
  shutdown.c \
148
160
  sigfd-deadlock.c \
161
+ single-issuer.c \
149
162
  skip-cqe.c \
150
163
  socket.c \
151
164
  socket-rw.c \
@@ -166,8 +179,8 @@ test_srcs := \
166
179
  submit-and-wait.c \
167
180
  submit-link-fail.c \
168
181
  submit-reuse.c \
169
- sync-cancel.c \
170
182
  symlink.c \
183
+ sync-cancel.c \
171
184
  teardowns.c \
172
185
  thread-exit.c \
173
186
  timeout.c \
@@ -175,11 +188,9 @@ test_srcs := \
175
188
  timeout-overflow.c \
176
189
  tty-write-dpoll.c \
177
190
  unlink.c \
191
+ version.c \
178
192
  wakeup-hang.c \
179
193
  xattr.c \
180
- skip-cqe.c \
181
- single-issuer.c \
182
- send-zerocopy.c \
183
194
  # EOL
184
195
 
185
196
  all_targets :=
@@ -213,8 +224,17 @@ helpers.o: helpers.c
213
224
  %.t: %.c $(helpers) helpers.h ../src/liburing.a
214
225
  $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
215
226
 
227
+ #
228
+ # Clang++ is not happy with -Wmissing-prototypes:
229
+ #
230
+ # cc1plus: warning: command-line option '-Wmissing-prototypes' \
231
+ # is valid for C/ObjC but not for C++
232
+ #
216
233
  %.t: %.cc $(helpers) helpers.h ../src/liburing.a
217
- $(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
234
+ $(QUIET_CXX)$(CXX) \
235
+ $(patsubst -Wmissing-prototypes,,$(CPPFLAGS)) \
236
+ $(patsubst -Wmissing-prototypes,,$(CXXFLAGS)) \
237
+ -o $@ $< $(helpers) $(LDFLAGS)
218
238
 
219
239
 
220
240
  install: $(test_targets) runtests.sh runtests-loop.sh
@@ -14,13 +14,13 @@
14
14
  #include "helpers.h"
15
15
  #include "../src/syscall.h"
16
16
 
17
- uint64_t r[1] = {0xffffffffffffffff};
17
+ static uint64_t r[1] = {0xffffffffffffffff};
18
18
 
19
19
  int main(int argc, char *argv[])
20
20
  {
21
21
  if (argc > 1)
22
22
  return T_EXIT_SKIP;
23
- mmap((void *) 0x20000000, 0x1000000, 3, 0x32, -1, 0);
23
+ mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0);
24
24
  intptr_t res = 0;
25
25
  *(uint32_t*)0x20000080 = 0;
26
26
  *(uint32_t*)0x20000084 = 0;
@@ -95,7 +95,7 @@ static void kill_and_wait(int pid, int* status)
95
95
  }
96
96
  }
97
97
 
98
- static void setup_test()
98
+ static void setup_test(void)
99
99
  {
100
100
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
101
101
  setpgrp();
@@ -175,7 +175,7 @@ int main(int argc, char *argv[])
175
175
  if (argc > 1)
176
176
  return T_EXIT_SKIP;
177
177
  signal(SIGINT, sig_int);
178
- mmap((void *) 0x20000000, 0x1000000, 3, 0x32, -1, 0);
178
+ mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0);
179
179
  loop();
180
180
  return T_EXIT_PASS;
181
181
  }
@@ -16,8 +16,8 @@
16
16
  #include "liburing.h"
17
17
  #include "helpers.h"
18
18
 
19
- pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
20
- pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
19
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
20
+ static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
21
21
 
22
22
  static int recv_thread_ready = 0;
23
23
  static int recv_thread_done = 0;
@@ -77,7 +77,7 @@ static void *send_thread(void *arg)
77
77
  return NULL;
78
78
  }
79
79
 
80
- void *recv_thread(void *arg)
80
+ static void *recv_thread(void *arg)
81
81
  {
82
82
  struct data *data = arg;
83
83
  struct io_uring ring;
@@ -195,7 +195,7 @@ static int test_accept_timeout(int do_connect, unsigned long timeout)
195
195
  if (ret) {
196
196
  fprintf(stderr, "queue_init: %d\n", ret);
197
197
  return 1;
198
- };
198
+ }
199
199
 
200
200
  fast_poll = (p.features & IORING_FEAT_FAST_POLL) != 0;
201
201
  io_uring_queue_exit(&ring);
@@ -1,5 +1,4 @@
1
1
  /* SPDX-License-Identifier: MIT */
2
- #include <liburing.h>
3
2
  #include <netdb.h>
4
3
  #include <string.h>
5
4
  #include <sys/socket.h>
@@ -11,17 +10,16 @@
11
10
  #include "helpers.h"
12
11
  #include "../src/syscall.h"
13
12
 
14
- struct io_uring io_uring;
13
+ static struct io_uring io_uring;
15
14
 
16
- int sys_io_uring_enter(const int fd,
17
- const unsigned to_submit,
18
- const unsigned min_complete,
19
- const unsigned flags, sigset_t * const sig)
15
+ static int sys_io_uring_enter(const int fd, const unsigned to_submit,
16
+ const unsigned min_complete,
17
+ const unsigned flags, sigset_t * const sig)
20
18
  {
21
19
  return __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
22
20
  }
23
21
 
24
- int submit_sqe(void)
22
+ static int submit_sqe(void)
25
23
  {
26
24
  struct io_uring_sq *sq = &io_uring.sq;
27
25
  const unsigned tail = *sq->ktail;
@@ -272,6 +272,7 @@ static int test_loop(struct io_uring *ring,
272
272
  uint32_t multishot_mask = 0;
273
273
  int nr_fds = multishot ? MAX_FDS : 1;
274
274
  int multishot_idx = multishot ? INITIAL_USER_DATA : 0;
275
+ int err_ret = T_EXIT_FAIL;
275
276
 
276
277
  if (args.overflow)
277
278
  cause_overflow(ring);
@@ -298,6 +299,7 @@ static int test_loop(struct io_uring *ring,
298
299
  no_accept_multi = 1;
299
300
  else
300
301
  no_accept = 1;
302
+ ret = T_EXIT_SKIP;
301
303
  goto out;
302
304
  } else if (s_fd[i] < 0) {
303
305
  if (args.accept_should_error &&
@@ -360,10 +362,10 @@ static int test_loop(struct io_uring *ring,
360
362
 
361
363
  out:
362
364
  close_sock_fds(s_fd, c_fd, nr_fds, fixed);
363
- return 0;
365
+ return T_EXIT_PASS;
364
366
  err:
365
367
  close_sock_fds(s_fd, c_fd, nr_fds, fixed);
366
- return 1;
368
+ return err_ret;
367
369
  }
368
370
 
369
371
  static int test(struct io_uring *ring, struct accept_test_args args)
@@ -372,7 +374,7 @@ static int test(struct io_uring *ring, struct accept_test_args args)
372
374
  int ret = 0;
373
375
  int loop;
374
376
  int32_t recv_s0 = start_accept_listen(&addr, 0,
375
- args.nonblock ? O_NONBLOCK : 0);
377
+ args.nonblock ? SOCK_NONBLOCK : 0);
376
378
  if (args.queue_accept_before_connect)
377
379
  queue_accept_conn(ring, recv_s0, args);
378
380
  for (loop = 0; loop < 1 + args.extra_loops; loop++) {
@@ -458,7 +460,7 @@ static int test_accept_many(struct test_accept_many_args args)
458
460
 
459
461
  for (i = 0; i < nr_socks; i++)
460
462
  fds[i] = start_accept_listen(NULL, i,
461
- args.nonblock ? O_NONBLOCK : 0);
463
+ args.nonblock ? SOCK_NONBLOCK : 0);
462
464
 
463
465
  for (i = 0; i < nr; i++) {
464
466
  int sock_idx = args.single_sock ? 0 : i;
@@ -611,7 +613,7 @@ static int test_multishot_accept(int count, bool before, bool overflow)
611
613
  return ret;
612
614
  }
613
615
 
614
- static int test_accept_multishot_wrong_arg()
616
+ static int test_accept_multishot_wrong_arg(void)
615
617
  {
616
618
  struct io_uring m_io_uring;
617
619
  struct io_uring_cqe *cqe;
@@ -733,8 +735,9 @@ int main(int argc, char *argv[])
733
735
 
734
736
  if (argc > 1)
735
737
  return T_EXIT_SKIP;
738
+
736
739
  ret = test_accept(1, false);
737
- if (ret) {
740
+ if (ret == T_EXIT_FAIL) {
738
741
  fprintf(stderr, "test_accept failed\n");
739
742
  return ret;
740
743
  }
@@ -742,141 +745,141 @@ int main(int argc, char *argv[])
742
745
  return T_EXIT_SKIP;
743
746
 
744
747
  ret = test_accept(2, false);
745
- if (ret) {
748
+ if (ret == T_EXIT_FAIL) {
746
749
  fprintf(stderr, "test_accept(2) failed\n");
747
750
  return ret;
748
751
  }
749
752
 
750
753
  ret = test_accept(2, true);
751
- if (ret) {
754
+ if (ret == T_EXIT_FAIL) {
752
755
  fprintf(stderr, "test_accept(2, true) failed\n");
753
756
  return ret;
754
757
  }
755
758
 
756
759
  ret = test_accept_nonblock(false, 1);
757
- if (ret) {
760
+ if (ret == T_EXIT_FAIL) {
758
761
  fprintf(stderr, "test_accept_nonblock failed\n");
759
762
  return ret;
760
763
  }
761
764
 
762
765
  ret = test_accept_nonblock(true, 1);
763
- if (ret) {
766
+ if (ret == T_EXIT_FAIL) {
764
767
  fprintf(stderr, "test_accept_nonblock(before, 1) failed\n");
765
768
  return ret;
766
769
  }
767
770
 
768
771
  ret = test_accept_nonblock(true, 3);
769
- if (ret) {
772
+ if (ret == T_EXIT_FAIL) {
770
773
  fprintf(stderr, "test_accept_nonblock(before,3) failed\n");
771
774
  return ret;
772
775
  }
773
776
 
774
777
  ret = test_accept_fixed();
775
- if (ret) {
778
+ if (ret == T_EXIT_FAIL) {
776
779
  fprintf(stderr, "test_accept_fixed failed\n");
777
780
  return ret;
778
781
  }
779
782
 
780
783
  ret = test_multishot_fixed_accept();
781
- if (ret) {
784
+ if (ret == T_EXIT_FAIL) {
782
785
  fprintf(stderr, "test_multishot_fixed_accept failed\n");
783
786
  return ret;
784
787
  }
785
788
 
786
789
  ret = test_accept_multishot_wrong_arg();
787
- if (ret) {
790
+ if (ret == T_EXIT_FAIL) {
788
791
  fprintf(stderr, "test_accept_multishot_wrong_arg failed\n");
789
792
  return ret;
790
793
  }
791
794
 
792
795
  ret = test_accept_sqpoll();
793
- if (ret) {
796
+ if (ret == T_EXIT_FAIL) {
794
797
  fprintf(stderr, "test_accept_sqpoll failed\n");
795
798
  return ret;
796
799
  }
797
800
 
798
801
  ret = test_accept_cancel(0, 1, false);
799
- if (ret) {
802
+ if (ret == T_EXIT_FAIL) {
800
803
  fprintf(stderr, "test_accept_cancel nodelay failed\n");
801
804
  return ret;
802
805
  }
803
806
 
804
807
  ret = test_accept_cancel(10000, 1, false);
805
- if (ret) {
808
+ if (ret == T_EXIT_FAIL) {
806
809
  fprintf(stderr, "test_accept_cancel delay failed\n");
807
810
  return ret;
808
811
  }
809
812
 
810
813
  ret = test_accept_cancel(0, 4, false);
811
- if (ret) {
814
+ if (ret == T_EXIT_FAIL) {
812
815
  fprintf(stderr, "test_accept_cancel nodelay failed\n");
813
816
  return ret;
814
817
  }
815
818
 
816
819
  ret = test_accept_cancel(10000, 4, false);
817
- if (ret) {
820
+ if (ret == T_EXIT_FAIL) {
818
821
  fprintf(stderr, "test_accept_cancel delay failed\n");
819
822
  return ret;
820
823
  }
821
824
 
822
825
  ret = test_accept_cancel(0, 1, true);
823
- if (ret) {
826
+ if (ret == T_EXIT_FAIL) {
824
827
  fprintf(stderr, "test_accept_cancel multishot nodelay failed\n");
825
828
  return ret;
826
829
  }
827
830
 
828
831
  ret = test_accept_cancel(10000, 1, true);
829
- if (ret) {
832
+ if (ret == T_EXIT_FAIL) {
830
833
  fprintf(stderr, "test_accept_cancel multishot delay failed\n");
831
834
  return ret;
832
835
  }
833
836
 
834
837
  ret = test_accept_cancel(0, 4, true);
835
- if (ret) {
838
+ if (ret == T_EXIT_FAIL) {
836
839
  fprintf(stderr, "test_accept_cancel multishot nodelay failed\n");
837
840
  return ret;
838
841
  }
839
842
 
840
843
  ret = test_accept_cancel(10000, 4, true);
841
- if (ret) {
844
+ if (ret == T_EXIT_FAIL) {
842
845
  fprintf(stderr, "test_accept_cancel multishot delay failed\n");
843
846
  return ret;
844
847
  }
845
848
 
846
849
  ret = test_multishot_accept(1, true, true);
847
- if (ret) {
850
+ if (ret == T_EXIT_FAIL) {
848
851
  fprintf(stderr, "test_multishot_accept(1, false, true) failed\n");
849
852
  return ret;
850
853
  }
851
854
 
852
855
  ret = test_multishot_accept(1, false, false);
853
- if (ret) {
856
+ if (ret == T_EXIT_FAIL) {
854
857
  fprintf(stderr, "test_multishot_accept(1, false, false) failed\n");
855
858
  return ret;
856
859
  }
857
860
 
858
861
  ret = test_multishot_accept(1, true, false);
859
- if (ret) {
862
+ if (ret == T_EXIT_FAIL) {
860
863
  fprintf(stderr, "test_multishot_accept(1, true, false) failed\n");
861
864
  return ret;
862
865
  }
863
866
 
864
867
  ret = test_accept_many((struct test_accept_many_args) {});
865
- if (ret) {
868
+ if (ret == T_EXIT_FAIL) {
866
869
  fprintf(stderr, "test_accept_many failed\n");
867
870
  return ret;
868
871
  }
869
872
 
870
873
  ret = test_accept_many((struct test_accept_many_args) {
871
874
  .usecs = 100000 });
872
- if (ret) {
875
+ if (ret == T_EXIT_FAIL) {
873
876
  fprintf(stderr, "test_accept_many(sleep) failed\n");
874
877
  return ret;
875
878
  }
876
879
 
877
880
  ret = test_accept_many((struct test_accept_many_args) {
878
881
  .nonblock = true });
879
- if (ret) {
882
+ if (ret == T_EXIT_FAIL) {
880
883
  fprintf(stderr, "test_accept_many(nonblock) failed\n");
881
884
  return ret;
882
885
  }
@@ -885,13 +888,13 @@ int main(int argc, char *argv[])
885
888
  .nonblock = true,
886
889
  .single_sock = true,
887
890
  .close_fds = true });
888
- if (ret) {
891
+ if (ret == T_EXIT_FAIL) {
889
892
  fprintf(stderr, "test_accept_many(nonblock,close) failed\n");
890
893
  return ret;
891
894
  }
892
895
 
893
896
  ret = test_accept_pending_on_exit();
894
- if (ret) {
897
+ if (ret == T_EXIT_FAIL) {
895
898
  fprintf(stderr, "test_accept_pending_on_exit failed\n");
896
899
  return ret;
897
900
  }
@@ -19,7 +19,7 @@ int main(int argc, char *argv[])
19
19
  if (argc > 1)
20
20
  return T_EXIT_SKIP;
21
21
 
22
- mmap((void *) 0x20000000, 0x1000000, 3, 0x32, -1, 0);
22
+ mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0);
23
23
 
24
24
  *(uint32_t*)0x20000200 = 0;
25
25
  *(uint32_t*)0x20000204 = 0;
@@ -9,11 +9,13 @@
9
9
  #include <stdlib.h>
10
10
  #include <string.h>
11
11
  #include <fcntl.h>
12
+ #include <sys/mman.h>
12
13
 
13
14
  #include "liburing.h"
14
15
  #include "helpers.h"
15
16
 
16
17
  static int no_buf_ring;
18
+ static int pagesize;
17
19
 
18
20
  /* test trying to register classic group when ring group exists */
19
21
  static int test_mixed_reg2(int bgid)
@@ -31,7 +33,7 @@ static int test_mixed_reg2(int bgid)
31
33
  else if (ret != T_SETUP_OK)
32
34
  return 1;
33
35
 
34
- if (posix_memalign(&ptr, 4096, 4096))
36
+ if (posix_memalign(&ptr, 4096, 32 * sizeof(struct io_uring_buf)))
35
37
  return 1;
36
38
 
37
39
  reg.ring_addr = (unsigned long) ptr;
@@ -96,7 +98,7 @@ static int test_mixed_reg(int bgid)
96
98
  }
97
99
  io_uring_cqe_seen(&ring, cqe);
98
100
 
99
- if (posix_memalign(&ptr, 4096, 4096))
101
+ if (posix_memalign(&ptr, 4096, 32 * sizeof(struct io_uring_buf)))
100
102
  return 1;
101
103
 
102
104
  reg.ring_addr = (unsigned long) ptr;
@@ -126,7 +128,7 @@ static int test_double_reg_unreg(int bgid)
126
128
  else if (ret != T_SETUP_OK)
127
129
  return 1;
128
130
 
129
- if (posix_memalign(&ptr, 4096, 4096))
131
+ if (posix_memalign(&ptr, 4096, 32 * sizeof(struct io_uring_buf)))
130
132
  return 1;
131
133
 
132
134
  reg.ring_addr = (unsigned long) ptr;
@@ -179,7 +181,7 @@ static int test_reg_unreg(int bgid)
179
181
  else if (ret != T_SETUP_OK)
180
182
  return 1;
181
183
 
182
- if (posix_memalign(&ptr, 4096, 4096))
184
+ if (posix_memalign(&ptr, 4096, 32 * sizeof(struct io_uring_buf)))
183
185
  return 1;
184
186
 
185
187
  reg.ring_addr = (unsigned long) ptr;
@@ -230,6 +232,50 @@ static int test_bad_reg(int bgid)
230
232
  return !ret;
231
233
  }
232
234
 
235
+ static int test_full_page_reg(int bgid)
236
+ {
237
+ struct io_uring ring;
238
+ int ret;
239
+ void *ptr;
240
+ struct io_uring_buf_reg reg = { };
241
+ int entries = pagesize / sizeof(struct io_uring_buf);
242
+
243
+ ret = io_uring_queue_init(1, &ring, 0);
244
+ if (ret) {
245
+ fprintf(stderr, "queue init failed %d\n", ret);
246
+ return 1;
247
+ }
248
+
249
+ ret = posix_memalign(&ptr, pagesize, pagesize * 2);
250
+ if (ret) {
251
+ fprintf(stderr, "posix_memalign failed %d\n", ret);
252
+ goto err;
253
+ }
254
+
255
+ ret = mprotect(ptr + pagesize, pagesize, PROT_NONE);
256
+ if (ret) {
257
+ fprintf(stderr, "mprotect failed %d\n", errno);
258
+ goto err1;
259
+ }
260
+
261
+ reg.ring_addr = (unsigned long) ptr;
262
+ reg.ring_entries = entries;
263
+ reg.bgid = bgid;
264
+
265
+ ret = io_uring_register_buf_ring(&ring, &reg, 0);
266
+ if (ret)
267
+ fprintf(stderr, "register buf ring failed %d\n", ret);
268
+
269
+ if (mprotect(ptr + pagesize, pagesize, PROT_READ | PROT_WRITE))
270
+ fprintf(stderr, "reverting mprotect failed %d\n", errno);
271
+
272
+ err1:
273
+ free(ptr);
274
+ err:
275
+ io_uring_queue_exit(&ring);
276
+ return ret;
277
+ }
278
+
233
279
  static int test_one_read(int fd, int bgid, struct io_uring *ring)
234
280
  {
235
281
  int ret;
@@ -374,6 +420,8 @@ int main(int argc, char *argv[])
374
420
  if (argc > 1)
375
421
  return T_EXIT_SKIP;
376
422
 
423
+ pagesize = getpagesize();
424
+
377
425
  for (i = 0; bgids[i] != -1; i++) {
378
426
  ret = test_reg_unreg(bgids[i]);
379
427
  if (ret) {
@@ -406,6 +454,12 @@ int main(int argc, char *argv[])
406
454
  fprintf(stderr, "test_mixed_reg2 failed\n");
407
455
  return T_EXIT_FAIL;
408
456
  }
457
+
458
+ ret = test_full_page_reg(bgids[i]);
459
+ if (ret) {
460
+ fprintf(stderr, "test_full_page_reg failed\n");
461
+ return T_EXIT_FAIL;
462
+ }
409
463
  }
410
464
 
411
465
  for (i = 0; !no_buf_ring && entries[i] != -1; i++) {
@@ -15,7 +15,7 @@
15
15
 
16
16
  static int use_sqpoll = 0;
17
17
 
18
- void notify_fd(int fd)
18
+ static void notify_fd(int fd)
19
19
  {
20
20
  char buf[8] = {0, 0, 0, 0, 0, 0, 1};
21
21
  int ret;
@@ -25,7 +25,7 @@ void notify_fd(int fd)
25
25
  perror("write");
26
26
  }
27
27
 
28
- void *delay_set_fd_from_thread(void *data)
28
+ static void *delay_set_fd_from_thread(void *data)
29
29
  {
30
30
  int fd = (intptr_t) data;
31
31
 
@@ -15,12 +15,13 @@
15
15
 
16
16
  #include <errno.h>
17
17
  #include <fcntl.h>
18
- #include <liburing.h>
19
18
  #include <sys/stat.h>
20
19
  #include <stdio.h>
21
20
  #include <string.h>
22
21
  #include <unistd.h>
23
22
 
23
+ #include "liburing.h"
24
+
24
25
  typedef struct
25
26
  {
26
27
  const char *const flnames;
@@ -15,6 +15,7 @@
15
15
  #include <netinet/in.h>
16
16
  #include <netinet/tcp.h>
17
17
  #include <arpa/inet.h>
18
+ #include <sys/stat.h>
18
19
 
19
20
  #include "liburing.h"
20
21
  #include "helpers.h"
@@ -256,6 +257,13 @@ static int test_connect_timeout(struct io_uring *ring)
256
257
  struct sockaddr_in addr;
257
258
  struct io_uring_sqe *sqe;
258
259
  struct __kernel_timespec ts = {.tv_sec = 0, .tv_nsec = 100000};
260
+ struct stat sb;
261
+
262
+ /*
263
+ * Test reliably fails if syncookies isn't enabled
264
+ */
265
+ if (stat("/proc/sys/net/ipv4/tcp_syncookies", &sb) < 0)
266
+ return T_EXIT_SKIP;
259
267
 
260
268
  connect_fd[0] = create_socket();
261
269
  if (connect_fd[0] == -1)