polyphony 0.94 → 0.95
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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.gitignore +3 -3
- data/CHANGELOG.md +14 -0
- data/docs/api-reference/fiber.md +2 -2
- data/docs/api-reference/object.md +3 -3
- data/docs/main-concepts/exception-handling.md +2 -2
- data/ext/polyphony/backend_common.c +3 -3
- data/ext/polyphony/backend_io_uring.c +18 -16
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +5 -3
- data/ext/polyphony/fiber.c +5 -13
- data/ext/polyphony/io_extensions.c +1 -1
- data/ext/polyphony/pipe.c +1 -1
- data/ext/polyphony/polyphony.c +1 -1
- data/ext/polyphony/polyphony_ext.c +1 -1
- data/ext/polyphony/queue.c +1 -1
- data/ext/polyphony/ring_buffer.c +1 -0
- data/ext/polyphony/socket_extensions.c +1 -1
- data/ext/polyphony/thread.c +1 -1
- data/lib/polyphony/extensions/enumerator.rb +16 -0
- data/lib/polyphony/extensions/socket.rb +2 -0
- data/lib/polyphony/extensions.rb +1 -0
- data/lib/polyphony/version.rb +1 -1
- data/polyphony.gemspec +2 -2
- data/test/test_backend.rb +5 -1
- data/test/test_enumerator.rb +46 -0
- data/test/test_io.rb +241 -216
- data/test/test_socket.rb +1 -1
- data/test/test_thread_pool.rb +3 -3
- data/vendor/liburing/.github/workflows/build.yml +51 -5
- data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
- data/vendor/liburing/.gitignore +6 -123
- data/vendor/liburing/CHANGELOG +35 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/LICENSE +16 -3
- data/vendor/liburing/Makefile +3 -1
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +14 -2
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +16 -15
- data/vendor/liburing/examples/Makefile +4 -1
- data/vendor/liburing/examples/io_uring-udp.c +395 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/send-zerocopy.c +339 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/man/io_uring.7 +38 -11
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
- data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
- data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
- data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
- data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
- data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
- data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
- data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
- data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
- data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
- data/vendor/liburing/man/io_uring_enter.2 +249 -32
- data/vendor/liburing/man/io_uring_enter2.2 +1 -0
- data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
- data/vendor/liburing/man/io_uring_get_events.3 +33 -0
- data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
- data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
- data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
- data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
- data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
- data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
- data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
- data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
- data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
- data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
- data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
- data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
- data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
- data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
- data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
- data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
- data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
- data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
- data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
- data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
- data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
- data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
- data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
- data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
- data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
- data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
- data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
- data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
- data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
- data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
- data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
- data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
- data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
- data/vendor/liburing/man/io_uring_register.2 +153 -13
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
- data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
- data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
- data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
- data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
- data/vendor/liburing/man/io_uring_register_files.3 +33 -11
- data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
- data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
- data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
- data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
- data/vendor/liburing/man/io_uring_setup.2 +119 -13
- data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
- data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
- data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
- data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
- data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
- data/vendor/liburing/man/io_uring_submit.3 +29 -12
- data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
- data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
- data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
- data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
- data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
- data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
- data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
- data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
- data/vendor/liburing/src/Makefile +8 -7
- data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
- data/vendor/liburing/src/arch/generic/lib.h +0 -4
- data/vendor/liburing/src/arch/generic/syscall.h +29 -16
- data/vendor/liburing/src/arch/syscall-defs.h +41 -14
- data/vendor/liburing/src/arch/x86/lib.h +0 -21
- data/vendor/liburing/src/arch/x86/syscall.h +146 -10
- data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
- data/vendor/liburing/src/include/liburing.h +468 -35
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +20 -16
- data/vendor/liburing/src/liburing.map +16 -0
- data/vendor/liburing/src/nolibc.c +1 -1
- data/vendor/liburing/src/queue.c +87 -55
- data/vendor/liburing/src/register.c +129 -53
- data/vendor/liburing/src/setup.c +65 -28
- data/vendor/liburing/src/syscall.c +14 -32
- data/vendor/liburing/src/syscall.h +12 -64
- data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
- data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
- data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
- data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
- data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
- data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
- data/vendor/liburing/test/Makefile +60 -62
- data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
- data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
- data/vendor/liburing/test/accept-link.c +5 -4
- data/vendor/liburing/test/accept-reuse.c +17 -16
- data/vendor/liburing/test/accept-test.c +14 -10
- data/vendor/liburing/test/accept.c +529 -107
- data/vendor/liburing/test/across-fork.c +7 -6
- data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
- data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
- data/vendor/liburing/test/buf-ring.c +420 -0
- data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
- data/vendor/liburing/test/connect.c +8 -7
- data/vendor/liburing/test/cq-full.c +5 -4
- data/vendor/liburing/test/cq-overflow.c +242 -12
- data/vendor/liburing/test/cq-peek-batch.c +5 -4
- data/vendor/liburing/test/cq-ready.c +5 -4
- data/vendor/liburing/test/cq-size.c +5 -4
- data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
- data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
- data/vendor/liburing/test/defer-taskrun.c +336 -0
- data/vendor/liburing/test/defer.c +26 -14
- data/vendor/liburing/test/double-poll-crash.c +15 -5
- data/vendor/liburing/test/drop-submit.c +5 -3
- data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
- data/vendor/liburing/test/empty-eownerdead.c +4 -4
- data/vendor/liburing/test/eventfd-disable.c +48 -20
- data/vendor/liburing/test/eventfd-reg.c +10 -9
- data/vendor/liburing/test/eventfd-ring.c +13 -12
- data/vendor/liburing/test/eventfd.c +13 -12
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +3 -3
- data/vendor/liburing/test/fallocate.c +16 -9
- data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
- data/vendor/liburing/test/fd-pass.c +187 -0
- data/vendor/liburing/test/file-register.c +302 -36
- data/vendor/liburing/test/file-update.c +62 -4
- data/vendor/liburing/test/file-verify.c +6 -2
- data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
- data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-link.c +10 -10
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +6 -3
- data/vendor/liburing/test/fsync.c +3 -3
- data/vendor/liburing/test/hardlink.c +10 -6
- data/vendor/liburing/test/helpers.c +137 -4
- data/vendor/liburing/test/helpers.h +27 -0
- data/vendor/liburing/test/io-cancel.c +16 -11
- data/vendor/liburing/test/io_uring_enter.c +46 -81
- data/vendor/liburing/test/io_uring_passthrough.c +451 -0
- data/vendor/liburing/test/io_uring_register.c +59 -229
- data/vendor/liburing/test/io_uring_setup.c +24 -29
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll.c +16 -9
- data/vendor/liburing/test/lfs-openat-write.c +3 -1
- data/vendor/liburing/test/link-timeout.c +4 -3
- data/vendor/liburing/test/link.c +8 -7
- data/vendor/liburing/test/madvise.c +2 -2
- data/vendor/liburing/test/mkdir.c +9 -5
- data/vendor/liburing/test/msg-ring.c +46 -20
- data/vendor/liburing/test/multicqes_drain.c +51 -12
- data/vendor/liburing/test/nolibc.c +60 -0
- data/vendor/liburing/test/nop.c +78 -16
- data/vendor/liburing/test/nvme.h +168 -0
- data/vendor/liburing/test/open-direct-link.c +188 -0
- data/vendor/liburing/test/open-direct-pick.c +180 -0
- data/vendor/liburing/test/openat2.c +3 -3
- data/vendor/liburing/test/poll-cancel-all.c +472 -0
- data/vendor/liburing/test/poll-link.c +9 -18
- data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
- data/vendor/liburing/test/poll-mshot-update.c +83 -33
- data/vendor/liburing/test/pollfree.c +2 -2
- data/vendor/liburing/test/read-before-exit.c +112 -0
- data/vendor/liburing/test/read-write.c +83 -1
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +265 -0
- data/vendor/liburing/test/recv-multishot.c +505 -0
- data/vendor/liburing/test/rename.c +2 -5
- data/vendor/liburing/test/ring-leak.c +97 -0
- data/vendor/liburing/test/ringbuf-read.c +200 -0
- data/vendor/liburing/test/rsrc_tags.c +25 -13
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +18 -20
- data/vendor/liburing/test/rw_merge_test.c +3 -2
- data/vendor/liburing/test/send-zerocopy.c +684 -0
- data/vendor/liburing/test/send_recv.c +49 -2
- data/vendor/liburing/test/send_recvmsg.c +165 -55
- data/vendor/liburing/test/shutdown.c +3 -4
- data/vendor/liburing/test/sigfd-deadlock.c +22 -8
- data/vendor/liburing/test/single-issuer.c +171 -0
- data/vendor/liburing/test/socket-rw-eagain.c +2 -12
- data/vendor/liburing/test/socket-rw-offset.c +2 -11
- data/vendor/liburing/test/socket-rw.c +2 -11
- data/vendor/liburing/test/socket.c +409 -0
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +1 -1
- data/vendor/liburing/test/statx.c +2 -2
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +5 -3
- data/vendor/liburing/test/submit-reuse.c +0 -2
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/test.h +35 -0
- data/vendor/liburing/test/timeout-overflow.c +11 -11
- data/vendor/liburing/test/timeout.c +7 -7
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/xattr.c +425 -0
- metadata +143 -22
- data/Gemfile.lock +0 -78
|
@@ -19,7 +19,7 @@ static char str[] = "This is a test of send and recv over io_uring!";
|
|
|
19
19
|
|
|
20
20
|
#define MAX_MSG 128
|
|
21
21
|
|
|
22
|
-
#define PORT
|
|
22
|
+
#define PORT 10202
|
|
23
23
|
#define HOST "127.0.0.1"
|
|
24
24
|
|
|
25
25
|
static int recv_prep(struct io_uring *ring, struct iovec *iov, int *sock,
|
|
@@ -254,7 +254,48 @@ static int test(int use_sqthread, int regfiles)
|
|
|
254
254
|
pthread_mutex_lock(&rd.mutex);
|
|
255
255
|
do_send();
|
|
256
256
|
pthread_join(recv_thread, &retval);
|
|
257
|
-
return (
|
|
257
|
+
return (intptr_t)retval;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
static int test_invalid(void)
|
|
261
|
+
{
|
|
262
|
+
struct io_uring ring;
|
|
263
|
+
int ret, i;
|
|
264
|
+
int fds[2];
|
|
265
|
+
struct io_uring_cqe *cqe;
|
|
266
|
+
struct io_uring_sqe *sqe;
|
|
267
|
+
|
|
268
|
+
ret = t_create_ring(8, &ring, 0);
|
|
269
|
+
if (ret)
|
|
270
|
+
return ret;
|
|
271
|
+
|
|
272
|
+
ret = t_create_socket_pair(fds, true);
|
|
273
|
+
if (ret)
|
|
274
|
+
return ret;
|
|
275
|
+
|
|
276
|
+
sqe = io_uring_get_sqe(&ring);
|
|
277
|
+
io_uring_prep_sendmsg(sqe, fds[0], NULL, MSG_WAITALL);
|
|
278
|
+
sqe->flags |= IOSQE_ASYNC;
|
|
279
|
+
|
|
280
|
+
sqe = io_uring_get_sqe(&ring);
|
|
281
|
+
io_uring_prep_recvmsg(sqe, fds[1], NULL, 0);
|
|
282
|
+
sqe->flags |= IOSQE_ASYNC;
|
|
283
|
+
|
|
284
|
+
ret = io_uring_submit_and_wait(&ring, 2);
|
|
285
|
+
if (ret != 2)
|
|
286
|
+
return ret;
|
|
287
|
+
|
|
288
|
+
for (i = 0; i < 2; i++) {
|
|
289
|
+
ret = io_uring_peek_cqe(&ring, &cqe);
|
|
290
|
+
if (ret || cqe->res != -EFAULT)
|
|
291
|
+
return -1;
|
|
292
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
io_uring_queue_exit(&ring);
|
|
296
|
+
close(fds[0]);
|
|
297
|
+
close(fds[1]);
|
|
298
|
+
return 0;
|
|
258
299
|
}
|
|
259
300
|
|
|
260
301
|
int main(int argc, char *argv[])
|
|
@@ -264,6 +305,12 @@ int main(int argc, char *argv[])
|
|
|
264
305
|
if (argc > 1)
|
|
265
306
|
return 0;
|
|
266
307
|
|
|
308
|
+
ret = test_invalid();
|
|
309
|
+
if (ret) {
|
|
310
|
+
fprintf(stderr, "test_invalid failed\n");
|
|
311
|
+
return ret;
|
|
312
|
+
}
|
|
313
|
+
|
|
267
314
|
ret = test(0, 0);
|
|
268
315
|
if (ret) {
|
|
269
316
|
fprintf(stderr, "test sqthread=0 failed\n");
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
|
|
18
18
|
static char str[] = "This is a test of sendmsg and recvmsg over io_uring!";
|
|
19
19
|
|
|
20
|
+
static int ud;
|
|
21
|
+
|
|
20
22
|
#define MAX_MSG 128
|
|
21
23
|
|
|
22
|
-
#define PORT
|
|
24
|
+
#define PORT 10203
|
|
23
25
|
#define HOST "127.0.0.1"
|
|
24
26
|
|
|
25
27
|
#define BUF_BGID 10
|
|
@@ -27,31 +29,32 @@ static char str[] = "This is a test of sendmsg and recvmsg over io_uring!";
|
|
|
27
29
|
|
|
28
30
|
#define MAX_IOV_COUNT 10
|
|
29
31
|
|
|
30
|
-
static int
|
|
31
|
-
|
|
32
|
+
static int no_pbuf_ring;
|
|
33
|
+
|
|
34
|
+
static int recv_prep(struct io_uring *ring, int *sockfd, struct iovec iov[],
|
|
35
|
+
int iov_count, int bgid, int async)
|
|
32
36
|
{
|
|
33
37
|
struct sockaddr_in saddr;
|
|
34
38
|
struct msghdr msg;
|
|
35
39
|
struct io_uring_sqe *sqe;
|
|
36
|
-
int
|
|
37
|
-
int val = 1;
|
|
40
|
+
int ret, val = 1;
|
|
38
41
|
|
|
39
42
|
memset(&saddr, 0, sizeof(saddr));
|
|
40
43
|
saddr.sin_family = AF_INET;
|
|
41
44
|
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
42
45
|
saddr.sin_port = htons(PORT);
|
|
43
46
|
|
|
44
|
-
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
45
|
-
if (sockfd < 0) {
|
|
47
|
+
*sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
48
|
+
if (*sockfd < 0) {
|
|
46
49
|
perror("socket");
|
|
47
50
|
return 1;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
val = 1;
|
|
51
|
-
setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
|
|
52
|
-
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
|
54
|
+
setsockopt(*sockfd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
|
|
55
|
+
setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
|
53
56
|
|
|
54
|
-
ret = bind(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
|
|
57
|
+
ret = bind(*sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
|
|
55
58
|
if (ret < 0) {
|
|
56
59
|
perror("bind");
|
|
57
60
|
goto err;
|
|
@@ -63,13 +66,16 @@ static int recv_prep(struct io_uring *ring, struct iovec iov[], int iov_count,
|
|
|
63
66
|
return 1;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
io_uring_prep_recvmsg(sqe, sockfd, &msg, 0);
|
|
69
|
+
io_uring_prep_recvmsg(sqe, *sockfd, &msg, 0);
|
|
67
70
|
if (bgid) {
|
|
68
71
|
iov->iov_base = NULL;
|
|
69
72
|
sqe->flags |= IOSQE_BUFFER_SELECT;
|
|
70
73
|
sqe->buf_group = bgid;
|
|
71
74
|
iov_count = 1;
|
|
72
75
|
}
|
|
76
|
+
sqe->user_data = ++ud;
|
|
77
|
+
if (async)
|
|
78
|
+
sqe->flags |= IOSQE_ASYNC;
|
|
73
79
|
memset(&msg, 0, sizeof(msg));
|
|
74
80
|
msg.msg_namelen = sizeof(struct sockaddr_in);
|
|
75
81
|
msg.msg_iov = iov;
|
|
@@ -81,18 +87,19 @@ static int recv_prep(struct io_uring *ring, struct iovec iov[], int iov_count,
|
|
|
81
87
|
goto err;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
close(sockfd);
|
|
85
90
|
return 0;
|
|
86
91
|
err:
|
|
87
|
-
close(sockfd);
|
|
92
|
+
close(*sockfd);
|
|
88
93
|
return 1;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
struct recv_data {
|
|
92
97
|
pthread_mutex_t *mutex;
|
|
93
98
|
int buf_select;
|
|
99
|
+
int buf_ring;
|
|
94
100
|
int no_buf_add;
|
|
95
101
|
int iov_count;
|
|
102
|
+
int async;
|
|
96
103
|
};
|
|
97
104
|
|
|
98
105
|
static int do_recvmsg(struct io_uring *ring, char buf[MAX_MSG + 1],
|
|
@@ -107,18 +114,18 @@ static int do_recvmsg(struct io_uring *ring, char buf[MAX_MSG + 1],
|
|
|
107
114
|
goto err;
|
|
108
115
|
}
|
|
109
116
|
if (cqe->res < 0) {
|
|
110
|
-
if (rd->no_buf_add && rd->buf_select)
|
|
117
|
+
if (rd->no_buf_add && (rd->buf_select || rd->buf_ring))
|
|
111
118
|
return 0;
|
|
112
119
|
fprintf(stderr, "%s: failed cqe: %d\n", __FUNCTION__, cqe->res);
|
|
113
120
|
goto err;
|
|
114
121
|
}
|
|
115
|
-
if (cqe->flags) {
|
|
122
|
+
if (cqe->flags & IORING_CQE_F_BUFFER) {
|
|
116
123
|
int bid = cqe->flags >> 16;
|
|
117
124
|
if (bid != BUF_BID)
|
|
118
125
|
fprintf(stderr, "Buffer ID mismatch %d\n", bid);
|
|
119
126
|
}
|
|
120
127
|
|
|
121
|
-
if (rd->no_buf_add && rd->buf_select) {
|
|
128
|
+
if (rd->no_buf_add && (rd->buf_ring || rd->buf_select)) {
|
|
122
129
|
fprintf(stderr, "Expected -ENOBUFS: %d\n", cqe->res);
|
|
123
130
|
goto err;
|
|
124
131
|
}
|
|
@@ -158,12 +165,14 @@ static void *recv_fn(void *data)
|
|
|
158
165
|
{
|
|
159
166
|
struct recv_data *rd = data;
|
|
160
167
|
pthread_mutex_t *mutex = rd->mutex;
|
|
168
|
+
struct io_uring_buf_ring *br = NULL;
|
|
161
169
|
char buf[MAX_MSG + 1];
|
|
162
170
|
struct iovec iov[MAX_IOV_COUNT];
|
|
163
|
-
struct io_uring_sqe *sqe;
|
|
164
|
-
struct io_uring_cqe *cqe;
|
|
165
171
|
struct io_uring ring;
|
|
166
|
-
int ret;
|
|
172
|
+
int ret, sockfd;
|
|
173
|
+
|
|
174
|
+
if (rd->buf_ring && no_pbuf_ring)
|
|
175
|
+
goto out_no_ring;
|
|
167
176
|
|
|
168
177
|
init_iov(iov, rd->iov_count, buf);
|
|
169
178
|
|
|
@@ -173,34 +182,61 @@ static void *recv_fn(void *data)
|
|
|
173
182
|
goto err;
|
|
174
183
|
}
|
|
175
184
|
|
|
176
|
-
if (rd->buf_select && !rd->no_buf_add) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
} else
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
if ((rd->buf_ring || rd->buf_select) && !rd->no_buf_add) {
|
|
186
|
+
if (rd->buf_ring) {
|
|
187
|
+
struct io_uring_buf_reg reg = { };
|
|
188
|
+
void *ptr;
|
|
189
|
+
|
|
190
|
+
if (posix_memalign(&ptr, 4096, 4096))
|
|
191
|
+
goto err;
|
|
192
|
+
|
|
193
|
+
reg.ring_addr = (unsigned long) ptr;
|
|
194
|
+
reg.ring_entries = 1;
|
|
195
|
+
reg.bgid = BUF_BGID;
|
|
196
|
+
if (io_uring_register_buf_ring(&ring, ®, 0)) {
|
|
197
|
+
no_pbuf_ring = 1;
|
|
198
|
+
goto out;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
br = ptr;
|
|
202
|
+
io_uring_buf_ring_init(br);
|
|
203
|
+
io_uring_buf_ring_add(br, buf, sizeof(buf), BUF_BID,
|
|
204
|
+
io_uring_buf_ring_mask(1), 0);
|
|
205
|
+
io_uring_buf_ring_advance(br, 1);
|
|
206
|
+
} else {
|
|
207
|
+
struct io_uring_sqe *sqe;
|
|
208
|
+
struct io_uring_cqe *cqe;
|
|
209
|
+
|
|
210
|
+
sqe = io_uring_get_sqe(&ring);
|
|
211
|
+
io_uring_prep_provide_buffers(sqe, buf, sizeof(buf) -1,
|
|
212
|
+
1, BUF_BGID, BUF_BID);
|
|
213
|
+
sqe->user_data = ++ud;
|
|
214
|
+
ret = io_uring_submit(&ring);
|
|
215
|
+
if (ret != 1) {
|
|
216
|
+
fprintf(stderr, "submit ret=%d\n", ret);
|
|
217
|
+
goto err;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
221
|
+
if (ret) {
|
|
222
|
+
fprintf(stderr, "wait_cqe=%d\n", ret);
|
|
223
|
+
goto err;
|
|
224
|
+
}
|
|
225
|
+
ret = cqe->res;
|
|
226
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
227
|
+
if (ret == -EINVAL) {
|
|
228
|
+
fprintf(stdout, "PROVIDE_BUFFERS not supported, skip\n");
|
|
229
|
+
goto out;
|
|
230
|
+
} else if (ret < 0) {
|
|
231
|
+
fprintf(stderr, "PROVIDER_BUFFERS %d\n", ret);
|
|
232
|
+
goto err;
|
|
233
|
+
}
|
|
200
234
|
}
|
|
201
235
|
}
|
|
202
236
|
|
|
203
|
-
ret = recv_prep(&ring, iov, rd->iov_count,
|
|
237
|
+
ret = recv_prep(&ring, &sockfd, iov, rd->iov_count,
|
|
238
|
+
(rd->buf_ring || rd->buf_select) ? BUF_BGID : 0,
|
|
239
|
+
rd->async);
|
|
204
240
|
if (ret) {
|
|
205
241
|
fprintf(stderr, "recv_prep failed: %d\n", ret);
|
|
206
242
|
goto err;
|
|
@@ -208,14 +244,19 @@ static void *recv_fn(void *data)
|
|
|
208
244
|
|
|
209
245
|
pthread_mutex_unlock(mutex);
|
|
210
246
|
ret = do_recvmsg(&ring, buf, rd);
|
|
247
|
+
close(sockfd);
|
|
211
248
|
|
|
212
249
|
io_uring_queue_exit(&ring);
|
|
213
|
-
|
|
250
|
+
if (br)
|
|
251
|
+
free(br);
|
|
214
252
|
err:
|
|
215
253
|
return (void *)(intptr_t)ret;
|
|
216
254
|
out:
|
|
217
|
-
pthread_mutex_unlock(mutex);
|
|
218
255
|
io_uring_queue_exit(&ring);
|
|
256
|
+
out_no_ring:
|
|
257
|
+
pthread_mutex_unlock(mutex);
|
|
258
|
+
if (br)
|
|
259
|
+
free(br);
|
|
219
260
|
return NULL;
|
|
220
261
|
}
|
|
221
262
|
|
|
@@ -255,8 +296,11 @@ static int do_sendmsg(void)
|
|
|
255
296
|
return 1;
|
|
256
297
|
}
|
|
257
298
|
|
|
299
|
+
usleep(10000);
|
|
300
|
+
|
|
258
301
|
sqe = io_uring_get_sqe(&ring);
|
|
259
302
|
io_uring_prep_sendmsg(sqe, sockfd, &msg, 0);
|
|
303
|
+
sqe->user_data = ++ud;
|
|
260
304
|
|
|
261
305
|
ret = io_uring_submit(&ring);
|
|
262
306
|
if (ret <= 0) {
|
|
@@ -277,7 +321,8 @@ err:
|
|
|
277
321
|
return 1;
|
|
278
322
|
}
|
|
279
323
|
|
|
280
|
-
static int test(int buf_select, int no_buf_add, int iov_count
|
|
324
|
+
static int test(int buf_select, int buf_ring, int no_buf_add, int iov_count,
|
|
325
|
+
int async)
|
|
281
326
|
{
|
|
282
327
|
struct recv_data rd;
|
|
283
328
|
pthread_mutexattr_t attr;
|
|
@@ -286,6 +331,9 @@ static int test(int buf_select, int no_buf_add, int iov_count)
|
|
|
286
331
|
int ret;
|
|
287
332
|
void *retval;
|
|
288
333
|
|
|
334
|
+
if (buf_select || buf_ring)
|
|
335
|
+
assert(iov_count == 1);
|
|
336
|
+
|
|
289
337
|
pthread_mutexattr_init(&attr);
|
|
290
338
|
pthread_mutexattr_setpshared(&attr, 1);
|
|
291
339
|
pthread_mutex_init(&mutex, &attr);
|
|
@@ -293,8 +341,10 @@ static int test(int buf_select, int no_buf_add, int iov_count)
|
|
|
293
341
|
|
|
294
342
|
rd.mutex = &mutex;
|
|
295
343
|
rd.buf_select = buf_select;
|
|
344
|
+
rd.buf_ring = buf_ring;
|
|
296
345
|
rd.no_buf_add = no_buf_add;
|
|
297
346
|
rd.iov_count = iov_count;
|
|
347
|
+
rd.async = async;
|
|
298
348
|
ret = pthread_create(&recv_thread, NULL, recv_fn, &rd);
|
|
299
349
|
if (ret) {
|
|
300
350
|
pthread_mutex_unlock(&mutex);
|
|
@@ -305,7 +355,7 @@ static int test(int buf_select, int no_buf_add, int iov_count)
|
|
|
305
355
|
pthread_mutex_lock(&mutex);
|
|
306
356
|
do_sendmsg();
|
|
307
357
|
pthread_join(recv_thread, &retval);
|
|
308
|
-
ret = (
|
|
358
|
+
ret = (intptr_t)retval;
|
|
309
359
|
|
|
310
360
|
return ret;
|
|
311
361
|
}
|
|
@@ -317,27 +367,87 @@ int main(int argc, char *argv[])
|
|
|
317
367
|
if (argc > 1)
|
|
318
368
|
return 0;
|
|
319
369
|
|
|
320
|
-
ret = test(0, 0, 1);
|
|
370
|
+
ret = test(0, 0, 0, 1, 0);
|
|
321
371
|
if (ret) {
|
|
322
|
-
fprintf(stderr, "send_recvmsg 0 failed\n");
|
|
372
|
+
fprintf(stderr, "send_recvmsg 0 0 0 1 0 failed\n");
|
|
323
373
|
return 1;
|
|
324
374
|
}
|
|
325
375
|
|
|
326
|
-
ret = test(0, 0, 10);
|
|
376
|
+
ret = test(0, 0, 0, 10, 0);
|
|
327
377
|
if (ret) {
|
|
328
378
|
fprintf(stderr, "send_recvmsg multi iov failed\n");
|
|
329
379
|
return 1;
|
|
330
380
|
}
|
|
331
381
|
|
|
332
|
-
ret = test(1, 0, 1);
|
|
382
|
+
ret = test(1, 0, 0, 1, 0);
|
|
383
|
+
if (ret) {
|
|
384
|
+
fprintf(stderr, "send_recvmsg 1 0 0 1 0 failed\n");
|
|
385
|
+
return 1;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
ret = test(1, 0, 1, 1, 0);
|
|
389
|
+
if (ret) {
|
|
390
|
+
fprintf(stderr, "send_recvmsg 1 0 1 1 0 failed\n");
|
|
391
|
+
return 1;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
ret = test(0, 1, 0, 1, 0);
|
|
395
|
+
if (ret) {
|
|
396
|
+
fprintf(stderr, "send_recvmsg 0 1 0 1 0 failed\n");
|
|
397
|
+
return 1;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
ret = test(1, 1, 0, 1, 0);
|
|
401
|
+
if (ret) {
|
|
402
|
+
fprintf(stderr, "send_recvmsg 1 1 0 1 0 failed\n");
|
|
403
|
+
return 1;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
ret = test(1, 1, 1, 1, 0);
|
|
407
|
+
if (ret) {
|
|
408
|
+
fprintf(stderr, "send_recvmsg 1 1 1 1 0 failed\n");
|
|
409
|
+
return 1;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
ret = test(0, 0, 0, 1, 1);
|
|
413
|
+
if (ret) {
|
|
414
|
+
fprintf(stderr, "send_recvmsg async 0 0 0 1 1 failed\n");
|
|
415
|
+
return 1;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
ret = test(0, 0, 0, 10, 1);
|
|
419
|
+
if (ret) {
|
|
420
|
+
fprintf(stderr, "send_recvmsg async multi iov failed\n");
|
|
421
|
+
return 1;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
ret = test(1, 0, 0, 1, 1);
|
|
425
|
+
if (ret) {
|
|
426
|
+
fprintf(stderr, "send_recvmsg async 1 0 0 1 1 failed\n");
|
|
427
|
+
return 1;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
ret = test(1, 0, 1, 1, 1);
|
|
431
|
+
if (ret) {
|
|
432
|
+
fprintf(stderr, "send_recvmsg async 1 0 1 1 1 failed\n");
|
|
433
|
+
return 1;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
ret = test(0, 1, 0, 1, 1);
|
|
437
|
+
if (ret) {
|
|
438
|
+
fprintf(stderr, "send_recvmsg async 0 1 0 1 1 failed\n");
|
|
439
|
+
return 1;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
ret = test(1, 1, 0, 1, 1);
|
|
333
443
|
if (ret) {
|
|
334
|
-
fprintf(stderr, "send_recvmsg 1 0 failed\n");
|
|
444
|
+
fprintf(stderr, "send_recvmsg async 1 1 0 1 1 failed\n");
|
|
335
445
|
return 1;
|
|
336
446
|
}
|
|
337
447
|
|
|
338
|
-
ret = test(1, 1, 1);
|
|
448
|
+
ret = test(1, 1, 1, 1, 1);
|
|
339
449
|
if (ret) {
|
|
340
|
-
fprintf(stderr, "send_recvmsg 1 1 failed\n");
|
|
450
|
+
fprintf(stderr, "send_recvmsg async 1 1 1 1 1 failed\n");
|
|
341
451
|
return 1;
|
|
342
452
|
}
|
|
343
453
|
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include <arpa/inet.h>
|
|
20
20
|
|
|
21
21
|
#include "liburing.h"
|
|
22
|
+
#include "helpers.h"
|
|
22
23
|
|
|
23
24
|
static void sig_pipe(int sig)
|
|
24
25
|
{
|
|
@@ -29,7 +30,7 @@ int main(int argc, char *argv[])
|
|
|
29
30
|
int p_fd[2], ret;
|
|
30
31
|
int32_t recv_s0;
|
|
31
32
|
int32_t val = 1;
|
|
32
|
-
struct sockaddr_in addr;
|
|
33
|
+
struct sockaddr_in addr = { };
|
|
33
34
|
|
|
34
35
|
if (argc > 1)
|
|
35
36
|
return 0;
|
|
@@ -44,11 +45,9 @@ int main(int argc, char *argv[])
|
|
|
44
45
|
assert(ret != -1);
|
|
45
46
|
|
|
46
47
|
addr.sin_family = AF_INET;
|
|
47
|
-
addr.sin_port = htons((rand() % 61440) + 4096);
|
|
48
48
|
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
assert(ret != -1);
|
|
50
|
+
assert(!t_bind_ephemeral_port(recv_s0, &addr));
|
|
52
51
|
ret = listen(recv_s0, 128);
|
|
53
52
|
assert(ret != -1);
|
|
54
53
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include <poll.h>
|
|
12
12
|
#include <stdio.h>
|
|
13
13
|
#include "liburing.h"
|
|
14
|
+
#include "helpers.h"
|
|
14
15
|
|
|
15
16
|
static int setup_signal(void)
|
|
16
17
|
{
|
|
@@ -34,22 +35,35 @@ static int test_uring(int sfd)
|
|
|
34
35
|
struct io_uring ring;
|
|
35
36
|
int ret;
|
|
36
37
|
|
|
37
|
-
io_uring_queue_init(32, &ring, 0);
|
|
38
|
+
ret = io_uring_queue_init(32, &ring, 0);
|
|
39
|
+
if (ret)
|
|
40
|
+
return T_EXIT_FAIL;
|
|
38
41
|
|
|
39
42
|
sqe = io_uring_get_sqe(&ring);
|
|
40
43
|
io_uring_prep_poll_add(sqe, sfd, POLLIN);
|
|
41
|
-
io_uring_submit(&ring);
|
|
44
|
+
ret = io_uring_submit(&ring);
|
|
45
|
+
if (ret < 0) {
|
|
46
|
+
ret = T_EXIT_FAIL;
|
|
47
|
+
goto err_exit;
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
kill(getpid(), SIGINT);
|
|
44
51
|
|
|
45
52
|
io_uring_wait_cqe(&ring, &cqe);
|
|
46
|
-
if (cqe->res
|
|
47
|
-
|
|
53
|
+
if (cqe->res == -EOPNOTSUPP) {
|
|
54
|
+
fprintf(stderr, "signalfd poll not supported\n");
|
|
55
|
+
ret = T_EXIT_SKIP;
|
|
56
|
+
} else if (cqe->res < 0) {
|
|
57
|
+
fprintf(stderr, "poll failed: %d\n", cqe->res);
|
|
58
|
+
ret = T_EXIT_FAIL;
|
|
59
|
+
} else if (cqe->res & POLLIN) {
|
|
60
|
+
ret = T_EXIT_PASS;
|
|
48
61
|
} else {
|
|
49
62
|
fprintf(stderr, "Unexpected poll mask %x\n", cqe->res);
|
|
50
|
-
ret =
|
|
63
|
+
ret = T_EXIT_FAIL;
|
|
51
64
|
}
|
|
52
65
|
io_uring_cqe_seen(&ring, cqe);
|
|
66
|
+
err_exit:
|
|
53
67
|
io_uring_queue_exit(&ring);
|
|
54
68
|
return ret;
|
|
55
69
|
}
|
|
@@ -59,14 +73,14 @@ int main(int argc, char *argv[])
|
|
|
59
73
|
int sfd, ret;
|
|
60
74
|
|
|
61
75
|
if (argc > 1)
|
|
62
|
-
return
|
|
76
|
+
return T_EXIT_PASS;
|
|
63
77
|
|
|
64
78
|
sfd = setup_signal();
|
|
65
79
|
if (sfd < 0)
|
|
66
|
-
return
|
|
80
|
+
return T_EXIT_FAIL;
|
|
67
81
|
|
|
68
82
|
ret = test_uring(sfd);
|
|
69
|
-
if (ret)
|
|
83
|
+
if (ret == T_EXIT_FAIL)
|
|
70
84
|
fprintf(stderr, "test_uring signalfd failed\n");
|
|
71
85
|
|
|
72
86
|
close(sfd);
|