polyphony 0.98 → 0.99.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -1
- data/.rubocop.yml +3 -3
- data/.yardopts +30 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE +1 -1
- data/README.md +63 -29
- data/Rakefile +1 -5
- data/TODO.md +0 -4
- data/docs/{main-concepts/concurrency.md → concurrency.md} +2 -9
- data/docs/{main-concepts/design-principles.md → design-principles.md} +3 -9
- data/docs/{main-concepts/exception-handling.md → exception-handling.md} +2 -9
- data/docs/{main-concepts/extending.md → extending.md} +2 -9
- data/docs/faq.md +3 -16
- data/docs/{main-concepts/fiber-scheduling.md → fiber-scheduling.md} +1 -9
- data/docs/link_rewriter.rb +16 -0
- data/docs/{getting-started/overview.md → overview.md} +1 -30
- data/docs/{getting-started/tutorial.md → tutorial.md} +3 -28
- data/docs/{_posts/2020-07-26-polyphony-0.44.md → whats-new.md} +3 -1
- data/examples/adapters/redis_client.rb +3 -2
- data/examples/io/echo_server.rb +1 -1
- data/examples/io/echo_server_plain_ruby.rb +26 -0
- data/examples/io/https_server_sni_2.rb +14 -8
- data/ext/polyphony/backend_io_uring.c +154 -9
- data/ext/polyphony/backend_io_uring_context.c +21 -12
- data/ext/polyphony/backend_io_uring_context.h +12 -7
- data/ext/polyphony/backend_libev.c +1 -1
- data/ext/polyphony/extconf.rb +25 -8
- data/ext/polyphony/fiber.c +79 -2
- data/ext/polyphony/io_extensions.c +53 -0
- data/ext/polyphony/libev.h +0 -2
- data/ext/polyphony/pipe.c +42 -2
- data/ext/polyphony/polyphony.c +345 -31
- data/ext/polyphony/polyphony.h +9 -2
- data/ext/polyphony/queue.c +181 -0
- data/ext/polyphony/ring_buffer.c +0 -1
- data/ext/polyphony/runqueue.c +8 -1
- data/ext/polyphony/runqueue_ring_buffer.c +13 -0
- data/ext/polyphony/runqueue_ring_buffer.h +2 -1
- data/ext/polyphony/socket_extensions.c +6 -0
- data/ext/polyphony/thread.c +34 -2
- data/lib/polyphony/adapters/process.rb +11 -1
- data/lib/polyphony/adapters/sequel.rb +1 -1
- data/lib/polyphony/core/channel.rb +2 -0
- data/lib/polyphony/core/debug.rb +1 -1
- data/lib/polyphony/core/global_api.rb +25 -24
- data/lib/polyphony/core/resource_pool.rb +7 -6
- data/lib/polyphony/core/sync.rb +55 -2
- data/lib/polyphony/core/thread_pool.rb +3 -3
- data/lib/polyphony/core/timer.rb +8 -8
- data/lib/polyphony/extensions/exception.rb +2 -0
- data/lib/polyphony/extensions/fiber.rb +15 -13
- data/lib/polyphony/extensions/io.rb +161 -16
- data/lib/polyphony/extensions/kernel.rb +20 -2
- data/lib/polyphony/extensions/openssl.rb +101 -12
- data/lib/polyphony/extensions/pipe.rb +103 -7
- data/lib/polyphony/extensions/process.rb +13 -1
- data/lib/polyphony/extensions/socket.rb +93 -27
- data/lib/polyphony/extensions/thread.rb +9 -1
- data/lib/polyphony/extensions/timeout.rb +1 -1
- data/lib/polyphony/version.rb +2 -1
- data/lib/polyphony.rb +27 -7
- data/polyphony.gemspec +1 -8
- data/test/stress.rb +1 -1
- data/test/test_global_api.rb +45 -7
- data/test/test_io.rb +6 -7
- data/test/test_socket.rb +157 -0
- data/test/test_sync.rb +42 -1
- data/test/test_timer.rb +5 -5
- data/vendor/liburing/.github/workflows/build.yml +7 -16
- data/vendor/liburing/.gitignore +5 -0
- data/vendor/liburing/CHANGELOG +23 -1
- data/vendor/liburing/Makefile +4 -3
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +48 -0
- data/vendor/liburing/configure +76 -6
- data/vendor/liburing/debian/changelog +11 -0
- data/vendor/liburing/debian/control +7 -16
- data/vendor/liburing/debian/liburing-dev.manpages +3 -6
- data/vendor/liburing/debian/liburing2.install +1 -0
- data/vendor/liburing/debian/liburing2.symbols +56 -0
- data/vendor/liburing/debian/rules +15 -68
- data/vendor/liburing/examples/Makefile +4 -0
- data/vendor/liburing/examples/io_uring-close-test.c +123 -0
- data/vendor/liburing/examples/io_uring-udp.c +1 -1
- data/vendor/liburing/examples/send-zerocopy.c +315 -56
- data/vendor/liburing/examples/ucontext-cp.c +2 -17
- data/vendor/liburing/liburing-ffi.pc.in +12 -0
- data/vendor/liburing/liburing.pc.in +1 -1
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/make-debs.sh +3 -3
- data/vendor/liburing/man/IO_URING_CHECK_VERSION.3 +1 -0
- data/vendor/liburing/man/IO_URING_VERSION_MAJOR.3 +1 -0
- data/vendor/liburing/man/IO_URING_VERSION_MINOR.3 +1 -0
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +6 -6
- data/vendor/liburing/man/io_uring_check_version.3 +72 -0
- data/vendor/liburing/man/io_uring_close_ring_fd.3 +43 -0
- data/vendor/liburing/man/io_uring_major_version.3 +1 -0
- data/vendor/liburing/man/io_uring_minor_version.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +1 -1
- data/vendor/liburing/man/io_uring_prep_fgetxattr.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_fsetxattr.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_getxattr.3 +61 -0
- data/vendor/liburing/man/io_uring_prep_link_timeout.3 +94 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +22 -2
- data/vendor/liburing/man/io_uring_prep_msg_ring_cqe_flags.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +1 -1
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +18 -9
- data/vendor/liburing/man/io_uring_prep_readv.3 +3 -3
- data/vendor/liburing/man/io_uring_prep_readv2.3 +3 -3
- data/vendor/liburing/man/io_uring_prep_recv.3 +5 -5
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +4 -4
- data/vendor/liburing/man/io_uring_prep_send.3 +9 -0
- data/vendor/liburing/man/io_uring_prep_send_set_addr.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +39 -7
- data/vendor/liburing/man/io_uring_prep_send_zc_fixed.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +20 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg_zc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_setxattr.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +40 -0
- data/vendor/liburing/man/io_uring_prep_writev.3 +2 -2
- data/vendor/liburing/man/io_uring_prep_writev2.3 +2 -2
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +13 -9
- data/vendor/liburing/man/io_uring_register.2 +15 -9
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +4 -4
- data/vendor/liburing/man/io_uring_register_buffers.3 +49 -6
- data/vendor/liburing/man/io_uring_register_buffers_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_buffers_tags.3 +1 -0
- data/vendor/liburing/man/io_uring_register_buffers_update_tag.3 +1 -0
- data/vendor/liburing/man/io_uring_register_files.3 +60 -5
- data/vendor/liburing/man/io_uring_register_files_tags.3 +1 -0
- data/vendor/liburing/man/io_uring_register_files_update.3 +1 -0
- data/vendor/liburing/man/io_uring_register_files_update_tag.3 +1 -0
- data/vendor/liburing/man/io_uring_setup.2 +31 -2
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +1 -1
- data/vendor/liburing/src/Makefile +25 -3
- data/vendor/liburing/src/ffi.c +15 -0
- data/vendor/liburing/src/include/liburing/io_uring.h +30 -7
- data/vendor/liburing/src/include/liburing.h +190 -148
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +5 -16
- data/vendor/liburing/src/liburing-ffi.map +172 -0
- data/vendor/liburing/src/liburing.map +11 -0
- data/vendor/liburing/src/nolibc.c +9 -2
- data/vendor/liburing/src/queue.c +2 -2
- data/vendor/liburing/src/register.c +66 -96
- data/vendor/liburing/src/setup.c +5 -4
- data/vendor/liburing/src/version.c +21 -0
- data/vendor/liburing/test/232c93d07b74.c +3 -3
- data/vendor/liburing/test/35fa71a030ca.c +3 -3
- data/vendor/liburing/test/500f9fbadef8.c +2 -0
- data/vendor/liburing/test/917257daa0fe.c +1 -1
- data/vendor/liburing/test/Makefile +27 -7
- data/vendor/liburing/test/a0908ae19763.c +2 -2
- data/vendor/liburing/test/a4c0b3decb33.c +2 -2
- data/vendor/liburing/test/accept-link.c +4 -4
- data/vendor/liburing/test/accept-reuse.c +5 -7
- data/vendor/liburing/test/accept.c +34 -31
- data/vendor/liburing/test/b19062a56726.c +1 -1
- data/vendor/liburing/test/buf-ring.c +58 -4
- data/vendor/liburing/test/ce593a6c480a.c +2 -2
- data/vendor/liburing/test/close-opath.c +2 -1
- data/vendor/liburing/test/connect.c +8 -0
- data/vendor/liburing/test/cq-overflow.c +14 -8
- data/vendor/liburing/test/d4ae271dfaae.c +1 -1
- data/vendor/liburing/test/defer-taskrun.c +64 -9
- data/vendor/liburing/test/defer.c +1 -1
- data/vendor/liburing/test/double-poll-crash.c +3 -3
- data/vendor/liburing/test/eeed8b54e0df.c +8 -3
- data/vendor/liburing/test/eploop.c +74 -0
- data/vendor/liburing/test/eventfd-ring.c +1 -1
- data/vendor/liburing/test/eventfd.c +1 -1
- data/vendor/liburing/test/evloop.c +73 -0
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +1 -1
- data/vendor/liburing/test/fc2a85cb02ef.c +3 -3
- data/vendor/liburing/test/fd-pass.c +35 -16
- data/vendor/liburing/test/file-register.c +61 -0
- data/vendor/liburing/test/file-verify.c +2 -2
- data/vendor/liburing/test/files-exit-hang-timeout.c +2 -2
- data/vendor/liburing/test/fixed-link.c +1 -1
- data/vendor/liburing/test/fsnotify.c +118 -0
- data/vendor/liburing/test/hardlink.c +1 -1
- data/vendor/liburing/test/helpers.c +54 -2
- data/vendor/liburing/test/helpers.h +4 -0
- data/vendor/liburing/test/io-cancel.c +3 -1
- data/vendor/liburing/test/io_uring_passthrough.c +39 -8
- data/vendor/liburing/test/io_uring_setup.c +3 -80
- data/vendor/liburing/test/iopoll-overflow.c +118 -0
- data/vendor/liburing/test/iopoll.c +90 -4
- data/vendor/liburing/test/lfs-openat-write.c +7 -9
- data/vendor/liburing/test/lfs-openat.c +6 -8
- data/vendor/liburing/test/link_drain.c +31 -5
- data/vendor/liburing/test/madvise.c +1 -1
- data/vendor/liburing/test/msg-ring-flags.c +192 -0
- data/vendor/liburing/test/msg-ring-overflow.c +159 -0
- data/vendor/liburing/test/msg-ring.c +173 -13
- data/vendor/liburing/test/multicqes_drain.c +22 -19
- data/vendor/liburing/test/nvme.h +4 -3
- data/vendor/liburing/test/pipe-bug.c +95 -0
- data/vendor/liburing/test/poll-link.c +3 -3
- data/vendor/liburing/test/poll-many.c +41 -19
- data/vendor/liburing/test/poll-mshot-overflow.c +105 -2
- data/vendor/liburing/test/poll-race-mshot.c +292 -0
- data/vendor/liburing/test/poll-race.c +105 -0
- data/vendor/liburing/test/poll.c +244 -26
- data/vendor/liburing/test/pollfree.c +5 -5
- data/vendor/liburing/test/read-before-exit.c +20 -3
- data/vendor/liburing/test/read-write.c +2 -0
- data/vendor/liburing/test/recv-multishot.c +96 -3
- data/vendor/liburing/test/reg-reg-ring.c +90 -0
- data/vendor/liburing/test/rename.c +1 -1
- data/vendor/liburing/test/ring-leak.c +0 -1
- data/vendor/liburing/test/ring-leak2.c +1 -1
- data/vendor/liburing/test/ringbuf-read.c +10 -6
- data/vendor/liburing/test/send-zerocopy.c +273 -103
- data/vendor/liburing/test/send_recv.c +7 -4
- data/vendor/liburing/test/sendmsg_fs_cve.c +2 -2
- data/vendor/liburing/test/single-issuer.c +7 -9
- data/vendor/liburing/test/skip-cqe.c +3 -4
- data/vendor/liburing/test/socket.c +0 -1
- data/vendor/liburing/test/sq-poll-dup.c +10 -3
- data/vendor/liburing/test/sq-poll-kthread.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +3 -2
- data/vendor/liburing/test/sqpoll-cancel-hang.c +17 -6
- data/vendor/liburing/test/sqpoll-disable-exit.c +4 -4
- data/vendor/liburing/test/symlink.c +2 -1
- data/vendor/liburing/test/test.h +2 -1
- data/vendor/liburing/test/timeout-new.c +11 -7
- data/vendor/liburing/test/timeout.c +1 -2
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/version.c +25 -0
- data/vendor/liburing/test/wakeup-hang.c +1 -1
- data/vendor/liburing/test/xattr.c +8 -4
- metadata +57 -44
- data/docs/_config.yml +0 -64
- data/docs/_includes/head.html +0 -40
- data/docs/_includes/title.html +0 -1
- data/docs/_sass/custom/custom.scss +0 -10
- data/docs/_sass/overrides.scss +0 -0
- data/docs/api-reference/exception.md +0 -31
- data/docs/api-reference/fiber.md +0 -425
- data/docs/api-reference/index.md +0 -9
- data/docs/api-reference/io.md +0 -36
- data/docs/api-reference/object.md +0 -99
- data/docs/api-reference/polyphony-baseexception.md +0 -33
- data/docs/api-reference/polyphony-cancel.md +0 -26
- data/docs/api-reference/polyphony-moveon.md +0 -24
- data/docs/api-reference/polyphony-net.md +0 -20
- data/docs/api-reference/polyphony-process.md +0 -28
- data/docs/api-reference/polyphony-resourcepool.md +0 -59
- data/docs/api-reference/polyphony-restart.md +0 -18
- data/docs/api-reference/polyphony-terminate.md +0 -18
- data/docs/api-reference/polyphony-threadpool.md +0 -67
- data/docs/api-reference/polyphony-throttler.md +0 -77
- data/docs/api-reference/polyphony.md +0 -36
- data/docs/api-reference/thread.md +0 -88
- data/docs/favicon.ico +0 -0
- data/docs/getting-started/index.md +0 -10
- data/docs/getting-started/installing.md +0 -34
- data/vendor/liburing/debian/compat +0 -1
- data/vendor/liburing/debian/liburing1-udeb.install +0 -1
- data/vendor/liburing/debian/liburing1.install +0 -1
- data/vendor/liburing/debian/liburing1.symbols +0 -32
- /data/{docs/assets/img → assets}/echo-fibers.svg +0 -0
- /data/{docs → assets}/polyphony-logo.png +0 -0
- /data/{docs/assets/img → assets}/sleeping-fiber.svg +0 -0
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,159 @@ 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
|
386
|
+
|
387
|
+
class MultishotAcceptTest < MiniTest::Test
|
388
|
+
def setup
|
389
|
+
skip if !TCPServer.instance_methods(false).include?(:multishot_accept)
|
390
|
+
end
|
391
|
+
|
392
|
+
def start_tcp_server_on_random_port(host = '127.0.0.1')
|
393
|
+
port = rand(1100..60000)
|
394
|
+
server = TCPServer.new(host, port)
|
395
|
+
[port, server]
|
396
|
+
rescue Errno::EADDRINUSE
|
397
|
+
retry
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_multishot_accept_while_loop
|
401
|
+
port, server = start_tcp_server_on_random_port
|
402
|
+
server_fiber = spin do
|
403
|
+
server.multishot_accept do
|
404
|
+
while (socket = server.accept)
|
405
|
+
spin do
|
406
|
+
while (data = socket.gets(8192))
|
407
|
+
socket << data
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
snooze
|
415
|
+
client = TCPSocket.new('127.0.0.1', port)
|
416
|
+
client.write("1234\n")
|
417
|
+
assert_equal "1234\n", client.recv(8192)
|
418
|
+
client.close
|
419
|
+
|
420
|
+
client = TCPSocket.new('127.0.0.1', port)
|
421
|
+
client.write("5678\n")
|
422
|
+
assert_equal "5678\n", client.recv(8192)
|
423
|
+
client.close
|
424
|
+
|
425
|
+
ensure
|
426
|
+
server_fiber&.stop
|
427
|
+
server_fiber&.await
|
428
|
+
server&.close
|
429
|
+
end
|
430
|
+
|
431
|
+
def spin_client(socket)
|
432
|
+
spin do
|
433
|
+
while (data = socket.gets(8192))
|
434
|
+
socket << data
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
def test_multishot_accept_loop
|
440
|
+
port, server = start_tcp_server_on_random_port
|
441
|
+
server_fiber = spin do
|
442
|
+
server.multishot_accept do
|
443
|
+
server.accept_loop { |s| spin_client(s) }
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
snooze
|
448
|
+
client = TCPSocket.new('127.0.0.1', port)
|
449
|
+
client.write("1234\n")
|
450
|
+
assert_equal "1234\n", client.recv(8192)
|
451
|
+
client.close
|
452
|
+
|
453
|
+
client = TCPSocket.new('127.0.0.1', port)
|
454
|
+
client.write("5678\n")
|
455
|
+
assert_equal "5678\n", client.recv(8192)
|
456
|
+
client.close
|
457
|
+
|
458
|
+
ensure
|
459
|
+
server_fiber&.stop
|
460
|
+
server_fiber&.await
|
461
|
+
server&.close
|
462
|
+
end
|
463
|
+
|
464
|
+
def test_multishot_accept_error
|
465
|
+
port, server = start_tcp_server_on_random_port
|
466
|
+
error = nil
|
467
|
+
server_fiber = spin do
|
468
|
+
server.multishot_accept do
|
469
|
+
server.accept_loop { |s| spin_client(s) }
|
470
|
+
rescue SystemCallError => e
|
471
|
+
error = e
|
472
|
+
end
|
473
|
+
end
|
474
|
+
snooze
|
475
|
+
server.close
|
476
|
+
snooze
|
477
|
+
server_fiber.await
|
478
|
+
assert_kind_of Errno::EBADF, error
|
479
|
+
end
|
480
|
+
|
481
|
+
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
|
-
|
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
|
data/test/test_timer.rb
CHANGED
@@ -39,18 +39,18 @@ class TimerMoveOnAfterTest < MiniTest::Test
|
|
39
39
|
skip unless IS_LINUX
|
40
40
|
|
41
41
|
t0 = Time.now
|
42
|
-
v = @timer.move_on_after(0.
|
43
|
-
sleep 0.
|
42
|
+
v = @timer.move_on_after(0.1, with_value: :moved_on) do
|
43
|
+
sleep 0.07
|
44
44
|
@timer.reset
|
45
|
-
sleep 0.
|
45
|
+
sleep 0.07
|
46
46
|
@timer.reset
|
47
|
-
sleep 0.
|
47
|
+
sleep 0.07
|
48
48
|
nil
|
49
49
|
end
|
50
50
|
t1 = Time.now
|
51
51
|
|
52
52
|
assert_nil v
|
53
|
-
assert_in_range 0.
|
53
|
+
assert_in_range 0.15..0.4, t1 - t0
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -26,7 +26,8 @@ jobs:
|
|
26
26
|
cxx_pkg: clang
|
27
27
|
cc: clang
|
28
28
|
cxx: clang++
|
29
|
-
|
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.
|
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
|
102
|
-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-
|
103
|
-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-
|
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;
|
data/vendor/liburing/.gitignore
CHANGED
@@ -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
|
data/vendor/liburing/CHANGELOG
CHANGED
@@ -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
|
|
data/vendor/liburing/Makefile
CHANGED
@@ -25,7 +25,7 @@ runtests-parallel: all
|
|
25
25
|
@$(MAKE) -C test runtests-parallel
|
26
26
|
|
27
27
|
config-host.mak: configure
|
28
|
-
|
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
|
data/vendor/liburing/README
CHANGED
@@ -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
|
|
data/vendor/liburing/configure
CHANGED
@@ -5,6 +5,22 @@ set -e
|
|
5
5
|
cc=${CC:-gcc}
|
6
6
|
cxx=${CXX:-g++}
|
7
7
|
|
8
|
+
#
|
9
|
+
# TODO(ammarfaizi2): Remove this notice and `--nolibc` option.
|
10
|
+
#
|
11
|
+
nolibc_deprecated() {
|
12
|
+
echo "";
|
13
|
+
echo "=================================================================";
|
14
|
+
echo "";
|
15
|
+
echo " --nolibc option is deprecated and has no effect.";
|
16
|
+
echo " It will be removed in a future liburing release.";
|
17
|
+
echo "";
|
18
|
+
echo " liburing on x86-64, x86 (32-bit) and aarch64 always use CONFIG_NOLIBC.";
|
19
|
+
echo "";
|
20
|
+
echo "=================================================================";
|
21
|
+
echo "";
|
22
|
+
}
|
23
|
+
|
8
24
|
for opt do
|
9
25
|
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)' || true)
|
10
26
|
case "$opt" in
|
@@ -26,7 +42,7 @@ for opt do
|
|
26
42
|
;;
|
27
43
|
--cxx=*) cxx="$optarg"
|
28
44
|
;;
|
29
|
-
--nolibc)
|
45
|
+
--nolibc) nolibc_deprecated
|
30
46
|
;;
|
31
47
|
*)
|
32
48
|
echo "ERROR: unknown option $opt"
|
@@ -115,7 +131,7 @@ print_config() {
|
|
115
131
|
}
|
116
132
|
|
117
133
|
# Default CFLAGS
|
118
|
-
CFLAGS="-D_GNU_SOURCE -include config-host.h"
|
134
|
+
CFLAGS="-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -include config-host.h"
|
119
135
|
BUILD_CFLAGS=""
|
120
136
|
|
121
137
|
# Print configure header at the top of $config_host_h
|
@@ -385,13 +401,43 @@ fi
|
|
385
401
|
print_config "NVMe uring command support" "$nvme_uring_cmd"
|
386
402
|
|
387
403
|
#############################################################################
|
404
|
+
#
|
405
|
+
# Currently, CONFIG_NOLIBC is only enabled on x86-64, x86 (32-bit) and aarch64.
|
406
|
+
#
|
407
|
+
cat > $TMPC << EOF
|
408
|
+
int main(void){
|
409
|
+
#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
|
410
|
+
return 0;
|
411
|
+
#else
|
412
|
+
#error libc is needed
|
413
|
+
#endif
|
414
|
+
}
|
415
|
+
EOF
|
416
|
+
if compile_prog "" "" "nolibc support"; then
|
417
|
+
liburing_nolibc="yes"
|
418
|
+
fi
|
419
|
+
print_config "nolibc support" "$liburing_nolibc";
|
420
|
+
#############################################################################
|
421
|
+
|
422
|
+
####################################################
|
423
|
+
# Most Android devices don't have sys/fanotify.h
|
424
|
+
has_fanotify="no"
|
425
|
+
cat > $TMPC << EOF
|
426
|
+
#include <sys/fanotify.h>
|
427
|
+
int main(void)
|
428
|
+
{
|
429
|
+
return 0;
|
430
|
+
}
|
431
|
+
EOF
|
432
|
+
if compile_prog "" "" "fanotify"; then
|
433
|
+
has_fanotify="yes"
|
434
|
+
fi
|
435
|
+
print_config "has_fanotify" "$has_fanotify"
|
436
|
+
####################################################
|
437
|
+
|
388
438
|
if test "$liburing_nolibc" = "yes"; then
|
389
439
|
output_sym "CONFIG_NOLIBC"
|
390
|
-
else
|
391
|
-
liburing_nolibc="no"
|
392
440
|
fi
|
393
|
-
print_config "liburing_nolibc" "$liburing_nolibc"
|
394
|
-
|
395
441
|
if test "$__kernel_rwf_t" = "yes"; then
|
396
442
|
output_sym "CONFIG_HAVE_KERNEL_RWF_T"
|
397
443
|
fi
|
@@ -422,12 +468,31 @@ fi
|
|
422
468
|
if test "$nvme_uring_cmd" = "yes"; then
|
423
469
|
output_sym "CONFIG_HAVE_NVME_URING"
|
424
470
|
fi
|
471
|
+
if test "$has_fanotify" = "yes"; then
|
472
|
+
output_sym "CONFIG_HAVE_FANOTIFY"
|
473
|
+
fi
|
425
474
|
|
426
475
|
echo "CC=$cc" >> $config_host_mak
|
427
476
|
print_config "CC" "$cc"
|
428
477
|
echo "CXX=$cxx" >> $config_host_mak
|
429
478
|
print_config "CXX" "$cxx"
|
430
479
|
|
480
|
+
# generate io_uring_version.h
|
481
|
+
MAKE_PRINT_VARS="include Makefile.common\nprint-%: ; @echo \$(\$*)\n"
|
482
|
+
VERSION_MAJOR=$(env echo -e "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MAJOR)
|
483
|
+
VERSION_MINOR=$(env echo -e "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MINOR)
|
484
|
+
io_uring_version_h="src/include/liburing/io_uring_version.h"
|
485
|
+
cat > $io_uring_version_h << EOF
|
486
|
+
/* SPDX-License-Identifier: MIT */
|
487
|
+
#ifndef LIBURING_VERSION_H
|
488
|
+
#define LIBURING_VERSION_H
|
489
|
+
|
490
|
+
#define IO_URING_VERSION_MAJOR $VERSION_MAJOR
|
491
|
+
#define IO_URING_VERSION_MINOR $VERSION_MINOR
|
492
|
+
|
493
|
+
#endif
|
494
|
+
EOF
|
495
|
+
|
431
496
|
# generate compat.h
|
432
497
|
compat_h="src/include/liburing/compat.h"
|
433
498
|
cat > $compat_h << EOF
|
@@ -452,10 +517,15 @@ struct __kernel_timespec {
|
|
452
517
|
long long tv_nsec;
|
453
518
|
};
|
454
519
|
|
520
|
+
/* <linux/time_types.h> is not available, so it can't be included */
|
521
|
+
#define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 1
|
522
|
+
|
455
523
|
EOF
|
456
524
|
else
|
457
525
|
cat >> $compat_h << EOF
|
458
526
|
#include <linux/time_types.h>
|
527
|
+
/* <linux/time_types.h> is included above and not needed again */
|
528
|
+
#define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 1
|
459
529
|
|
460
530
|
EOF
|
461
531
|
fi
|
@@ -1,3 +1,14 @@
|
|
1
|
+
liburing (2.2-1) stable; urgency=low
|
2
|
+
|
3
|
+
* Update to 2.2
|
4
|
+
* Bump up so version to 2
|
5
|
+
* Drop liburing1-udeb
|
6
|
+
* Package using dh instead of using dh_* helpers manually
|
7
|
+
* Add linux header dependency to liburing-dev
|
8
|
+
* Bump up debhelper-compact level to 13
|
9
|
+
|
10
|
+
-- Kefu Chai <tchaikov@gmail.com> Sun, 16 Oct 2022 16:30:48 +0800
|
11
|
+
|
1
12
|
liburing (0.7-1) stable; urgency=low
|
2
13
|
|
3
14
|
* Update to 0.7
|
@@ -2,13 +2,14 @@ Source: liburing
|
|
2
2
|
Section: libs
|
3
3
|
Priority: optional
|
4
4
|
Maintainer: Liu Changcheng <changcheng.liu@intel.com>
|
5
|
-
Build-Depends:
|
5
|
+
Build-Depends:
|
6
|
+
debhelper-compat (= 13)
|
6
7
|
Standards-Version: 4.1.4
|
7
8
|
Homepage: https://git.kernel.dk/cgit/liburing/tree/README
|
8
9
|
Vcs-Git: https://git.kernel.dk/liburing
|
9
10
|
Vcs-Browser: https://git.kernel.dk/cgit/liburing/
|
10
11
|
|
11
|
-
Package:
|
12
|
+
Package: liburing2
|
12
13
|
Architecture: linux-any
|
13
14
|
Multi-Arch: same
|
14
15
|
Pre-Depends: ${misc:Pre-Depends}
|
@@ -21,24 +22,14 @@ Description: userspace library for using io_uring
|
|
21
22
|
.
|
22
23
|
This package contains the shared library.
|
23
24
|
|
24
|
-
Package: liburing1-udeb
|
25
|
-
Package-Type: udeb
|
26
|
-
Section: debian-installer
|
27
|
-
Architecture: linux-any
|
28
|
-
Depends: ${misc:Depends}, ${shlibs:Depends},
|
29
|
-
Description: userspace library for using io_uring
|
30
|
-
io_uring is kernel feature to improve development
|
31
|
-
The newese Linux IO interface, io_uring could improve
|
32
|
-
system performance a lot. liburing is the userpace
|
33
|
-
library to use io_uring feature.
|
34
|
-
.
|
35
|
-
This package contains the udeb shared library.
|
36
|
-
|
37
25
|
Package: liburing-dev
|
38
26
|
Section: libdevel
|
39
27
|
Architecture: linux-any
|
40
28
|
Multi-Arch: same
|
41
|
-
Depends:
|
29
|
+
Depends:
|
30
|
+
${misc:Depends},
|
31
|
+
liburing2 (= ${binary:Version}),
|
32
|
+
linux-libc-dev (>= 5.1)
|
42
33
|
Description: userspace library for using io_uring
|
43
34
|
io_uring is kernel feature to improve development
|
44
35
|
The newese Linux IO interface, io_uring could improve
|
@@ -0,0 +1 @@
|
|
1
|
+
usr/lib/*/lib*.so.*
|