polyphony 0.98 → 0.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/examples/io/https_server_sni_2.rb +14 -8
  4. data/ext/polyphony/extconf.rb +6 -5
  5. data/ext/polyphony/libev.h +0 -2
  6. data/lib/polyphony/core/sync.rb +53 -0
  7. data/lib/polyphony/extensions/io.rb +37 -14
  8. data/lib/polyphony/extensions/openssl.rb +1 -1
  9. data/lib/polyphony/version.rb +1 -1
  10. data/test/test_io.rb +6 -7
  11. data/test/test_socket.rb +61 -0
  12. data/test/test_sync.rb +42 -1
  13. data/vendor/liburing/.github/workflows/build.yml +7 -16
  14. data/vendor/liburing/.gitignore +5 -0
  15. data/vendor/liburing/CHANGELOG +23 -1
  16. data/vendor/liburing/Makefile +4 -3
  17. data/vendor/liburing/Makefile.common +1 -0
  18. data/vendor/liburing/README +48 -0
  19. data/vendor/liburing/configure +76 -6
  20. data/vendor/liburing/debian/changelog +11 -0
  21. data/vendor/liburing/debian/control +7 -16
  22. data/vendor/liburing/debian/liburing-dev.manpages +3 -6
  23. data/vendor/liburing/debian/liburing2.install +1 -0
  24. data/vendor/liburing/debian/liburing2.symbols +56 -0
  25. data/vendor/liburing/debian/rules +15 -68
  26. data/vendor/liburing/examples/Makefile +4 -0
  27. data/vendor/liburing/examples/io_uring-close-test.c +123 -0
  28. data/vendor/liburing/examples/io_uring-udp.c +1 -1
  29. data/vendor/liburing/examples/send-zerocopy.c +315 -56
  30. data/vendor/liburing/examples/ucontext-cp.c +2 -17
  31. data/vendor/liburing/liburing-ffi.pc.in +12 -0
  32. data/vendor/liburing/liburing.pc.in +1 -1
  33. data/vendor/liburing/liburing.spec +1 -1
  34. data/vendor/liburing/make-debs.sh +3 -3
  35. data/vendor/liburing/man/IO_URING_CHECK_VERSION.3 +1 -0
  36. data/vendor/liburing/man/IO_URING_VERSION_MAJOR.3 +1 -0
  37. data/vendor/liburing/man/IO_URING_VERSION_MINOR.3 +1 -0
  38. data/vendor/liburing/man/io_uring_buf_ring_add.3 +6 -6
  39. data/vendor/liburing/man/io_uring_check_version.3 +72 -0
  40. data/vendor/liburing/man/io_uring_close_ring_fd.3 +43 -0
  41. data/vendor/liburing/man/io_uring_major_version.3 +1 -0
  42. data/vendor/liburing/man/io_uring_minor_version.3 +1 -0
  43. data/vendor/liburing/man/io_uring_prep_accept.3 +1 -1
  44. data/vendor/liburing/man/io_uring_prep_fgetxattr.3 +1 -0
  45. data/vendor/liburing/man/io_uring_prep_fsetxattr.3 +1 -0
  46. data/vendor/liburing/man/io_uring_prep_getxattr.3 +61 -0
  47. data/vendor/liburing/man/io_uring_prep_link_timeout.3 +94 -0
  48. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +22 -2
  49. data/vendor/liburing/man/io_uring_prep_msg_ring_cqe_flags.3 +1 -0
  50. data/vendor/liburing/man/io_uring_prep_poll_add.3 +1 -1
  51. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +18 -9
  52. data/vendor/liburing/man/io_uring_prep_readv.3 +3 -3
  53. data/vendor/liburing/man/io_uring_prep_readv2.3 +3 -3
  54. data/vendor/liburing/man/io_uring_prep_recv.3 +5 -5
  55. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +4 -4
  56. data/vendor/liburing/man/io_uring_prep_send.3 +9 -0
  57. data/vendor/liburing/man/io_uring_prep_send_set_addr.3 +38 -0
  58. data/vendor/liburing/man/io_uring_prep_send_zc.3 +39 -7
  59. data/vendor/liburing/man/io_uring_prep_send_zc_fixed.3 +1 -0
  60. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +20 -0
  61. data/vendor/liburing/man/io_uring_prep_sendmsg_zc.3 +1 -0
  62. data/vendor/liburing/man/io_uring_prep_setxattr.3 +64 -0
  63. data/vendor/liburing/man/io_uring_prep_splice.3 +40 -0
  64. data/vendor/liburing/man/io_uring_prep_writev.3 +2 -2
  65. data/vendor/liburing/man/io_uring_prep_writev2.3 +2 -2
  66. data/vendor/liburing/man/io_uring_recvmsg_out.3 +13 -9
  67. data/vendor/liburing/man/io_uring_register.2 +15 -9
  68. data/vendor/liburing/man/io_uring_register_buf_ring.3 +4 -4
  69. data/vendor/liburing/man/io_uring_register_buffers.3 +49 -6
  70. data/vendor/liburing/man/io_uring_register_buffers_sparse.3 +1 -0
  71. data/vendor/liburing/man/io_uring_register_buffers_tags.3 +1 -0
  72. data/vendor/liburing/man/io_uring_register_buffers_update_tag.3 +1 -0
  73. data/vendor/liburing/man/io_uring_register_files.3 +60 -5
  74. data/vendor/liburing/man/io_uring_register_files_tags.3 +1 -0
  75. data/vendor/liburing/man/io_uring_register_files_update.3 +1 -0
  76. data/vendor/liburing/man/io_uring_register_files_update_tag.3 +1 -0
  77. data/vendor/liburing/man/io_uring_setup.2 +31 -2
  78. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +1 -1
  79. data/vendor/liburing/src/Makefile +25 -3
  80. data/vendor/liburing/src/ffi.c +15 -0
  81. data/vendor/liburing/src/include/liburing/io_uring.h +30 -7
  82. data/vendor/liburing/src/include/liburing.h +190 -148
  83. data/vendor/liburing/src/int_flags.h +1 -0
  84. data/vendor/liburing/src/lib.h +5 -16
  85. data/vendor/liburing/src/liburing-ffi.map +172 -0
  86. data/vendor/liburing/src/liburing.map +11 -0
  87. data/vendor/liburing/src/nolibc.c +9 -2
  88. data/vendor/liburing/src/queue.c +2 -2
  89. data/vendor/liburing/src/register.c +66 -96
  90. data/vendor/liburing/src/setup.c +5 -4
  91. data/vendor/liburing/src/version.c +21 -0
  92. data/vendor/liburing/test/232c93d07b74.c +3 -3
  93. data/vendor/liburing/test/35fa71a030ca.c +3 -3
  94. data/vendor/liburing/test/500f9fbadef8.c +2 -0
  95. data/vendor/liburing/test/917257daa0fe.c +1 -1
  96. data/vendor/liburing/test/Makefile +27 -7
  97. data/vendor/liburing/test/a0908ae19763.c +2 -2
  98. data/vendor/liburing/test/a4c0b3decb33.c +2 -2
  99. data/vendor/liburing/test/accept-link.c +4 -4
  100. data/vendor/liburing/test/accept-reuse.c +5 -7
  101. data/vendor/liburing/test/accept.c +34 -31
  102. data/vendor/liburing/test/b19062a56726.c +1 -1
  103. data/vendor/liburing/test/buf-ring.c +58 -4
  104. data/vendor/liburing/test/ce593a6c480a.c +2 -2
  105. data/vendor/liburing/test/close-opath.c +2 -1
  106. data/vendor/liburing/test/connect.c +8 -0
  107. data/vendor/liburing/test/cq-overflow.c +14 -8
  108. data/vendor/liburing/test/d4ae271dfaae.c +1 -1
  109. data/vendor/liburing/test/defer-taskrun.c +64 -9
  110. data/vendor/liburing/test/defer.c +1 -1
  111. data/vendor/liburing/test/double-poll-crash.c +3 -3
  112. data/vendor/liburing/test/eeed8b54e0df.c +8 -3
  113. data/vendor/liburing/test/eploop.c +74 -0
  114. data/vendor/liburing/test/eventfd-ring.c +1 -1
  115. data/vendor/liburing/test/eventfd.c +1 -1
  116. data/vendor/liburing/test/evloop.c +73 -0
  117. data/vendor/liburing/test/exit-no-cleanup.c +1 -1
  118. data/vendor/liburing/test/fadvise.c +1 -1
  119. data/vendor/liburing/test/fc2a85cb02ef.c +3 -3
  120. data/vendor/liburing/test/fd-pass.c +35 -16
  121. data/vendor/liburing/test/file-register.c +61 -0
  122. data/vendor/liburing/test/file-verify.c +2 -2
  123. data/vendor/liburing/test/files-exit-hang-timeout.c +2 -2
  124. data/vendor/liburing/test/fixed-link.c +1 -1
  125. data/vendor/liburing/test/fsnotify.c +118 -0
  126. data/vendor/liburing/test/hardlink.c +1 -1
  127. data/vendor/liburing/test/helpers.c +54 -2
  128. data/vendor/liburing/test/helpers.h +4 -0
  129. data/vendor/liburing/test/io-cancel.c +3 -1
  130. data/vendor/liburing/test/io_uring_passthrough.c +39 -8
  131. data/vendor/liburing/test/io_uring_setup.c +3 -80
  132. data/vendor/liburing/test/iopoll-overflow.c +118 -0
  133. data/vendor/liburing/test/iopoll.c +90 -4
  134. data/vendor/liburing/test/lfs-openat-write.c +7 -9
  135. data/vendor/liburing/test/lfs-openat.c +6 -8
  136. data/vendor/liburing/test/link_drain.c +31 -5
  137. data/vendor/liburing/test/madvise.c +1 -1
  138. data/vendor/liburing/test/msg-ring-flags.c +192 -0
  139. data/vendor/liburing/test/msg-ring-overflow.c +159 -0
  140. data/vendor/liburing/test/msg-ring.c +173 -13
  141. data/vendor/liburing/test/multicqes_drain.c +22 -19
  142. data/vendor/liburing/test/nvme.h +4 -3
  143. data/vendor/liburing/test/pipe-bug.c +95 -0
  144. data/vendor/liburing/test/poll-link.c +3 -3
  145. data/vendor/liburing/test/poll-many.c +41 -19
  146. data/vendor/liburing/test/poll-mshot-overflow.c +105 -2
  147. data/vendor/liburing/test/poll-race-mshot.c +292 -0
  148. data/vendor/liburing/test/poll-race.c +105 -0
  149. data/vendor/liburing/test/poll.c +244 -26
  150. data/vendor/liburing/test/pollfree.c +5 -5
  151. data/vendor/liburing/test/read-before-exit.c +20 -3
  152. data/vendor/liburing/test/read-write.c +2 -0
  153. data/vendor/liburing/test/recv-multishot.c +96 -3
  154. data/vendor/liburing/test/reg-reg-ring.c +90 -0
  155. data/vendor/liburing/test/rename.c +1 -1
  156. data/vendor/liburing/test/ring-leak.c +0 -1
  157. data/vendor/liburing/test/ring-leak2.c +1 -1
  158. data/vendor/liburing/test/ringbuf-read.c +10 -6
  159. data/vendor/liburing/test/send-zerocopy.c +273 -103
  160. data/vendor/liburing/test/send_recv.c +7 -4
  161. data/vendor/liburing/test/sendmsg_fs_cve.c +2 -2
  162. data/vendor/liburing/test/single-issuer.c +7 -9
  163. data/vendor/liburing/test/skip-cqe.c +3 -4
  164. data/vendor/liburing/test/socket.c +0 -1
  165. data/vendor/liburing/test/sq-poll-dup.c +10 -3
  166. data/vendor/liburing/test/sq-poll-kthread.c +1 -1
  167. data/vendor/liburing/test/sq-poll-share.c +3 -2
  168. data/vendor/liburing/test/sqpoll-cancel-hang.c +17 -6
  169. data/vendor/liburing/test/sqpoll-disable-exit.c +4 -4
  170. data/vendor/liburing/test/symlink.c +2 -1
  171. data/vendor/liburing/test/test.h +2 -1
  172. data/vendor/liburing/test/timeout-new.c +11 -7
  173. data/vendor/liburing/test/timeout.c +1 -2
  174. data/vendor/liburing/test/unlink.c +1 -1
  175. data/vendor/liburing/test/version.c +25 -0
  176. data/vendor/liburing/test/wakeup-hang.c +1 -1
  177. data/vendor/liburing/test/xattr.c +8 -4
  178. metadata +42 -6
  179. data/vendor/liburing/debian/compat +0 -1
  180. data/vendor/liburing/debian/liburing1-udeb.install +0 -1
  181. data/vendor/liburing/debian/liburing1.install +0 -1
  182. data/vendor/liburing/debian/liburing1.symbols +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf93e3d5dfd0a5e3a4a70ee66d62caddc1ea22e63cf1ce44a212a75f18c2ac76
