uringmachine 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +85 -0
- data/TODO.md +5 -0
- data/examples/echo_server.rb +18 -40
- data/examples/inout.rb +19 -0
- data/examples/nc.rb +36 -0
- data/ext/um/extconf.rb +6 -15
- data/ext/um/um.c +245 -53
- data/ext/um/um.h +21 -9
- data/ext/um/um_class.c +74 -87
- data/ext/um/um_const.c +184 -0
- data/ext/um/um_op.c +10 -13
- data/ext/um/um_utils.c +48 -3
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +12 -0
- data/test/helper.rb +8 -0
- data/test/test_um.rb +227 -7
- data/vendor/liburing/.github/workflows/build.yml +29 -1
- data/vendor/liburing/.gitignore +1 -0
- data/vendor/liburing/CHANGELOG +15 -0
- data/vendor/liburing/CONTRIBUTING.md +165 -0
- data/vendor/liburing/configure +32 -0
- data/vendor/liburing/examples/Makefile +8 -1
- data/vendor/liburing/examples/kdigest.c +405 -0
- data/vendor/liburing/examples/proxy.c +75 -8
- data/vendor/liburing/liburing.pc.in +1 -1
- data/vendor/liburing/src/Makefile +16 -2
- data/vendor/liburing/src/include/liburing/io_uring.h +31 -0
- data/vendor/liburing/src/include/liburing/sanitize.h +39 -0
- data/vendor/liburing/src/include/liburing.h +31 -4
- data/vendor/liburing/src/liburing-ffi.map +5 -0
- data/vendor/liburing/src/liburing.map +1 -0
- data/vendor/liburing/src/queue.c +3 -0
- data/vendor/liburing/src/register.c +36 -0
- data/vendor/liburing/src/sanitize.c +176 -0
- data/vendor/liburing/src/setup.c +1 -1
- data/vendor/liburing/test/35fa71a030ca.c +7 -0
- data/vendor/liburing/test/500f9fbadef8.c +2 -0
- data/vendor/liburing/test/7ad0e4b2f83c.c +0 -25
- data/vendor/liburing/test/917257daa0fe.c +7 -0
- data/vendor/liburing/test/Makefile +31 -4
- data/vendor/liburing/test/a0908ae19763.c +7 -0
- data/vendor/liburing/test/a4c0b3decb33.c +7 -0
- data/vendor/liburing/test/accept.c +14 -4
- data/vendor/liburing/test/b19062a56726.c +7 -0
- data/vendor/liburing/test/bind-listen.c +2 -2
- data/vendor/liburing/test/buf-ring-nommap.c +10 -3
- data/vendor/liburing/test/buf-ring.c +2 -0
- data/vendor/liburing/test/coredump.c +7 -0
- data/vendor/liburing/test/cq-overflow.c +13 -1
- data/vendor/liburing/test/d4ae271dfaae.c +11 -3
- data/vendor/liburing/test/defer-taskrun.c +2 -2
- data/vendor/liburing/test/defer-tw-timeout.c +4 -1
- data/vendor/liburing/test/defer.c +2 -2
- data/vendor/liburing/test/double-poll-crash.c +1 -1
- data/vendor/liburing/test/eeed8b54e0df.c +2 -0
- data/vendor/liburing/test/eventfd.c +0 -1
- data/vendor/liburing/test/exit-no-cleanup.c +11 -0
- data/vendor/liburing/test/fadvise.c +9 -26
- data/vendor/liburing/test/fdinfo.c +9 -1
- data/vendor/liburing/test/file-register.c +14 -2
- data/vendor/liburing/test/file-update.c +1 -1
- data/vendor/liburing/test/file-verify.c +27 -16
- data/vendor/liburing/test/files-exit-hang-timeout.c +1 -2
- data/vendor/liburing/test/fixed-buf-iter.c +3 -1
- data/vendor/liburing/test/fixed-hugepage.c +12 -1
- data/vendor/liburing/test/fsnotify.c +1 -0
- data/vendor/liburing/test/futex.c +16 -4
- data/vendor/liburing/test/helpers.c +47 -0
- data/vendor/liburing/test/helpers.h +6 -0
- data/vendor/liburing/test/init-mem.c +5 -3
- data/vendor/liburing/test/io-cancel.c +0 -24
- data/vendor/liburing/test/io_uring_passthrough.c +2 -0
- data/vendor/liburing/test/io_uring_register.c +25 -6
- data/vendor/liburing/test/iopoll-leak.c +4 -0
- data/vendor/liburing/test/iopoll-overflow.c +1 -1
- data/vendor/liburing/test/iopoll.c +3 -3
- data/vendor/liburing/test/kallsyms.c +203 -0
- data/vendor/liburing/test/link-timeout.c +159 -0
- data/vendor/liburing/test/linked-defer-close.c +224 -0
- data/vendor/liburing/test/madvise.c +12 -25
- data/vendor/liburing/test/min-timeout-wait.c +0 -25
- data/vendor/liburing/test/min-timeout.c +0 -25
- data/vendor/liburing/test/mkdir.c +6 -0
- data/vendor/liburing/test/msg-ring.c +8 -2
- data/vendor/liburing/test/napi-test.c +15 -2
- data/vendor/liburing/test/no-mmap-inval.c +2 -0
- data/vendor/liburing/test/nop.c +44 -0
- data/vendor/liburing/test/ooo-file-unreg.c +1 -1
- data/vendor/liburing/test/open-close.c +40 -0
- data/vendor/liburing/test/openat2.c +37 -14
- data/vendor/liburing/test/poll-many.c +13 -7
- data/vendor/liburing/test/poll-mshot-update.c +17 -10
- data/vendor/liburing/test/poll-v-poll.c +6 -3
- data/vendor/liburing/test/pollfree.c +148 -0
- data/vendor/liburing/test/read-mshot-empty.c +156 -153
- data/vendor/liburing/test/read-mshot.c +276 -27
- data/vendor/liburing/test/read-write.c +78 -13
- data/vendor/liburing/test/recv-msgall-stream.c +3 -0
- data/vendor/liburing/test/recv-msgall.c +5 -0
- data/vendor/liburing/test/recvsend_bundle-inc.c +680 -0
- data/vendor/liburing/test/recvsend_bundle.c +92 -29
- data/vendor/liburing/test/reg-fd-only.c +14 -4
- data/vendor/liburing/test/regbuf-clone.c +187 -0
- data/vendor/liburing/test/regbuf-merge.c +7 -0
- data/vendor/liburing/test/register-restrictions.c +86 -85
- data/vendor/liburing/test/rename.c +59 -1
- data/vendor/liburing/test/ringbuf-read.c +5 -0
- data/vendor/liburing/test/ringbuf-status.c +5 -1
- data/vendor/liburing/test/runtests.sh +16 -1
- data/vendor/liburing/test/send-zerocopy.c +59 -0
- data/vendor/liburing/test/short-read.c +1 -0
- data/vendor/liburing/test/socket.c +43 -0
- data/vendor/liburing/test/splice.c +3 -1
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +2 -0
- data/vendor/liburing/test/sqpoll-disable-exit.c +8 -0
- data/vendor/liburing/test/sqpoll-exit-hang.c +1 -25
- data/vendor/liburing/test/sqpoll-sleep.c +1 -25
- data/vendor/liburing/test/statx.c +89 -0
- data/vendor/liburing/test/stdout.c +2 -0
- data/vendor/liburing/test/submit-and-wait.c +1 -25
- data/vendor/liburing/test/submit-reuse.c +4 -26
- data/vendor/liburing/test/symlink.c +12 -1
- data/vendor/liburing/test/sync-cancel.c +48 -21
- data/vendor/liburing/test/thread-exit.c +5 -0
- data/vendor/liburing/test/timeout-new.c +1 -26
- data/vendor/liburing/test/timeout.c +12 -26
- data/vendor/liburing/test/unlink.c +94 -1
- data/vendor/liburing/test/uring_cmd_ublk.c +1252 -0
- data/vendor/liburing/test/waitid.c +62 -8
- data/vendor/liburing/test/wq-aff.c +35 -0
- data/vendor/liburing/test/xfail_prep_link_timeout_out_of_scope.c +46 -0
- data/vendor/liburing/test/xfail_register_buffers_out_of_scope.c +51 -0
- metadata +17 -4
- data/examples/event_loop.rb +0 -69
- data/examples/fibers.rb +0 -105
@@ -19,6 +19,39 @@ static void child(long usleep_time)
|
|
19
19
|
exit(0);
|
20
20
|
}
|
21
21
|
|
22
|
+
static int test_invalid_infop(struct io_uring *ring)
|
23
|
+
{
|
24
|
+
struct io_uring_sqe *sqe;
|
25
|
+
struct io_uring_cqe *cqe;
|
26
|
+
siginfo_t *si = (siginfo_t *) (uintptr_t) 0x1234;
|
27
|
+
int ret, w;
|
28
|
+
pid_t pid;
|
29
|
+
|
30
|
+
pid = fork();
|
31
|
+
if (!pid) {
|
32
|
+
child(200000);
|
33
|
+
exit(0);
|
34
|
+
}
|
35
|
+
|
36
|
+
sqe = io_uring_get_sqe(ring);
|
37
|
+
io_uring_prep_waitid(sqe, P_PID, pid, si, WEXITED, 0);
|
38
|
+
sqe->user_data = 1;
|
39
|
+
io_uring_submit(ring);
|
40
|
+
|
41
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
42
|
+
if (ret) {
|
43
|
+
fprintf(stderr, "cqe wait: %d\n", ret);
|
44
|
+
return T_EXIT_FAIL;
|
45
|
+
}
|
46
|
+
if (cqe->res != -EFAULT) {
|
47
|
+
fprintf(stderr, "Bad return on invalid infop: %d\n", cqe->res);
|
48
|
+
return T_EXIT_FAIL;
|
49
|
+
}
|
50
|
+
io_uring_cqe_seen(ring, cqe);
|
51
|
+
wait(&w);
|
52
|
+
return T_EXIT_PASS;
|
53
|
+
}
|
54
|
+
|
22
55
|
/*
|
23
56
|
* Test linked timeout with child not exiting in time
|
24
57
|
*/
|
@@ -27,9 +60,9 @@ static int test_noexit(struct io_uring *ring)
|
|
27
60
|
struct io_uring_sqe *sqe;
|
28
61
|
struct io_uring_cqe *cqe;
|
29
62
|
struct __kernel_timespec ts;
|
63
|
+
int ret, i, w;
|
30
64
|
siginfo_t si;
|
31
65
|
pid_t pid;
|
32
|
-
int ret, i;
|
33
66
|
|
34
67
|
pid = fork();
|
35
68
|
if (!pid) {
|
@@ -67,6 +100,7 @@ static int test_noexit(struct io_uring *ring)
|
|
67
100
|
io_uring_cqe_seen(ring, cqe);
|
68
101
|
}
|
69
102
|
|
103
|
+
wait(&w);
|
70
104
|
return T_EXIT_PASS;
|
71
105
|
}
|
72
106
|
|
@@ -79,7 +113,7 @@ static int test_double(struct io_uring *ring)
|
|
79
113
|
struct io_uring_cqe *cqe;
|
80
114
|
siginfo_t si;
|
81
115
|
pid_t p1, p2;
|
82
|
-
int ret;
|
116
|
+
int ret, w;
|
83
117
|
|
84
118
|
/* p1 will exit shortly */
|
85
119
|
p1 = fork();
|
@@ -116,6 +150,7 @@ static int test_double(struct io_uring *ring)
|
|
116
150
|
}
|
117
151
|
|
118
152
|
io_uring_cqe_seen(ring, cqe);
|
153
|
+
wait(&w);
|
119
154
|
return T_EXIT_PASS;
|
120
155
|
}
|
121
156
|
|
@@ -167,7 +202,7 @@ static int test_cancel(struct io_uring *ring)
|
|
167
202
|
{
|
168
203
|
struct io_uring_sqe *sqe;
|
169
204
|
struct io_uring_cqe *cqe;
|
170
|
-
int ret, i;
|
205
|
+
int ret, i, w;
|
171
206
|
pid_t pid;
|
172
207
|
|
173
208
|
pid = fork();
|
@@ -205,6 +240,7 @@ static int test_cancel(struct io_uring *ring)
|
|
205
240
|
io_uring_cqe_seen(ring, cqe);
|
206
241
|
}
|
207
242
|
|
243
|
+
wait(&w);
|
208
244
|
return T_EXIT_PASS;
|
209
245
|
}
|
210
246
|
|
@@ -216,10 +252,12 @@ static int test_cancel_race(struct io_uring *ring, int async)
|
|
216
252
|
{
|
217
253
|
struct io_uring_sqe *sqe;
|
218
254
|
struct io_uring_cqe *cqe;
|
219
|
-
int ret, i;
|
255
|
+
int ret, i, to_wait, total_forks;
|
220
256
|
pid_t pid;
|
221
257
|
|
258
|
+
total_forks = 0;
|
222
259
|
for (i = 0; i < 10; i++) {
|
260
|
+
total_forks++;
|
223
261
|
pid = fork();
|
224
262
|
if (!pid) {
|
225
263
|
child(getpid() & 1);
|
@@ -243,16 +281,20 @@ static int test_cancel_race(struct io_uring *ring, int async)
|
|
243
281
|
|
244
282
|
io_uring_submit(ring);
|
245
283
|
|
284
|
+
to_wait = total_forks;
|
246
285
|
for (i = 0; i < 2; i++) {
|
247
286
|
ret = io_uring_wait_cqe(ring, &cqe);
|
248
287
|
if (ret) {
|
249
288
|
fprintf(stderr, "cqe wait: %d\n", ret);
|
250
289
|
return T_EXIT_FAIL;
|
251
290
|
}
|
252
|
-
if (cqe->user_data == 1
|
253
|
-
|
254
|
-
|
255
|
-
|
291
|
+
if (cqe->user_data == 1) {
|
292
|
+
if (!cqe->res)
|
293
|
+
to_wait--;
|
294
|
+
if (!(cqe->res == -ECANCELED || cqe->res == 0)) {
|
295
|
+
fprintf(stderr, "cqe1 res: %d\n", cqe->res);
|
296
|
+
return T_EXIT_FAIL;
|
297
|
+
}
|
256
298
|
}
|
257
299
|
if (cqe->user_data == 2 &&
|
258
300
|
!(cqe->res == 1 || cqe->res == 0 || cqe->res == -ENOENT ||
|
@@ -263,6 +305,12 @@ static int test_cancel_race(struct io_uring *ring, int async)
|
|
263
305
|
io_uring_cqe_seen(ring, cqe);
|
264
306
|
}
|
265
307
|
|
308
|
+
for (i = 0; i < to_wait; i++) {
|
309
|
+
int w;
|
310
|
+
|
311
|
+
wait(&w);
|
312
|
+
}
|
313
|
+
|
266
314
|
return T_EXIT_PASS;
|
267
315
|
}
|
268
316
|
|
@@ -360,6 +408,12 @@ int main(int argc, char *argv[])
|
|
360
408
|
return T_EXIT_FAIL;
|
361
409
|
}
|
362
410
|
|
411
|
+
ret = test_invalid_infop(&ring);
|
412
|
+
if (ret == T_EXIT_FAIL) {
|
413
|
+
fprintf(stderr, "test_invalid_infop failed\n");
|
414
|
+
return T_EXIT_FAIL;
|
415
|
+
}
|
416
|
+
|
363
417
|
for (i = 0; i < 1000; i++) {
|
364
418
|
ret = test_cancel_race(&ring, i & 1);
|
365
419
|
if (ret == T_EXIT_FAIL) {
|
@@ -127,6 +127,33 @@ static int test(int sqpoll)
|
|
127
127
|
return ret;
|
128
128
|
}
|
129
129
|
|
130
|
+
static int test_invalid_cpu(void)
|
131
|
+
{
|
132
|
+
struct io_uring_params p = { };
|
133
|
+
struct io_uring ring;
|
134
|
+
int ret, nr_cpus;
|
135
|
+
|
136
|
+
nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
137
|
+
if (nr_cpus < 0) {
|
138
|
+
perror("sysconf(_SC_NPROCESSORS_ONLN");
|
139
|
+
return T_EXIT_SKIP;
|
140
|
+
}
|
141
|
+
|
142
|
+
p.flags = IORING_SETUP_SQPOLL | IORING_SETUP_SQ_AFF;
|
143
|
+
p.sq_thread_cpu = 16 * nr_cpus;
|
144
|
+
|
145
|
+
ret = io_uring_queue_init_params(8, &ring, &p);
|
146
|
+
if (ret == -EPERM) {
|
147
|
+
return T_EXIT_SKIP;
|
148
|
+
} else if (ret != -EINVAL) {
|
149
|
+
fprintf(stderr, "Queue init: %d\n", ret);
|
150
|
+
return T_EXIT_FAIL;
|
151
|
+
}
|
152
|
+
|
153
|
+
io_uring_queue_exit(&ring);
|
154
|
+
return T_EXIT_PASS;
|
155
|
+
}
|
156
|
+
|
130
157
|
int main(int argc, char *argv[])
|
131
158
|
{
|
132
159
|
int ret;
|
@@ -134,6 +161,14 @@ int main(int argc, char *argv[])
|
|
134
161
|
if (argc > 1)
|
135
162
|
return T_EXIT_SKIP;
|
136
163
|
|
164
|
+
ret = test_invalid_cpu();
|
165
|
+
if (ret == T_EXIT_SKIP) {
|
166
|
+
return T_EXIT_SKIP;
|
167
|
+
} else if (ret != T_EXIT_PASS) {
|
168
|
+
fprintf(stderr, "test sqpoll cpu failed\n");
|
169
|
+
return T_EXIT_FAIL;
|
170
|
+
}
|
171
|
+
|
137
172
|
ret = test(1);
|
138
173
|
if (ret == T_EXIT_SKIP) {
|
139
174
|
return T_EXIT_SKIP;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
2
|
+
/*
|
3
|
+
* Description: Check to see if the asan checks catch an stack-use-after-free for prep_link_timeout
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <errno.h>
|
8
|
+
#include <sys/socket.h>
|
9
|
+
#include <sys/un.h>
|
10
|
+
#include <assert.h>
|
11
|
+
#include "liburing.h"
|
12
|
+
#include "helpers.h"
|
13
|
+
|
14
|
+
#include <stdio.h>
|
15
|
+
|
16
|
+
int main(int argc, char *argv[])
|
17
|
+
{
|
18
|
+
struct io_uring ring;
|
19
|
+
struct io_uring_sqe *sqe;
|
20
|
+
int ret;
|
21
|
+
|
22
|
+
if (argc > 1)
|
23
|
+
return T_EXIT_SKIP;
|
24
|
+
|
25
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
26
|
+
if (ret < 0) {
|
27
|
+
printf("io_uring_queue_init ret %i\n", ret);
|
28
|
+
return T_EXIT_PASS; // this test expects an inverted exit code
|
29
|
+
}
|
30
|
+
|
31
|
+
// force timespec to go out of scope, test "passes" if asan catches this bug.
|
32
|
+
{
|
33
|
+
struct __kernel_timespec timespec;
|
34
|
+
timespec.tv_sec = 0;
|
35
|
+
timespec.tv_nsec = 5000;
|
36
|
+
|
37
|
+
sqe = io_uring_get_sqe(&ring);
|
38
|
+
io_uring_prep_timeout(sqe, ×pec, 0, 0);
|
39
|
+
io_uring_sqe_set_data(sqe, (void *) 1);
|
40
|
+
}
|
41
|
+
|
42
|
+
ret = io_uring_submit_and_wait(&ring, 1);
|
43
|
+
printf("submit_and_wait %i\n", ret);
|
44
|
+
|
45
|
+
return T_EXIT_PASS; // this test expects an inverted exit code
|
46
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
2
|
+
/*
|
3
|
+
* Description: Check to see if the asan checks catch an stack-use-after-free for io_uring_sqe_set_data
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <errno.h>
|
8
|
+
#include <sys/socket.h>
|
9
|
+
#include <sys/un.h>
|
10
|
+
#include <assert.h>
|
11
|
+
#include <stdlib.h>
|
12
|
+
#include "liburing.h"
|
13
|
+
#include "helpers.h"
|
14
|
+
|
15
|
+
#include <stdio.h>
|
16
|
+
|
17
|
+
#define BUFFERS 8
|
18
|
+
#define BUFFER_SIZE 128
|
19
|
+
|
20
|
+
int main(int argc, char *argv[])
|
21
|
+
{
|
22
|
+
struct io_uring ring;
|
23
|
+
struct iovec *iovs;
|
24
|
+
int i;
|
25
|
+
int ret;
|
26
|
+
|
27
|
+
if (argc > 1)
|
28
|
+
return T_EXIT_SKIP;
|
29
|
+
|
30
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
31
|
+
if (ret < 0) {
|
32
|
+
printf("io_uring_queue_init ret %i\n", ret);
|
33
|
+
return T_EXIT_PASS; // this test expects an inverted exit code
|
34
|
+
}
|
35
|
+
|
36
|
+
iovs = calloc(BUFFERS, sizeof(struct iovec));
|
37
|
+
for (i = 0; i < BUFFERS; i++) {
|
38
|
+
iovs[i].iov_base = malloc(BUFFER_SIZE);
|
39
|
+
iovs[i].iov_len = BUFFER_SIZE;
|
40
|
+
}
|
41
|
+
// force one iov_base to be freed, test "passes" if asan catches this bug.
|
42
|
+
free(iovs[4].iov_base);
|
43
|
+
|
44
|
+
ret = io_uring_register_buffers(&ring, iovs, BUFFERS);
|
45
|
+
printf("io_uring_register_buffers %i\n", ret);
|
46
|
+
|
47
|
+
ret = io_uring_submit_and_wait(&ring, 1);
|
48
|
+
printf("submit_and_wait %i\n", ret);
|
49
|
+
|
50
|
+
return T_EXIT_PASS; // this test expects an inverted exit code
|
51
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uringmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -85,15 +85,16 @@ files:
|
|
85
85
|
- Rakefile
|
86
86
|
- TODO.md
|
87
87
|
- examples/echo_server.rb
|
88
|
-
- examples/event_loop.rb
|
89
|
-
- examples/fibers.rb
|
90
88
|
- examples/http_server.rb
|
91
89
|
- examples/http_server_multishot.rb
|
92
90
|
- examples/http_server_simpler.rb
|
91
|
+
- examples/inout.rb
|
92
|
+
- examples/nc.rb
|
93
93
|
- ext/um/extconf.rb
|
94
94
|
- ext/um/um.c
|
95
95
|
- ext/um/um.h
|
96
96
|
- ext/um/um_class.c
|
97
|
+
- ext/um/um_const.c
|
97
98
|
- ext/um/um_ext.c
|
98
99
|
- ext/um/um_op.c
|
99
100
|
- ext/um/um_utils.c
|
@@ -110,6 +111,7 @@ files:
|
|
110
111
|
- vendor/liburing/.gitignore
|
111
112
|
- vendor/liburing/CHANGELOG
|
112
113
|
- vendor/liburing/CITATION.cff
|
114
|
+
- vendor/liburing/CONTRIBUTING.md
|
113
115
|
- vendor/liburing/COPYING
|
114
116
|
- vendor/liburing/COPYING.GPL
|
115
117
|
- vendor/liburing/LICENSE
|
@@ -140,6 +142,7 @@ files:
|
|
140
142
|
- vendor/liburing/examples/io_uring-cp.c
|
141
143
|
- vendor/liburing/examples/io_uring-test.c
|
142
144
|
- vendor/liburing/examples/io_uring-udp.c
|
145
|
+
- vendor/liburing/examples/kdigest.c
|
143
146
|
- vendor/liburing/examples/link-cp.c
|
144
147
|
- vendor/liburing/examples/napi-busy-poll-client.c
|
145
148
|
- vendor/liburing/examples/napi-busy-poll-server.c
|
@@ -167,6 +170,7 @@ files:
|
|
167
170
|
- vendor/liburing/src/include/liburing.h
|
168
171
|
- vendor/liburing/src/include/liburing/barrier.h
|
169
172
|
- vendor/liburing/src/include/liburing/io_uring.h
|
173
|
+
- vendor/liburing/src/include/liburing/sanitize.h
|
170
174
|
- vendor/liburing/src/int_flags.h
|
171
175
|
- vendor/liburing/src/lib.h
|
172
176
|
- vendor/liburing/src/liburing-ffi.map
|
@@ -174,6 +178,7 @@ files:
|
|
174
178
|
- vendor/liburing/src/nolibc.c
|
175
179
|
- vendor/liburing/src/queue.c
|
176
180
|
- vendor/liburing/src/register.c
|
181
|
+
- vendor/liburing/src/sanitize.c
|
177
182
|
- vendor/liburing/src/setup.c
|
178
183
|
- vendor/liburing/src/setup.h
|
179
184
|
- vendor/liburing/src/syscall.c
|
@@ -261,11 +266,13 @@ files:
|
|
261
266
|
- vendor/liburing/test/iopoll-leak.c
|
262
267
|
- vendor/liburing/test/iopoll-overflow.c
|
263
268
|
- vendor/liburing/test/iopoll.c
|
269
|
+
- vendor/liburing/test/kallsyms.c
|
264
270
|
- vendor/liburing/test/lfs-openat-write.c
|
265
271
|
- vendor/liburing/test/lfs-openat.c
|
266
272
|
- vendor/liburing/test/link-timeout.c
|
267
273
|
- vendor/liburing/test/link.c
|
268
274
|
- vendor/liburing/test/link_drain.c
|
275
|
+
- vendor/liburing/test/linked-defer-close.c
|
269
276
|
- vendor/liburing/test/madvise.c
|
270
277
|
- vendor/liburing/test/min-timeout-wait.c
|
271
278
|
- vendor/liburing/test/min-timeout.c
|
@@ -303,6 +310,7 @@ files:
|
|
303
310
|
- vendor/liburing/test/poll-ring.c
|
304
311
|
- vendor/liburing/test/poll-v-poll.c
|
305
312
|
- vendor/liburing/test/poll.c
|
313
|
+
- vendor/liburing/test/pollfree.c
|
306
314
|
- vendor/liburing/test/probe.c
|
307
315
|
- vendor/liburing/test/read-before-exit.c
|
308
316
|
- vendor/liburing/test/read-mshot-empty.c
|
@@ -311,10 +319,12 @@ files:
|
|
311
319
|
- vendor/liburing/test/recv-msgall-stream.c
|
312
320
|
- vendor/liburing/test/recv-msgall.c
|
313
321
|
- vendor/liburing/test/recv-multishot.c
|
322
|
+
- vendor/liburing/test/recvsend_bundle-inc.c
|
314
323
|
- vendor/liburing/test/recvsend_bundle.c
|
315
324
|
- vendor/liburing/test/reg-fd-only.c
|
316
325
|
- vendor/liburing/test/reg-hint.c
|
317
326
|
- vendor/liburing/test/reg-reg-ring.c
|
327
|
+
- vendor/liburing/test/regbuf-clone.c
|
318
328
|
- vendor/liburing/test/regbuf-merge.c
|
319
329
|
- vendor/liburing/test/register-restrictions.c
|
320
330
|
- vendor/liburing/test/rename.c
|
@@ -369,12 +379,15 @@ files:
|
|
369
379
|
- vendor/liburing/test/truncate.c
|
370
380
|
- vendor/liburing/test/tty-write-dpoll.c
|
371
381
|
- vendor/liburing/test/unlink.c
|
382
|
+
- vendor/liburing/test/uring_cmd_ublk.c
|
372
383
|
- vendor/liburing/test/version.c
|
373
384
|
- vendor/liburing/test/wait-timeout.c
|
374
385
|
- vendor/liburing/test/waitid.c
|
375
386
|
- vendor/liburing/test/wakeup-hang.c
|
376
387
|
- vendor/liburing/test/wq-aff.c
|
377
388
|
- vendor/liburing/test/xattr.c
|
389
|
+
- vendor/liburing/test/xfail_prep_link_timeout_out_of_scope.c
|
390
|
+
- vendor/liburing/test/xfail_register_buffers_out_of_scope.c
|
378
391
|
homepage: https://github.com/digital-fabric/uringmachine
|
379
392
|
licenses:
|
380
393
|
- MIT
|
data/examples/event_loop.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require_relative '../lib/iou'
|
2
|
-
require 'socket'
|
3
|
-
|
4
|
-
class IOUEventLoop
|
5
|
-
attr_reader :ring
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@ring = IOU::Ring.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def async_queue
|
12
|
-
@async_queue ||= []
|
13
|
-
end
|
14
|
-
|
15
|
-
def async(&block)
|
16
|
-
@async_queue << block
|
17
|
-
signal if @waiting
|
18
|
-
end
|
19
|
-
|
20
|
-
def signal
|
21
|
-
# generate an event to cause process_completions to return
|
22
|
-
ring.prep_nop
|
23
|
-
ring.submit
|
24
|
-
end
|
25
|
-
|
26
|
-
def run_async_tasks
|
27
|
-
pending = @async_queue
|
28
|
-
@async_queue = []
|
29
|
-
pending&.each(&:call)
|
30
|
-
end
|
31
|
-
|
32
|
-
def run
|
33
|
-
yield if block_given?
|
34
|
-
while !@stopped
|
35
|
-
run_async_tasks
|
36
|
-
@waiting = true
|
37
|
-
ring.process_completions
|
38
|
-
@waiting = false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def stop
|
43
|
-
@stopped = true
|
44
|
-
signal if @waiting
|
45
|
-
end
|
46
|
-
|
47
|
-
def timeout(delay, &block)
|
48
|
-
ring.prep_timeout(interval: delay, &block)
|
49
|
-
ring.submit
|
50
|
-
end
|
51
|
-
|
52
|
-
def interval(period, &block)
|
53
|
-
ring.prep_timeout(interval: period, multishot: true, &block)
|
54
|
-
ring.submit
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# exaple usage
|
59
|
-
event_loop = IOUEventLoop.new
|
60
|
-
|
61
|
-
trap('SIGINT') { event_loop.stop }
|
62
|
-
|
63
|
-
event_loop.run do
|
64
|
-
event_loop.interval(1) do
|
65
|
-
puts "The time is #{Time.now}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
puts "Stopped"
|
data/examples/fibers.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require_relative '../lib/iou'
|
2
|
-
require 'socket'
|
3
|
-
require 'fiber'
|
4
|
-
|
5
|
-
class ::Fiber
|
6
|
-
attr_accessor :__op_id
|
7
|
-
end
|
8
|
-
|
9
|
-
class Scheduler
|
10
|
-
class Cancel < Exception
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_reader :ring
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@ring = IOU::Ring.new
|
17
|
-
@runqueue = []
|
18
|
-
end
|
19
|
-
|
20
|
-
def switchpoint
|
21
|
-
while true
|
22
|
-
f, v = @runqueue.shift
|
23
|
-
if f
|
24
|
-
return f.transfer(v)
|
25
|
-
end
|
26
|
-
|
27
|
-
@ring.process_completions
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def fiber_wait(op_id)
|
32
|
-
Fiber.current.__op_id = op_id
|
33
|
-
v = switchpoint
|
34
|
-
Fiber.current.__op_id = nil
|
35
|
-
raise v if v.is_a?(Exception)
|
36
|
-
|
37
|
-
v
|
38
|
-
end
|
39
|
-
|
40
|
-
def read(**args)
|
41
|
-
f = Fiber.current
|
42
|
-
id = ring.prep_read(**args) do |c|
|
43
|
-
if c[:result] < 0
|
44
|
-
@runqueue << [f, RuntimeError.new('error')]
|
45
|
-
else
|
46
|
-
@runqueue << [f, c[:buffer]]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
fiber_wait(id)
|
50
|
-
end
|
51
|
-
|
52
|
-
def write(**args)
|
53
|
-
f = Fiber.current
|
54
|
-
id = ring.prep_write(**args) do |c|
|
55
|
-
if c[:result] < 0
|
56
|
-
@runqueue << [f, RuntimeError.new('error')]
|
57
|
-
else
|
58
|
-
@runqueue << [f, c[:result]]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
fiber_wait(id)
|
62
|
-
end
|
63
|
-
|
64
|
-
def sleep(interval)
|
65
|
-
f = Fiber.current
|
66
|
-
id = ring.prep_timeout(interval: interval) do |c|
|
67
|
-
if c[:result] == Errno::ECANCELED::Errno
|
68
|
-
@runqueue << [f, c[:result]]
|
69
|
-
else
|
70
|
-
@runqueue << [f, c[:result]]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
fiber_wait(id)
|
74
|
-
end
|
75
|
-
|
76
|
-
def cancel_fiber_op(f)
|
77
|
-
op_id = f.__op_id
|
78
|
-
if op_id
|
79
|
-
ring.prep_cancel(op_id)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def move_on_after(interval)
|
84
|
-
f = Fiber.current
|
85
|
-
cancel_id = ring.prep_timeout(interval: interval) do |c|
|
86
|
-
if c[:result] != Errno::ECANCELED::Errno
|
87
|
-
cancel_fiber_op(f)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
v = yield
|
91
|
-
ring.prep_cancel(cancel_id)
|
92
|
-
v
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
s = Scheduler.new
|
97
|
-
|
98
|
-
puts "Going to sleep..."
|
99
|
-
s.sleep 3
|
100
|
-
puts "Woke up"
|
101
|
-
|
102
|
-
s.move_on_after(1) do
|
103
|
-
puts "Going to sleep (move on after 1 second)"
|
104
|
-
s.sleep 3
|
105
|
-
end
|