uringmachine 0.24.0 → 0.26.0
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/.gitignore +1 -0
- data/.gitmodules +0 -3
- data/CHANGELOG.md +13 -0
- data/Gemfile +11 -0
- data/README.md +266 -112
- data/Rakefile +8 -0
- data/TODO.md +14 -21
- data/benchmark/common.rb +2 -0
- data/benchmark/openssl.rb +77 -0
- data/benchmark/openssl_socketpair.rb +112 -0
- data/benchmark/sqlite.rb +1 -1
- data/docs/design/buffer_pool.md +1 -1
- data/docs/wroclove.rb.md +52 -0
- data/ext/um/extconf.rb +15 -0
- data/ext/um/um.c +392 -358
- data/ext/um/um.h +48 -23
- data/ext/um/um_async_op.c +9 -8
- data/ext/um/um_async_op_class.c +34 -3
- data/ext/um/um_class.c +705 -19
- data/ext/um/um_const.c +31 -0
- data/ext/um/um_mutex_class.c +12 -0
- data/ext/um/um_op.c +15 -1
- data/ext/um/um_queue_class.c +16 -0
- data/ext/um/um_ssl.c +109 -0
- data/ext/um/um_stream.c +9 -8
- data/ext/um/um_sync.c +18 -11
- data/ext/um/um_utils.c +17 -8
- data/grant-2025/interim-report.md +1 -1
- data/grant-2025/journal.md +4 -4
- data/grant-2025/tasks.md +6 -4
- data/lib/uringmachine/dns_resolver.rb +38 -0
- data/lib/uringmachine/fiber_scheduler.rb +7 -5
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +106 -6
- data/test/helper.rb +15 -0
- data/test/test_async_op.rb +3 -2
- data/test/test_fiber_scheduler.rb +41 -1
- data/test/test_ssl.rb +85 -0
- data/test/test_stream.rb +11 -0
- data/test/test_um.rb +445 -11
- data/uringmachine.gemspec +1 -7
- data/vendor/liburing/examples/send-zerocopy.c +43 -31
- data/vendor/liburing/examples/zcrx.c +260 -69
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/src/include/liburing/io_uring.h +12 -0
- data/vendor/liburing/src/include/liburing.h +3 -2
- data/vendor/liburing/src/liburing-ffi.map +4 -0
- data/vendor/liburing/src/liburing.map +4 -0
- data/vendor/liburing/src/queue.c +12 -0
- data/vendor/liburing/src/register.c +1 -0
- data/vendor/liburing/src/setup.c +15 -7
- data/vendor/liburing/test/Makefile +8 -4
- data/vendor/liburing/test/conn-unreach.c +1 -1
- data/vendor/liburing/test/epwait.c +32 -6
- data/vendor/liburing/test/io-wq-exit.c +131 -0
- data/vendor/liburing/test/iowait.c +1 -1
- data/vendor/liburing/test/min-timeout.c +3 -1
- data/vendor/liburing/test/open-close.c +39 -0
- data/vendor/liburing/test/poll-update-trigger.c +85 -0
- data/vendor/liburing/test/recvsend_bundle.c +14 -11
- data/vendor/liburing/test/sendzc-bug.c +146 -0
- data/vendor/liburing/test/sqe-mixed-nop.c +151 -7
- data/vendor/liburing/test/test.h +2 -0
- data/vendor/liburing/test/timestamp-bug.c +135 -0
- data/vendor/liburing/test/timestamp.c +5 -0
- data/vendor/liburing/test/vec-regbuf.c +136 -1
- metadata +38 -283
- data/vendor/libressl/.github/scripts/changelog.sh +0 -74
- data/vendor/libressl/.github/workflows/android.yml +0 -35
- data/vendor/libressl/.github/workflows/cifuzz.yml +0 -33
- data/vendor/libressl/.github/workflows/cmake-config.yml +0 -98
- data/vendor/libressl/.github/workflows/coverity.yml +0 -69
- data/vendor/libressl/.github/workflows/emscripten.yml +0 -71
- data/vendor/libressl/.github/workflows/fedora-rawhide.yml +0 -39
- data/vendor/libressl/.github/workflows/freebsd.yml +0 -71
- data/vendor/libressl/.github/workflows/linux.yml +0 -71
- data/vendor/libressl/.github/workflows/macos.yml +0 -37
- data/vendor/libressl/.github/workflows/release.yml +0 -81
- data/vendor/libressl/.github/workflows/rust-openssl.yml +0 -47
- data/vendor/libressl/.github/workflows/solaris.yml +0 -37
- data/vendor/libressl/.github/workflows/windows.yml +0 -70
- data/vendor/libressl/.gitignore +0 -333
- data/vendor/libressl/CMakeLists.txt +0 -581
- data/vendor/libressl/COPYING +0 -133
- data/vendor/libressl/ChangeLog +0 -3280
- data/vendor/libressl/FindLibreSSL.cmake +0 -232
- data/vendor/libressl/LibreSSLConfig.cmake.in +0 -36
- data/vendor/libressl/Makefile.am +0 -60
- data/vendor/libressl/Makefile.am.common +0 -20
- data/vendor/libressl/OPENBSD_BRANCH +0 -1
- data/vendor/libressl/README.md +0 -238
- data/vendor/libressl/README.mingw.md +0 -43
- data/vendor/libressl/apps/CMakeLists.txt +0 -18
- data/vendor/libressl/apps/Makefile.am +0 -5
- data/vendor/libressl/apps/nc/CMakeLists.txt +0 -67
- data/vendor/libressl/apps/nc/Makefile.am +0 -64
- data/vendor/libressl/apps/nc/compat/accept4.c +0 -17
- data/vendor/libressl/apps/nc/compat/readpassphrase.c +0 -205
- data/vendor/libressl/apps/nc/compat/socket.c +0 -29
- data/vendor/libressl/apps/nc/compat/sys/socket.h +0 -30
- data/vendor/libressl/apps/ocspcheck/CMakeLists.txt +0 -44
- data/vendor/libressl/apps/ocspcheck/Makefile.am +0 -45
- data/vendor/libressl/apps/ocspcheck/compat/.gitignore +0 -0
- data/vendor/libressl/apps/openssl/CMakeLists.txt +0 -97
- data/vendor/libressl/apps/openssl/Makefile.am +0 -108
- data/vendor/libressl/apps/openssl/apps_win.c +0 -138
- data/vendor/libressl/apps/openssl/certhash_win.c +0 -13
- data/vendor/libressl/apps/openssl/compat/clock_gettime_osx.c +0 -26
- data/vendor/libressl/apps/openssl/compat/poll_win.c +0 -329
- data/vendor/libressl/appveyor.yml +0 -53
- data/vendor/libressl/autogen.sh +0 -15
- data/vendor/libressl/check-release.sh +0 -86
- data/vendor/libressl/cmake_export_symbol.cmake +0 -71
- data/vendor/libressl/cmake_uninstall.cmake.in +0 -36
- data/vendor/libressl/config +0 -17
- data/vendor/libressl/configure.ac +0 -165
- data/vendor/libressl/crypto/CMakeLists.txt +0 -863
- data/vendor/libressl/crypto/Makefile.am +0 -962
- data/vendor/libressl/crypto/Makefile.am.arc4random +0 -46
- data/vendor/libressl/crypto/Makefile.am.elf-mips +0 -14
- data/vendor/libressl/crypto/Makefile.am.elf-mips64 +0 -14
- data/vendor/libressl/crypto/Makefile.am.elf-x86_64 +0 -35
- data/vendor/libressl/crypto/Makefile.am.macosx-x86_64 +0 -35
- data/vendor/libressl/crypto/Makefile.am.masm-x86_64 +0 -22
- data/vendor/libressl/crypto/Makefile.am.mingw64-x86_64 +0 -23
- data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_darwin.c +0 -60
- data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_linux.c +0 -62
- data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_none.c +0 -26
- data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_windows.c +0 -36
- data/vendor/libressl/crypto/arch/loongarch64/crypto_arch.h +0 -21
- data/vendor/libressl/crypto/arch/mips/crypto_arch.h +0 -21
- data/vendor/libressl/crypto/bn/arch/loongarch64/bn_arch.h +0 -23
- data/vendor/libressl/crypto/bn/arch/mips/bn_arch.h +0 -24
- data/vendor/libressl/crypto/compat/.gitignore +0 -31
- data/vendor/libressl/crypto/compat/arc4random.h +0 -41
- data/vendor/libressl/crypto/compat/b_win.c +0 -55
- data/vendor/libressl/crypto/compat/bsd-asprintf.c +0 -96
- data/vendor/libressl/crypto/compat/crypto_lock_win.c +0 -56
- data/vendor/libressl/crypto/compat/explicit_bzero_win.c +0 -13
- data/vendor/libressl/crypto/compat/freezero.c +0 -32
- data/vendor/libressl/crypto/compat/getdelim.c +0 -78
- data/vendor/libressl/crypto/compat/getline.c +0 -40
- data/vendor/libressl/crypto/compat/getopt_long.c +0 -528
- data/vendor/libressl/crypto/compat/getpagesize.c +0 -18
- data/vendor/libressl/crypto/compat/getprogname_linux.c +0 -23
- data/vendor/libressl/crypto/compat/getprogname_unimpl.c +0 -7
- data/vendor/libressl/crypto/compat/getprogname_windows.c +0 -13
- data/vendor/libressl/crypto/compat/posix_win.c +0 -296
- data/vendor/libressl/crypto/compat/syslog_r.c +0 -19
- data/vendor/libressl/crypto/compat/ui_openssl_win.c +0 -334
- data/vendor/libressl/dist.sh +0 -22
- data/vendor/libressl/gen-coverage-report.sh +0 -58
- data/vendor/libressl/gen-openbsd-tags.sh +0 -20
- data/vendor/libressl/include/CMakeLists.txt +0 -61
- data/vendor/libressl/include/Makefile.am +0 -79
- data/vendor/libressl/include/arch/loongarch64/opensslconf.h +0 -150
- data/vendor/libressl/include/arch/mips/opensslconf.h +0 -150
- data/vendor/libressl/include/compat/arpa/inet.h +0 -15
- data/vendor/libressl/include/compat/arpa/nameser.h +0 -25
- data/vendor/libressl/include/compat/cet.h +0 -19
- data/vendor/libressl/include/compat/dirent.h +0 -17
- data/vendor/libressl/include/compat/dirent_msvc.h +0 -611
- data/vendor/libressl/include/compat/endian.h +0 -161
- data/vendor/libressl/include/compat/err.h +0 -95
- data/vendor/libressl/include/compat/fcntl.h +0 -32
- data/vendor/libressl/include/compat/getopt.h +0 -50
- data/vendor/libressl/include/compat/limits.h +0 -25
- data/vendor/libressl/include/compat/netdb.h +0 -10
- data/vendor/libressl/include/compat/netinet/in.h +0 -19
- data/vendor/libressl/include/compat/netinet/ip.h +0 -49
- data/vendor/libressl/include/compat/netinet/tcp.h +0 -10
- data/vendor/libressl/include/compat/poll.h +0 -63
- data/vendor/libressl/include/compat/pthread.h +0 -122
- data/vendor/libressl/include/compat/readpassphrase.h +0 -44
- data/vendor/libressl/include/compat/resolv.h +0 -24
- data/vendor/libressl/include/compat/stdint.h +0 -31
- data/vendor/libressl/include/compat/stdio.h +0 -65
- data/vendor/libressl/include/compat/stdlib.h +0 -57
- data/vendor/libressl/include/compat/string.h +0 -98
- data/vendor/libressl/include/compat/sys/_null.h +0 -18
- data/vendor/libressl/include/compat/sys/ioctl.h +0 -11
- data/vendor/libressl/include/compat/sys/mman.h +0 -19
- data/vendor/libressl/include/compat/sys/param.h +0 -15
- data/vendor/libressl/include/compat/sys/queue.h +0 -536
- data/vendor/libressl/include/compat/sys/select.h +0 -10
- data/vendor/libressl/include/compat/sys/socket.h +0 -18
- data/vendor/libressl/include/compat/sys/stat.h +0 -129
- data/vendor/libressl/include/compat/sys/time.h +0 -37
- data/vendor/libressl/include/compat/sys/tree.h +0 -1006
- data/vendor/libressl/include/compat/sys/types.h +0 -69
- data/vendor/libressl/include/compat/sys/uio.h +0 -17
- data/vendor/libressl/include/compat/syslog.h +0 -38
- data/vendor/libressl/include/compat/time.h +0 -59
- data/vendor/libressl/include/compat/unistd.h +0 -83
- data/vendor/libressl/include/compat/win32netcompat.h +0 -57
- data/vendor/libressl/include/openssl/Makefile.am.tpl +0 -45
- data/vendor/libressl/libcrypto.pc.in +0 -28
- data/vendor/libressl/libressl.pub +0 -2
- data/vendor/libressl/libssl.pc.in +0 -28
- data/vendor/libressl/libtls.pc.in +0 -28
- data/vendor/libressl/m4/ax_add_fortify_source.m4 +0 -80
- data/vendor/libressl/m4/ax_check_compile_flag.m4 +0 -53
- data/vendor/libressl/m4/check-hardening-options.m4 +0 -110
- data/vendor/libressl/m4/check-libc.m4 +0 -189
- data/vendor/libressl/m4/check-os-options.m4 +0 -181
- data/vendor/libressl/m4/disable-compiler-warnings.m4 +0 -44
- data/vendor/libressl/man/CMakeLists.txt +0 -26
- data/vendor/libressl/man/links +0 -2780
- data/vendor/libressl/man/update_links.sh +0 -25
- data/vendor/libressl/openssl.pc.in +0 -11
- data/vendor/libressl/patches/bn_shift.patch +0 -34
- data/vendor/libressl/patches/crypto_arch.h.patch +0 -34
- data/vendor/libressl/patches/crypto_namespace.h.patch +0 -22
- data/vendor/libressl/patches/netcat.c.patch +0 -178
- data/vendor/libressl/patches/openssl.c.patch +0 -12
- data/vendor/libressl/patches/opensslfeatures.h.patch +0 -49
- data/vendor/libressl/patches/patch-amd64-crypto-cpu-caps.c.patch +0 -20
- data/vendor/libressl/patches/patch-i386-crypto-cpu-caps.c.patch +0 -20
- data/vendor/libressl/patches/speed.c.patch +0 -114
- data/vendor/libressl/patches/ssl_namespace.h.patch +0 -21
- data/vendor/libressl/patches/tls.h.patch +0 -16
- data/vendor/libressl/patches/tls_config.c.patch +0 -15
- data/vendor/libressl/patches/win32_amd64_bn_arch.h.patch +0 -28
- data/vendor/libressl/patches/windows_headers.patch +0 -80
- data/vendor/libressl/scripts/config.guess +0 -1774
- data/vendor/libressl/scripts/config.sub +0 -1907
- data/vendor/libressl/scripts/i686-w64-mingw32.cmake +0 -9
- data/vendor/libressl/scripts/test +0 -210
- data/vendor/libressl/scripts/wrap-compiler-for-flag-check +0 -31
- data/vendor/libressl/scripts/x86_64-w64-mingw32.cmake +0 -9
- data/vendor/libressl/ssl/CMakeLists.txt +0 -183
- data/vendor/libressl/ssl/Makefile.am +0 -187
- data/vendor/libressl/tests/CMakeLists.txt +0 -970
- data/vendor/libressl/tests/Makefile.am +0 -944
- data/vendor/libressl/tests/aeadtest.sh +0 -30
- data/vendor/libressl/tests/arc4randomforktest.sh +0 -21
- data/vendor/libressl/tests/asn1time_small.test +0 -10
- data/vendor/libressl/tests/cmake/CMakeLists.txt +0 -52
- data/vendor/libressl/tests/cmake/crypto.c +0 -7
- data/vendor/libressl/tests/cmake/ssl.c +0 -6
- data/vendor/libressl/tests/cmake/tls.c +0 -6
- data/vendor/libressl/tests/compat/pipe2.c +0 -186
- data/vendor/libressl/tests/dtlstest.sh +0 -28
- data/vendor/libressl/tests/evptest.sh +0 -22
- data/vendor/libressl/tests/keypairtest.sh +0 -27
- data/vendor/libressl/tests/mlkem_tests.sh +0 -39
- data/vendor/libressl/tests/ocsptest.bat +0 -25
- data/vendor/libressl/tests/ocsptest.sh +0 -23
- data/vendor/libressl/tests/openssl.cnf +0 -29
- data/vendor/libressl/tests/optionstest.c +0 -381
- data/vendor/libressl/tests/pidwraptest.c +0 -85
- data/vendor/libressl/tests/pidwraptest.sh +0 -26
- data/vendor/libressl/tests/quictest.bat +0 -27
- data/vendor/libressl/tests/quictest.sh +0 -30
- data/vendor/libressl/tests/renegotiation_test.bat +0 -27
- data/vendor/libressl/tests/renegotiation_test.sh +0 -30
- data/vendor/libressl/tests/rfc5280time_small.test +0 -10
- data/vendor/libressl/tests/servertest.bat +0 -27
- data/vendor/libressl/tests/servertest.sh +0 -30
- data/vendor/libressl/tests/shutdowntest.bat +0 -27
- data/vendor/libressl/tests/shutdowntest.sh +0 -30
- data/vendor/libressl/tests/ssltest.bat +0 -32
- data/vendor/libressl/tests/ssltest.sh +0 -48
- data/vendor/libressl/tests/testdsa.bat +0 -47
- data/vendor/libressl/tests/testdsa.sh +0 -57
- data/vendor/libressl/tests/testenc.bat +0 -85
- data/vendor/libressl/tests/testenc.sh +0 -93
- data/vendor/libressl/tests/testrsa.bat +0 -47
- data/vendor/libressl/tests/testrsa.sh +0 -57
- data/vendor/libressl/tests/testssl.bat +0 -171
- data/vendor/libressl/tests/tlstest.bat +0 -27
- data/vendor/libressl/tests/tlstest.sh +0 -28
- data/vendor/libressl/tls/CMakeLists.txt +0 -125
- data/vendor/libressl/tls/Makefile.am +0 -76
- data/vendor/libressl/tls/compat/ftruncate.c +0 -17
- data/vendor/libressl/tls/compat/pread.c +0 -29
- data/vendor/libressl/tls/compat/pwrite.c +0 -29
- data/vendor/libressl/update.sh +0 -460
data/ext/um/um.h
CHANGED
|
@@ -73,20 +73,31 @@ enum um_op_kind {
|
|
|
73
73
|
OP_READ_MULTISHOT,
|
|
74
74
|
OP_RECV_MULTISHOT,
|
|
75
75
|
OP_TIMEOUT_MULTISHOT,
|
|
76
|
-
OP_SLEEP_MULTISHOT
|
|
77
76
|
};
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
#define
|
|
81
|
-
#define
|
|
82
|
-
#define
|
|
83
|
-
#define
|
|
84
|
-
#define OP_F_MULTISHOT
|
|
85
|
-
#define
|
|
86
|
-
#define
|
|
87
|
-
#define
|
|
88
|
-
#define
|
|
89
|
-
|
|
78
|
+
|
|
79
|
+
#define OP_F_CQE_SEEN (1U << 0) // CQE has been seen
|
|
80
|
+
#define OP_F_CQE_DONE (1U << 1) // CQE has been seen and operation is done
|
|
81
|
+
#define OP_F_SCHEDULED (1U << 2) // op is on runqueue
|
|
82
|
+
#define OP_F_CANCELED (1U << 3) // op is cancelled (disregard CQE results)
|
|
83
|
+
#define OP_F_MULTISHOT (1U << 4) // op is multishot
|
|
84
|
+
#define OP_F_ASYNC (1U << 5) // op is async (no fiber is scheduled to be resumed on completion)
|
|
85
|
+
#define OP_F_TRANSIENT (1U << 6) // op is on transient list (for GC purposes)
|
|
86
|
+
#define OP_F_FREE_IOVECS (1U << 7) // op->iovecs should be freed on release
|
|
87
|
+
#define OP_F_SKIP (1U << 8) // op should be skipped when pulled from runqueue
|
|
88
|
+
|
|
89
|
+
#define OP_F_SELECT_POLLIN (1U << 13) // select POLLIN
|
|
90
|
+
#define OP_F_SELECT_POLLOUT (1U << 14) // select POLLOUT
|
|
91
|
+
#define OP_F_SELECT_POLLPRI (1U << 15) // select POLLPRI
|
|
92
|
+
|
|
93
|
+
#define OP_CQE_SEEN_P(op) ((op)->flags & OP_F_CQE_SEEN)
|
|
94
|
+
#define OP_CQE_DONE_P(op) ((op)->flags & OP_F_CQE_DONE)
|
|
95
|
+
#define OP_SCHEDULED_P(op) ((op)->flags & OP_F_SCHEDULED)
|
|
96
|
+
#define OP_CANCELED_P(op) ((op)->flags & OP_F_CANCELED)
|
|
97
|
+
#define OP_MULTISHOT_P(op) ((op)->flags & OP_F_MULTISHOT)
|
|
98
|
+
#define OP_ASYNC_P(op) ((op)->flags & OP_F_ASYNC)
|
|
99
|
+
#define OP_TRANSIENT_P(op) ((op)->flags & OP_F_TRANSIENT)
|
|
100
|
+
#define OP_SKIP_P(op) ((op)->flags & OP_F_SKIP)
|
|
90
101
|
|
|
91
102
|
struct um_op_result {
|
|
92
103
|
__s32 res;
|
|
@@ -100,6 +111,7 @@ struct um_op {
|
|
|
100
111
|
|
|
101
112
|
enum um_op_kind kind;
|
|
102
113
|
uint flags;
|
|
114
|
+
uint ref_count;
|
|
103
115
|
|
|
104
116
|
VALUE fiber;
|
|
105
117
|
VALUE value;
|
|
@@ -109,7 +121,12 @@ struct um_op {
|
|
|
109
121
|
struct um_op_result *multishot_result_tail;
|
|
110
122
|
uint multishot_result_count;
|
|
111
123
|
|
|
112
|
-
|
|
124
|
+
union {
|
|
125
|
+
struct __kernel_timespec ts; // used for timeout operation
|
|
126
|
+
struct iovec *iovecs; // used for vectorized write/send
|
|
127
|
+
siginfo_t siginfo; // used for waitid
|
|
128
|
+
int int_value; // used for getsockopt
|
|
129
|
+
};
|
|
113
130
|
};
|
|
114
131
|
|
|
115
132
|
struct um_buffer {
|
|
@@ -170,7 +187,7 @@ struct um {
|
|
|
170
187
|
struct buf_ring_descriptor buffer_rings[BUFFER_RING_MAX_COUNT];
|
|
171
188
|
|
|
172
189
|
struct um_op *transient_head; // list of pending transient ops
|
|
173
|
-
VALUE pending_fibers; //
|
|
190
|
+
VALUE pending_fibers; // set containing pending fibers
|
|
174
191
|
|
|
175
192
|
struct um_op *runqueue_head;
|
|
176
193
|
struct um_op *runqueue_tail;
|
|
@@ -237,8 +254,12 @@ void um_teardown(struct um *machine);
|
|
|
237
254
|
VALUE um_metrics(struct um *machine, struct um_metrics *metrics);
|
|
238
255
|
|
|
239
256
|
const char * um_op_kind_name(enum um_op_kind kind);
|
|
240
|
-
|
|
241
|
-
|
|
257
|
+
|
|
258
|
+
struct um_op *um_op_acquire(struct um *machine);
|
|
259
|
+
void um_op_release(struct um *machine, struct um_op *op);
|
|
260
|
+
|
|
261
|
+
// struct um_op *um_op_alloc(struct um *machine);
|
|
262
|
+
// void um_op_free(struct um *machine, struct um_op *op);
|
|
242
263
|
void um_op_clear(struct um *machine, struct um_op *op);
|
|
243
264
|
void um_op_transient_add(struct um *machine, struct um_op *op);
|
|
244
265
|
void um_op_transient_remove(struct um *machine, struct um_op *op);
|
|
@@ -264,11 +285,11 @@ VALUE um_raise_exception(VALUE v);
|
|
|
264
285
|
|
|
265
286
|
#define RAISE_IF_EXCEPTION(v) if (unlikely(um_value_is_exception_p(v))) { um_raise_exception(v); }
|
|
266
287
|
|
|
267
|
-
void um_prep_op(struct um *machine, struct um_op *op, enum um_op_kind kind, unsigned flags);
|
|
288
|
+
void um_prep_op(struct um *machine, struct um_op *op, enum um_op_kind kind, uint ref_count, unsigned flags);
|
|
268
289
|
void um_raise_on_error_result(int result);
|
|
269
|
-
|
|
290
|
+
int um_get_buffer_bytes_for_writing(VALUE buffer, const void **base, size_t *size, int raise_on_bad_buffer);
|
|
270
291
|
void * um_prepare_read_buffer(VALUE buffer, ssize_t len, ssize_t ofs);
|
|
271
|
-
void um_update_read_buffer(
|
|
292
|
+
void um_update_read_buffer(VALUE buffer, ssize_t buffer_offset, __s32 result);
|
|
272
293
|
int um_setup_buffer_ring(struct um *machine, unsigned size, unsigned count);
|
|
273
294
|
VALUE um_get_string_from_buffer_ring(struct um *machine, int bgid, __s32 result, __u32 flags);
|
|
274
295
|
void um_add_strings_to_buffer_ring(struct um *machine, int bgid, VALUE strings);
|
|
@@ -283,10 +304,9 @@ VALUE um_yield(struct um *machine);
|
|
|
283
304
|
VALUE um_switch(struct um *machine);
|
|
284
305
|
VALUE um_wakeup(struct um *machine);
|
|
285
306
|
void um_cancel_op(struct um *machine, struct um_op *op);
|
|
286
|
-
void
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
#define um_op_completed_p(op) ((op)->flags & OP_F_COMPLETED)
|
|
307
|
+
void um_cancel_op_and_discard_cqe(struct um *machine, struct um_op *op);
|
|
308
|
+
void um_cancel_op_and_await_cqe(struct um *machine, struct um_op *op);
|
|
309
|
+
int um_verify_op_completion(struct um *machine, struct um_op *op, int await_cancelled);
|
|
290
310
|
|
|
291
311
|
void um_schedule(struct um *machine, VALUE fiber, VALUE value);
|
|
292
312
|
VALUE um_timeout(struct um *machine, VALUE interval, VALUE class);
|
|
@@ -297,6 +317,7 @@ VALUE um_read(struct um *machine, int fd, VALUE buffer, size_t maxlen, ssize_t b
|
|
|
297
317
|
size_t um_read_raw(struct um *machine, int fd, char *buffer, size_t maxlen);
|
|
298
318
|
VALUE um_read_each(struct um *machine, int fd, int bgid);
|
|
299
319
|
VALUE um_write(struct um *machine, int fd, VALUE buffer, size_t len, __u64 file_offset);
|
|
320
|
+
size_t um_write_raw(struct um *machine, int fd, const char *buffer, size_t maxlen);
|
|
300
321
|
VALUE um_writev(struct um *machine, int fd, int argc, VALUE *argv);
|
|
301
322
|
VALUE um_write_async(struct um *machine, int fd, VALUE buffer, size_t len, __u64 file_offset);
|
|
302
323
|
VALUE um_close(struct um *machine, int fd);
|
|
@@ -368,4 +389,8 @@ void um_sidecar_teardown(struct um *machine);
|
|
|
368
389
|
void um_sidecar_signal_wait(struct um *machine);
|
|
369
390
|
void um_sidecar_signal_wake(struct um *machine);
|
|
370
391
|
|
|
392
|
+
void um_ssl_set_bio(struct um *machine, VALUE ssl_obj);
|
|
393
|
+
int um_ssl_read(struct um *machine, VALUE ssl, VALUE buf, int maxlen);
|
|
394
|
+
int um_ssl_write(struct um *machine, VALUE ssl, VALUE buf, int len);
|
|
395
|
+
|
|
371
396
|
#endif // UM_H
|
data/ext/um/um_async_op.c
CHANGED
|
@@ -5,11 +5,11 @@ VALUE um_prep_timeout(struct um *machine, double interval) {
|
|
|
5
5
|
static ID ID_new = 0;
|
|
6
6
|
if (!ID_new) ID_new = rb_intern("new");
|
|
7
7
|
|
|
8
|
-
struct um_op *op =
|
|
9
|
-
um_prep_op(machine, op, OP_TIMEOUT,
|
|
8
|
+
struct um_op *op = um_op_acquire(machine);
|
|
9
|
+
um_prep_op(machine, op, OP_TIMEOUT, 2, OP_F_ASYNC | OP_F_TRANSIENT);
|
|
10
10
|
op->ts = um_double_to_timespec(interval);
|
|
11
11
|
|
|
12
|
-
VALUE obj = rb_funcall(cAsyncOp,
|
|
12
|
+
VALUE obj = rb_funcall(cAsyncOp, ID_new, 0);
|
|
13
13
|
um_async_op_set(obj, machine, op);
|
|
14
14
|
|
|
15
15
|
RB_OBJ_WRITE(machine->self, &op->async_op, obj);
|
|
@@ -17,18 +17,19 @@ VALUE um_prep_timeout(struct um *machine, double interval) {
|
|
|
17
17
|
struct io_uring_sqe *sqe = um_get_sqe(machine, op);
|
|
18
18
|
io_uring_prep_timeout(sqe, &op->ts, 0, 0);
|
|
19
19
|
|
|
20
|
-
um_op_transient_add(machine, op);
|
|
21
|
-
|
|
22
20
|
return obj;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
VALUE um_async_op_await(struct um_async_op *async_op) {
|
|
24
|
+
if (OP_CQE_DONE_P(async_op->op)) return async_op->op->value;
|
|
25
|
+
|
|
26
26
|
RB_OBJ_WRITE(async_op->machine->self, &async_op->op->fiber, rb_fiber_current());
|
|
27
|
-
async_op->op
|
|
27
|
+
um_op_transient_remove(async_op->machine, async_op->op);
|
|
28
|
+
async_op->op->flags &= ~(OP_F_ASYNC | OP_F_TRANSIENT);
|
|
28
29
|
|
|
29
30
|
VALUE ret = um_switch(async_op->machine);
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
um_verify_op_completion(async_op->machine, async_op->op, true);
|
|
32
33
|
|
|
33
34
|
RAISE_IF_EXCEPTION(ret);
|
|
34
35
|
RB_GC_GUARD(ret);
|
data/ext/um/um_async_op_class.c
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
#include "um.h"
|
|
2
2
|
#include <stdlib.h>
|
|
3
3
|
|
|
4
|
+
/*
|
|
5
|
+
* Document-class: UringMachine::AsyncOp
|
|
6
|
+
*
|
|
7
|
+
* Encapsulates an asynchronous operation. Currently the only asynchronous
|
|
8
|
+
* operation supported is a timeout operation.
|
|
9
|
+
*/
|
|
10
|
+
|
|
4
11
|
VALUE cAsyncOp;
|
|
5
12
|
|
|
6
13
|
VALUE SYM_timeout;
|
|
@@ -12,8 +19,8 @@ static void AsyncOp_mark(void *ptr) {
|
|
|
12
19
|
|
|
13
20
|
static void AsyncOp_free(void *ptr) {
|
|
14
21
|
struct um_async_op *async_op = ptr;
|
|
15
|
-
if (async_op->op)
|
|
16
|
-
|
|
22
|
+
if (likely(async_op->op))
|
|
23
|
+
um_op_release(async_op->machine, async_op->op);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
static const rb_data_type_t AsyncOp_type = {
|
|
@@ -56,9 +63,13 @@ inline void raise_on_missing_op(struct um_async_op *async_op) {
|
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
inline int async_op_is_done(struct um_async_op *async_op) {
|
|
59
|
-
return (async_op->op
|
|
66
|
+
return OP_CQE_DONE_P(async_op->op);
|
|
60
67
|
}
|
|
61
68
|
|
|
69
|
+
/* Returns the kind of asynchronous operation.
|
|
70
|
+
*
|
|
71
|
+
* @return [Symbol] operation kind
|
|
72
|
+
*/
|
|
62
73
|
VALUE AsyncOp_kind(VALUE self) {
|
|
63
74
|
struct um_async_op *async_op = AsyncOp_data(self);
|
|
64
75
|
raise_on_missing_op(async_op);
|
|
@@ -71,6 +82,10 @@ VALUE AsyncOp_kind(VALUE self) {
|
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
|
|
85
|
+
/* Returns true if the operation has completed.
|
|
86
|
+
*
|
|
87
|
+
* @return [bool] is the operation done
|
|
88
|
+
*/
|
|
74
89
|
VALUE AsyncOp_done_p(VALUE self) {
|
|
75
90
|
struct um_async_op *async_op = AsyncOp_data(self);
|
|
76
91
|
raise_on_missing_op(async_op);
|
|
@@ -78,6 +93,10 @@ VALUE AsyncOp_done_p(VALUE self) {
|
|
|
78
93
|
return async_op_is_done(async_op) ? Qtrue : Qfalse;
|
|
79
94
|
}
|
|
80
95
|
|
|
96
|
+
/* Returns the operation result. If the operation is not completed, returns nil.
|
|
97
|
+
*
|
|
98
|
+
* @return [Integer, nil] operation result
|
|
99
|
+
*/
|
|
81
100
|
VALUE AsyncOp_result(VALUE self) {
|
|
82
101
|
struct um_async_op *async_op = AsyncOp_data(self);
|
|
83
102
|
raise_on_missing_op(async_op);
|
|
@@ -85,6 +104,10 @@ VALUE AsyncOp_result(VALUE self) {
|
|
|
85
104
|
return async_op_is_done(async_op) ? INT2NUM(async_op->op->result.res) : Qnil;
|
|
86
105
|
}
|
|
87
106
|
|
|
107
|
+
/* Returns true if the operation has been cancelled.
|
|
108
|
+
*
|
|
109
|
+
* @return [bool] is the operation cancelled
|
|
110
|
+
*/
|
|
88
111
|
VALUE AsyncOp_cancelled_p(VALUE self) {
|
|
89
112
|
struct um_async_op *async_op = AsyncOp_data(self);
|
|
90
113
|
raise_on_missing_op(async_op);
|
|
@@ -94,6 +117,10 @@ VALUE AsyncOp_cancelled_p(VALUE self) {
|
|
|
94
117
|
return (async_op->op->result.res == -ECANCELED) ? Qtrue : Qfalse;
|
|
95
118
|
}
|
|
96
119
|
|
|
120
|
+
/* Waits for the operation to complete.
|
|
121
|
+
*
|
|
122
|
+
* @return [Integer] operation result
|
|
123
|
+
*/
|
|
97
124
|
VALUE AsyncOp_await(VALUE self) {
|
|
98
125
|
struct um_async_op *async_op = AsyncOp_data(self);
|
|
99
126
|
raise_on_missing_op(async_op);
|
|
@@ -104,6 +131,10 @@ VALUE AsyncOp_await(VALUE self) {
|
|
|
104
131
|
return um_async_op_await(async_op);
|
|
105
132
|
}
|
|
106
133
|
|
|
134
|
+
/* Cancels the operation.
|
|
135
|
+
*
|
|
136
|
+
* @return [UringMachine::AsyncOp] self
|
|
137
|
+
*/
|
|
107
138
|
VALUE AsyncOp_cancel(VALUE self) {
|
|
108
139
|
struct um_async_op *async_op = AsyncOp_data(self);
|
|
109
140
|
raise_on_missing_op(async_op);
|