4
- data.tar.gz: 121f84bb920ccc6822cb43b772a68dd92b2f2d81ebf9e1a510c081481dd1e3b1
3
+ metadata.gz: 4696bb7b13f68b379c29d5c38257e57c13aefd299f88727107e2f0f0a3c7d360
4
+ data.tar.gz: 94a3eeb8575d0d5fe6f143ab41351024b50c4c4cf919edec6c8155d9ead2831e
5
5
  SHA512:
6
- metadata.gz: 286d3cb30ecd19b8f046fe43761f6d2f243f3e3a8134d01ebe14fdfdf11d6d879000f51ba66c705b0ad425e3c6a51dff02781b47e8cf75e52bc4f0439dfffc0e
7
- data.tar.gz: 7caf9e3b7294ece38c964dc0366011b07d8977f95ec8c92a22763b9ecccc33080de40b5ab19bb66223eb4bb27be0847c92879a173dceee1b3fda9e1b03b0cdcd
6
+ metadata.gz: 9e1798e18b0e7a35104009d6f480191f5ed5efd7dee69189d443cb57ab8ca2f8fd75105234cd60f52ecea2348a8c3d85f152aa869374ea8dfbab8895a2015b04
7
+ data.tar.gz: 835b2be245f60b04d5b750bcce6e679b11c671e31c3d0269aeafaa961c52c501193f67cf00f4f7cc5570cab499105d025863189767db8ae79f961a62d903b173
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.99 2023-03-09
2
+
3
+ - Add missing Mutex API methods (#76)
4
+ - Fix `IO.foreach` and `IO#each_line` (#74)
5
+ - Fix `SSLServer#accept_loop` (#59)
6
+ - Update liburing
7
+
1
8
  ## 0.98 2023-03-08
2
9
 
3
10
  - Add basic support for UDP sockets
@@ -27,15 +27,21 @@ server = Polyphony::Net.tcp_listen('localhost', 1234, opts)
27
27
 
28
28
  puts 'Serving HTTPS on port 1234'
29
29
 
30
- # server.accept_loop do |socket|
31
- server.accept_loop do |socket|
32
- # while (socket = (server.accept)
33
- spin do
34
- while (data = socket.gets("\n", 8192))
35
- if data.chomp.empty?
36
- socket << "HTTP/1.1 200 OK\nConnection: close\nContent-Length: 4\n\nfoo\n"
37
- break
30
+ begin
31
+ server.accept_loop(false) do |socket|
32
+ spin do
33
+ while (data = socket.gets("\n", 8192))
34
+ if data.chomp.empty?
35
+ socket << "HTTP/1.1 200 OK\nConnection: close\nContent-Length: 4\n\nfoo\n"
36
+ break
37
+ end
38
38
  end
39
+ rescue OpenSSL::SSL::SSLError
40
+ # ignore
39
41
  end
40
42
  end
43
+ rescue => e
44
+ puts '*' * 40
45
+ p e
46
+ puts e.backtrace.join("\n")
41
47
  end
@@ -55,16 +55,17 @@ if config[:io_uring]
55
55
  else
56
56
  $defs << "-DPOLYPHONY_BACKEND_LIBEV"
57
57
  $defs << "-DPOLYPHONY_LINUX" if config[:linux]
58
- $defs << '-DEV_USE_LINUXAIO' if have_header('linux/aio_abi.h')
59
- $defs << '-DEV_USE_SELECT' if have_header('sys/select.h')
60
- $defs << '-DEV_USE_POLL' if have_type('port_event_t', 'poll.h')
58
+
59
+ $defs << "-DEV_STANDALONE" # prevent libev from assuming "config.h" exists
61
60
  $defs << '-DEV_USE_EPOLL' if have_header('sys/epoll.h')
62
61
  $defs << '-DEV_USE_KQUEUE' if have_header('sys/event.h') && have_header('sys/queue.h')
62
+ $defs << '-DEV_USE_LINUXAIO' if have_header('linux/aio_abi.h')
63
+ $defs << '-DEV_USE_POLL' if have_type('port_event_t', 'poll.h')
63
64
  $defs << '-DEV_USE_PORT' if have_type('port_event_t', 'port.h')
65
+ $defs << '-DEV_USE_SELECT' if have_header('sys/select.h')
66
+
64
67
  $defs << '-DHAVE_SYS_RESOURCE_H' if have_header('sys/resource.h')
65
68
 
66
- $defs << "-DEV_STANDALONE" # prevent libev from assuming "config.h" exists
67
-
68
69
  $CFLAGS << " -Wno-comment"
69
70
  $CFLAGS << " -Wno-unused-result"
70
71
  $CFLAGS << " -Wno-dangling-else"
@@ -1,5 +1,3 @@
1
- #define EV_STANDALONE
2
-
3
1
  #ifdef POLYPHONY_BACKEND_LIBEV
4
2
 
5
3
  /* keeps ev from requiring config.h */
@@ -58,6 +58,58 @@ module Polyphony
58
58
  @holding_fiber
59
59
  end
60
60
 
61
+ # Obtains a lock. Raises `ThreadError` if mutex is locked by the current
62
+ # thread.
63
+ #
64
+ # @return [Mutex] self
65
+ def lock
66
+ raise ThreadError if owned?
67
+
68
+ @token = @store.shift
69
+ @holding_fiber = Fiber.current
70
+ self
71
+ end
72
+
73
+ # Releases the lock. Raises `ThreadError` if mutex is not locked by the
74
+ # current thread.
75
+ #
76
+ # @return [Mutex] self
77
+ def unlock
78
+ raise ThreadError if !owned?
79
+
80
+ @holding_fiber = nil
81
+ @store << @token if @token
82
+ @token = nil
83
+ end
84
+
85
+ # Attempts to obtain the lock and returns immediately. Returns `true` if the
86
+ # lock was granted.
87
+ #
88
+ # @return [true, false]
89
+ def try_lock
90
+ return false if @holding_fiber
91
+
92
+ @token = @store.shift
93
+ @holding_fiber = Fiber.current
94
+ true
95
+ end
96
+
97
+ # Releases the lock and sleeps timeout seconds if it is given and non-nil or
98
+ # forever. Raises `ThreadError` if mutex wasn’t locked by the current
99
+ # thread.
100
+ #
101
+ # @param timeout [nil, Number] sleep timeout
102
+ # @return [Number] slept time in seconds
103
+ def sleep(timeout = nil)
104
+ unlock
105
+ t0 = Time.now
106
+ Kernel.sleep(timeout)
107
+ t1 = Time.now
108
+ lock
109
+
110
+ return t1 - t0
111
+ end
112
+
61
113
  private
62
114
 
63
115
  # Helper method for performing a `#synchronize` when not currently holding
@@ -72,6 +124,7 @@ module Polyphony
72
124
  ensure
73
125
  @holding_fiber = nil
74
126
  @store << @token if @token
127
+ @token = nil
75
128
  end
76
129
  end
77
130
  end
@@ -25,20 +25,19 @@ class ::IO
25
25
 
26
26
  EMPTY_HASH = {}.freeze
27
27
 
28
- # alias_method :orig_foreach, :foreach
29
- # def foreach(_name, _sep = $/, _limit = nil, _getline_args = EMPTY_HASH,
30
- # &_block)
31
- # # IO.orig_read(name).each_line(&block)
32
- # raise NotImplementedError
33
-
34
- # # if sep.is_a?(Integer)
35
- # # sep = $/
36
- # # limit = sep
37
- # # end
38
- # # File.open(name, 'r') do |f|
39
- # # f.each_line(sep, limit, getline_args, &block)
40
- # # end
41
- # end
28
+ alias_method :orig_foreach, :foreach
29
+ def foreach(name, sep = $/, limit = nil, getline_args = EMPTY_HASH, &block)
30
+ # IO.orig_read(name).each_line(&block)
31
+ # raise NotImplementedError
32
+
33
+ if sep.is_a?(Integer)
34
+ sep = $/
35
+ limit = sep
36
+ end
37
+ File.open(name, 'r') do |f|
38
+ f.each_line(sep, limit, chomp: getline_args[:chomp], &block)
39
+ end
40
+ end
42
41
 
43
42
  alias_method :orig_read, :read
44
43
  def read(name, length = nil, offset = nil, opt = EMPTY_HASH)
@@ -198,6 +197,30 @@ class ::IO
198
197
  return nil
199
198
  end
200
199
 
200
+ def each_line(sep = $/, limit = nil, chomp: false)
201
+ if sep.is_a?(Integer)
202
+ limit = sep
203
+ sep = $/
204
+ end
205
+ sep_size = sep.bytesize
206
+
207
+
208
+ @read_buffer ||= +''
209
+
210
+ while true
211
+ while (idx = @read_buffer.index(sep))
212
+ line = @read_buffer.slice!(0, idx + sep_size)
213
+ line = line.chomp if chomp
214
+ yield line
215
+ end
216
+
217
+ result = readpartial(8192, @read_buffer, -1)
218
+ return self if !result
219
+ end
220
+ rescue EOFError
221
+ return self
222
+ end
223
+
201
224
  # def print(*args)
202
225
  # end
203
226
 
@@ -200,7 +200,7 @@ class ::OpenSSL::SSL::SSLServer
200
200
  def accept_loop(ignore_errors = true)
201
201
  loop do
202
202
  yield accept
203
- rescue SystemCallError, StandardError => e
203
+ rescue OpenSSL::SSL::SSLError, SystemCallError => e
204
204
  raise e unless ignore_errors
205
205
  end
206
206
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polyphony
4
- VERSION = '0.98'
4
+ VERSION = '0.99'
5
5
  end
data/test/test_io.rb CHANGED
@@ -523,13 +523,12 @@ class IOClassMethodsTest < MiniTest::Test
523
523
  assert_equal BIN_DATA, s
524
524
  end
525
525
 
526
- # def test_foreach
527
- # skip 'IO.foreach is not yet implemented'
528
- # lines = []
529
- # IO.foreach(__FILE__) { |l| lines << l }
530
- # assert_equal "# frozen_string_literal: true\n", lines[0]
531
- # assert_equal "end\n", lines[-1]
532
- # end
526
+ def test_foreach
527
+ lines = []
528
+ IO.foreach(__FILE__) { |l| lines << l }
529
+ assert_equal "# frozen_string_literal: true\n", lines[0]
530
+ assert_equal "end\n", lines[-1]
531
+ end
533
532
 
534
533
  def test_read_class_method
535
534
  s = IO.read(__FILE__)
data/test/test_socket.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative 'helper'
4
4
  require 'fileutils'
5
5
  require 'msgpack'
6
+ require 'localhost/authority'
6
7
 
7
8
  class TCPSocketTest < MiniTest::Test
8
9
  def start_tcp_server_on_random_port(host = '127.0.0.1')
@@ -322,3 +323,63 @@ if IS_LINUX
322
323
  end
323
324
  end
324
325
  end
326
+
327
+ class SSLSocketTest < MiniTest::Test
328
+ def handle_http_request(socket)
329
+ while (data = socket.gets("\n", 8192))
330
+ if data.chomp.empty?
331
+ socket << "HTTP/1.1 200 OK\nConnection: close\nContent-Length: 3\n\nfoo"
332
+ break
333
+ end
334
+ end
335
+ end
336
+
337
+ def test_ssl_accept_loop
338
+ authority = Localhost::Authority.fetch
339
+ server_ctx = authority.server_context
340
+
341
+ opts = {
342
+ reuse_addr: true,
343
+ dont_linger: true,
344
+ secure_context: server_ctx
345
+ }
346
+
347
+ port = rand(10001..39999)
348
+ server = Polyphony::Net.tcp_listen('127.0.0.1', port, opts)
349
+ f = spin do
350
+ server.accept_loop { |s| handle_http_request(s) }
351
+ end
352
+
353
+ # make bad request
354
+ `curl -s http://localhost:#{port}/`
355
+
356
+ msg = `curl -sk https://localhost:#{port}/`
357
+ assert_equal 'foo', msg
358
+
359
+ f.stop
360
+ f.await
361
+
362
+ port = rand(10001..39999)
363
+ server = Polyphony::Net.tcp_listen('127.0.0.1', port, opts)
364
+ errors = []
365
+ f = spin do
366
+ ## without ignoring errors
367
+ f2 = spin do
368
+ server.accept_loop(false) { |s| handle_http_request(s) }
369
+ end
370
+ f2.await
371
+ rescue => e
372
+ errors << e
373
+ end
374
+
375
+ msg = `curl -sk https://localhost:#{port}/`
376
+ assert_equal 'foo', msg
377
+
378
+ # make bad request
379
+ `curl -s http://localhost:#{port}/`
380
+
381
+ f.await
382
+ assert_equal 1, errors.size
383
+ assert_kind_of OpenSSL::SSL::SSLError, errors.first
384
+ end
385
+ end
data/test/test_sync.rb CHANGED
@@ -113,4 +113,45 @@ class MutexTest < MiniTest::Test
113
113
  receive
114
114
  assert !lock.locked?
115
115
  end
116
- end
116
+
117
+ def test_lock_unlock
118
+ m = Polyphony::Mutex.new
119
+ assert_nil m.locked?
120
+ assert_equal false, m.owned?
121
+ assert_raises(ThreadError) { m.unlock }
122
+
123
+ m.lock
124
+ assert_equal Fiber.current, m.locked?
125
+ assert_equal true, m.owned?
126
+
127
+ assert_raises(ThreadError) { m.lock }
128
+
129
+ m.unlock
130
+ assert_nil m.locked?
131
+ assert_equal false, m.owned?
132
+ end
133
+
134
+ def test_try_lock
135
+ m = Polyphony::Mutex.new
136
+
137
+ r = m.try_lock
138
+ assert_equal true, r
139
+
140
+ r = m.try_lock
141
+ assert_equal false, r
142
+
143
+ this = Fiber.current
144
+ m.unlock
145
+ f = spin do
146
+ m.synchronize { this << 'ok'; sleep 0.2 }
147
+ end
148
+
149
+ assert_equal 'ok', receive
150
+ r = m.try_lock
151
+ assert_equal false, r
152
+
153
+ f.await
154
+ r = m.try_lock
155
+ assert_equal true, r
156
+ end
157
+ end
@@ -26,7 +26,8 @@ jobs:
26
26
  cxx_pkg: clang
27
27
  cc: clang
28
28
  cxx: clang++
29
- extra_flags: -Wshorten-64-to-32
29
+ liburing_extra_flags: -Wshorten-64-to-32
30
+ extra_flags: -Wmissing-prototypes -Wstrict-prototypes -Wunreachable-code-loop-increment -Wunreachable-code -Wmissing-variable-declarations -Wextra-semi-stmt
30
31
 
31
32
  # x86 (32-bit) gcc
32
33
  - arch: i686
@@ -85,10 +86,10 @@ jobs:
85
86
  cxx: mips-linux-gnu-g++
86
87
 
87
88
  env:
88
- FLAGS: -g -O3 -Wall -Wextra -Werror
89
+ FLAGS: -g -O3 -Wall -Wextra -Werror -Wno-sign-compare ${{matrix.extra_flags}}
89
90
 
90
91
  # Flags for building sources in src/ dir only.
91
- LIBURING_CFLAGS: ${{matrix.extra_flags}}
92
+ LIBURING_CFLAGS: ${{matrix.liburing_extra_flags}}
92
93
 
93
94
  steps:
94
95
  - name: Checkout source
@@ -98,9 +99,9 @@ jobs:
98
99
  run: |
99
100
  if [[ "${{matrix.cc_pkg}}" == "clang" ]]; then \
100
101
  wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh; \
101
- sudo bash /tmp/llvm.sh 16; \
102
- sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 400; \
103
- sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 400; \
102
+ sudo bash /tmp/llvm.sh 17; \
103
+ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 400; \
104
+ sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 400; \
104
105
  else \
105
106
  sudo apt-get update -y; \
106
107
  sudo apt-get install -y ${{matrix.cc_pkg}} ${{matrix.cxx_pkg}}; \
@@ -116,16 +117,6 @@ jobs:
116
117
  ./configure --cc=${{matrix.cc}} --cxx=${{matrix.cxx}};
117
118
  make -j$(nproc) V=1 CPPFLAGS="-Werror" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS";
118
119
 
119
- - name: Build nolibc
120
- run: |
121
- if [[ "${{matrix.arch}}" == "x86_64" || "${{matrix.arch}}" == "i686" || "${{matrix.arch}}" == "aarch64" ]]; then \
122
- make clean; \
123
- ./configure --cc=${{matrix.cc}} --cxx=${{matrix.cxx}} --nolibc; \
124
- make -j$(nproc) V=1 CPPFLAGS="-Werror" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS"; \
125
- else \
126
- echo "Skipping nolibc build, this arch doesn't support building liburing without libc"; \
127
- fi;
128
-
129
120
  - name: Test install command
130
121
  run: |
131
122
  sudo make install;
@@ -9,8 +9,12 @@
9
9
 
10
10
  /src/liburing.a
11
11
  /src/liburing.so*
12
+ /src/liburing-ffi.a
13
+ /src/liburing-ffi.so*
12
14
  /src/include/liburing/compat.h
15
+ /src/include/liburing/io_uring_version.h
13
16
 
17
+ /examples/io_uring-close-test
14
18
  /examples/io_uring-cp
15
19
  /examples/io_uring-test
16
20
  /examples/io_uring-udp
@@ -28,5 +32,6 @@ config-host.mak
28
32
  config.log
29
33
 
30
34
  liburing.pc
35
+ liburing-ffi.pc
31
36
 
32
37
  cscope.out
@@ -1,8 +1,30 @@
1
+ liburing-2.4 release
2
+
3
+ - Add io_uring_{major,minor,check}_version() functions.
4
+ - Add IO_URING_{MAJOR,MINOR,CHECK}_VERSION() macros.
5
+ - FFI support (for non-C/C++ languages integration).
6
+ - Add io_uring_prep_msg_ring_cqe_flags() function.
7
+ - Deprecate --nolibc configure option.
8
+ - CONFIG_NOLIBC is always enabled on x86-64, x86, and aarch64.
9
+ - Add support for IORING_REGISTER_USE_REGISTERED_RING and use if available.
10
+ - Add io_uring_close_ring_fd() function.
11
+
1
12
  liburing-2.3 release
2
13
 
3
14
  - Support non-libc build for aarch64.
4
15
  - Add io_uring_{enter,enter2,register,setup} syscall functions.
5
-
16
+ - Add sync cancel interface, io_uring_register_sync_cancel().
17
+ - Fix return value of io_uring_submit_and_wait_timeout() to match the
18
+ man page.
19
+ - Improvements to the regression tests
20
+ - Add support and test case for passthrough IO
21
+ - Add recv and recvmsg multishot helpers and support
22
+ - Add documentation and support for IORING_SETUP_DEFER_TASKRUN
23
+ - Fix potential missing kernel entry with IORING_SETUP_IOPOLL
24
+ - Add support and documentation for zero-copy network transmit
25
+ - Various optimizations
26
+ - Many cleanups
27
+ - Many man page additions and updates
6
28
 
7
29
  liburing-2.2 release
8
30
 
@@ -25,7 +25,7 @@ runtests-parallel: all
25
25
  @$(MAKE) -C test runtests-parallel
26
26
 
27
27
  config-host.mak: configure
28
- @if [ ! -e "$@" ]; then \
28
+ +@if [ ! -e "$@" ]; then \
29
29
  echo "Running configure ..."; \
30
30
  ./configure; \
31
31
  else \
@@ -45,13 +45,14 @@ endif
45
45
  -e "s%@VERSION@%$(VERSION)%g" \
46
46
  $< >$@
47
47
 
48
- install: $(NAME).pc
48
+ install: $(NAME).pc $(NAME)-ffi.pc
49
49
  @$(MAKE) -C src install prefix=$(DESTDIR)$(prefix) \
50
50
  includedir=$(DESTDIR)$(includedir) \
51
51
  libdir=$(DESTDIR)$(libdir) \
52
52
  libdevdir=$(DESTDIR)$(libdevdir) \
53
53
  relativelibdir=$(relativelibdir)
54
54
  $(INSTALL) -D -m 644 $(NAME).pc $(DESTDIR)$(libdevdir)/pkgconfig/$(NAME).pc
55
+ $(INSTALL) -D -m 644 $(NAME)-ffi.pc $(DESTDIR)$(libdevdir)/pkgconfig/$(NAME)-ffi.pc
55
56
  $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man2
56
57
  $(INSTALL) -m 644 man/*.2 $(DESTDIR)$(mandir)/man2
57
58
  $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3
@@ -63,7 +64,7 @@ install-tests:
63
64
  @$(MAKE) -C test install prefix=$(DESTDIR)$(prefix) datadir=$(DESTDIR)$(datadir)
64
65
 
65
66
  clean:
66
- @rm -f config-host.mak config-host.h cscope.out $(NAME).pc test/*.dmesg
67
+ @rm -f config-host.mak config-host.h cscope.out $(NAME).pc $(NAME)-ffi.pc test/*.dmesg
67
68
  @$(MAKE) -C src clean
68
69
  @$(MAKE) -C test clean
69
70
  @$(MAKE) -C examples clean
@@ -3,4 +3,5 @@ NAME=liburing
3
3
  SPECFILE=$(TOP)/$(NAME).spec
4
4
  VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE))
5
5
  VERSION_MAJOR=$(shell echo $(VERSION) | cut -d. -f1)
6
+ VERSION_MINOR=$(shell echo $(VERSION) | cut -d. -f2)
6
7
  TAG = $(NAME)-$(VERSION)
@@ -47,6 +47,54 @@ the kernel io_uring support. Please note that this suite isn't expected to
47
47
  pass on older kernels, and may even crash or hang older kernels!
48
48
 
49
49
 
50
+ Building liburing
51
+ -----------------
52
+
53
+ #
54
+ # Prepare build config (optional).
55
+ #
56
+ # --cc specifies the C compiler.
57
+ # --cxx speficies the C++ compiler.
58
+ #
59
+ ./configure --cc=gcc --cxx=g++;
60
+
61
+ #
62
+ # Build liburing.
63
+ #
64
+ make -j$(nproc);
65
+
66
+ #
67
+ # Install liburing (headers, shared/static libs, and manpage).
68
+ #
69
+ sudo make install;
70
+
71
+ See './configure --help' for more information about build config options.
72
+
73
+
74
+ FFI support
75
+ -----------
76
+
77
+ By default, the build results in 4 lib files:
78
+
79
+ 2 shared libs:
80
+
81
+ liburing.so
82
+ liburing-ffi.so
83
+
84
+ 2 static libs:
85
+
86
+ liburing.a
87
+ liburing-ffi.a
88
+
89
+ Languages and applications that can't use 'static inline' functions in
90
+ liburing.h should use the FFI variants.
91
+
92
+ liburing's main public interface lives in liburing.h as 'static inline'
93
+ functions. Users wishing to consume liburing purely as a binary dependency
94
+ should link against liburing-ffi. It contains definitions for every 'static
95
+ inline' function.
96
+
97
+
50
98
  License
51
99
  -------
52
100