uringmachine 0.3 → 0.4
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/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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include <unistd.h>
|
|
9
9
|
#include <pthread.h>
|
|
10
10
|
#include "liburing.h"
|
|
11
|
+
#include "helpers.h"
|
|
11
12
|
|
|
12
13
|
#define TIMEOUT_MSEC 200
|
|
13
14
|
#define TIMEOUT_SEC 10
|
|
@@ -22,32 +23,6 @@ static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
|
|
|
22
23
|
ts->tv_nsec = (msec % 1000) * 1000000;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
static unsigned long long mtime_since(const struct timeval *s,
|
|
26
|
-
const struct timeval *e)
|
|
27
|
-
{
|
|
28
|
-
long long sec, usec;
|
|
29
|
-
|
|
30
|
-
sec = e->tv_sec - s->tv_sec;
|
|
31
|
-
usec = (e->tv_usec - s->tv_usec);
|
|
32
|
-
if (sec > 0 && usec < 0) {
|
|
33
|
-
sec--;
|
|
34
|
-
usec += 1000000;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
sec *= 1000;
|
|
38
|
-
usec /= 1000;
|
|
39
|
-
return sec + usec;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
43
|
-
{
|
|
44
|
-
struct timeval end;
|
|
45
|
-
|
|
46
|
-
gettimeofday(&end, NULL);
|
|
47
|
-
return mtime_since(tv, &end);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
26
|
static int test_return_before_timeout(struct io_uring *ring)
|
|
52
27
|
{
|
|
53
28
|
struct io_uring_cqe *cqe;
|
|
@@ -29,31 +29,6 @@ static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
|
|
|
29
29
|
ts->tv_nsec = (msec % 1000) * 1000000;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
static unsigned long long mtime_since(const struct timeval *s,
|
|
33
|
-
const struct timeval *e)
|
|
34
|
-
{
|
|
35
|
-
long long sec, usec;
|
|
36
|
-
|
|
37
|
-
sec = e->tv_sec - s->tv_sec;
|
|
38
|
-
usec = (e->tv_usec - s->tv_usec);
|
|
39
|
-
if (sec > 0 && usec < 0) {
|
|
40
|
-
sec--;
|
|
41
|
-
usec += 1000000;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
sec *= 1000;
|
|
45
|
-
usec /= 1000;
|
|
46
|
-
return sec + usec;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
50
|
-
{
|
|
51
|
-
struct timeval end;
|
|
52
|
-
|
|
53
|
-
gettimeofday(&end, NULL);
|
|
54
|
-
return mtime_since(tv, &end);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
32
|
/*
|
|
58
33
|
* Test that we return to userspace if a timeout triggers, even if we
|
|
59
34
|
* don't satisfy the number of events asked for.
|
|
@@ -980,6 +955,7 @@ static int test_update_timeout(struct io_uring *ring, unsigned long ms,
|
|
|
980
955
|
struct io_uring_cqe *cqe;
|
|
981
956
|
struct __kernel_timespec ts, ts_upd;
|
|
982
957
|
unsigned long long exp_ms, base_ms = 10000;
|
|
958
|
+
bool update_ealready = false;
|
|
983
959
|
struct timeval tv;
|
|
984
960
|
int ret, i, nr = 2;
|
|
985
961
|
__u32 mode = abs ? IORING_TIMEOUT_ABS : 0;
|
|
@@ -1042,6 +1018,16 @@ static int test_update_timeout(struct io_uring *ring, unsigned long ms,
|
|
|
1042
1018
|
}
|
|
1043
1019
|
break;
|
|
1044
1020
|
case 2:
|
|
1021
|
+
/*
|
|
1022
|
+
* We should not be hitting this case, but for
|
|
1023
|
+
* a kernel with PREEMPT_RT, even an instant attempt
|
|
1024
|
+
* to remove a timer will return that the timer is
|
|
1025
|
+
* already running... Deal with it.
|
|
1026
|
+
*/
|
|
1027
|
+
if (cqe->res == -EALREADY) {
|
|
1028
|
+
update_ealready = true;
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1045
1031
|
if (cqe->res != 0) {
|
|
1046
1032
|
fprintf(stderr, "%s: got %d, wanted %d\n",
|
|
1047
1033
|
__FUNCTION__, cqe->res,
|
|
@@ -1062,7 +1048,7 @@ static int test_update_timeout(struct io_uring *ring, unsigned long ms,
|
|
|
1062
1048
|
}
|
|
1063
1049
|
|
|
1064
1050
|
exp_ms = mtime_since_now(&tv);
|
|
1065
|
-
if (exp_ms >= base_ms / 2) {
|
|
1051
|
+
if (!update_ealready && exp_ms >= base_ms / 2) {
|
|
1066
1052
|
fprintf(stderr, "too long, timeout wasn't updated\n");
|
|
1067
1053
|
goto err;
|
|
1068
1054
|
}
|
|
@@ -13,6 +13,87 @@
|
|
|
13
13
|
|
|
14
14
|
#include "liburing.h"
|
|
15
15
|
|
|
16
|
+
static int test_rmdir(struct io_uring *ring)
|
|
17
|
+
{
|
|
18
|
+
struct io_uring_cqe *cqe;
|
|
19
|
+
struct io_uring_sqe *sqe;
|
|
20
|
+
char buf[32];
|
|
21
|
+
int ret;
|
|
22
|
+
|
|
23
|
+
sprintf(buf, ".tmp.dir.%d", getpid());
|
|
24
|
+
if (mkdir(buf, 0755) < 0) {
|
|
25
|
+
perror("mkdir");
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
sqe = io_uring_get_sqe(ring);
|
|
30
|
+
if (!sqe) {
|
|
31
|
+
fprintf(stderr, "get sqe failed\n");
|
|
32
|
+
goto err;
|
|
33
|
+
}
|
|
34
|
+
io_uring_prep_unlink(sqe, buf, AT_REMOVEDIR);
|
|
35
|
+
|
|
36
|
+
ret = io_uring_submit(ring);
|
|
37
|
+
if (ret <= 0) {
|
|
38
|
+
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
39
|
+
goto err;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
43
|
+
if (ret < 0) {
|
|
44
|
+
fprintf(stderr, "wait completion %d\n", ret);
|
|
45
|
+
goto err;
|
|
46
|
+
}
|
|
47
|
+
ret = cqe->res;
|
|
48
|
+
io_uring_cqe_seen(ring, cqe);
|
|
49
|
+
|
|
50
|
+
if (!ret) {
|
|
51
|
+
struct stat sb;
|
|
52
|
+
|
|
53
|
+
if (!stat(buf, &sb)) {
|
|
54
|
+
fprintf(stderr, "dir unlinked but still there\n");
|
|
55
|
+
goto err;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
unlink(buf);
|
|
59
|
+
return ret;
|
|
60
|
+
err:
|
|
61
|
+
unlink(buf);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static int test_unlink_badaddr(struct io_uring *ring)
|
|
66
|
+
{
|
|
67
|
+
const char *old = (const char *) (uintptr_t) 0x1234;
|
|
68
|
+
struct io_uring_cqe *cqe;
|
|
69
|
+
struct io_uring_sqe *sqe;
|
|
70
|
+
int ret;
|
|
71
|
+
|
|
72
|
+
sqe = io_uring_get_sqe(ring);
|
|
73
|
+
if (!sqe) {
|
|
74
|
+
fprintf(stderr, "get sqe failed\n");
|
|
75
|
+
goto err;
|
|
76
|
+
}
|
|
77
|
+
io_uring_prep_unlink(sqe, old, 0);
|
|
78
|
+
|
|
79
|
+
ret = io_uring_submit(ring);
|
|
80
|
+
if (ret <= 0) {
|
|
81
|
+
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
82
|
+
goto err;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
86
|
+
if (ret < 0) {
|
|
87
|
+
fprintf(stderr, "wait completion %d\n", ret);
|
|
88
|
+
goto err;
|
|
89
|
+
}
|
|
90
|
+
ret = cqe->res;
|
|
91
|
+
io_uring_cqe_seen(ring, cqe);
|
|
92
|
+
return ret;
|
|
93
|
+
err:
|
|
94
|
+
return 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
16
97
|
static int test_unlink(struct io_uring *ring, const char *old)
|
|
17
98
|
{
|
|
18
99
|
struct io_uring_cqe *cqe;
|
|
@@ -25,7 +106,7 @@ static int test_unlink(struct io_uring *ring, const char *old)
|
|
|
25
106
|
goto err;
|
|
26
107
|
}
|
|
27
108
|
io_uring_prep_unlink(sqe, old, 0);
|
|
28
|
-
|
|
109
|
+
|
|
29
110
|
ret = io_uring_submit(ring);
|
|
30
111
|
if (ret <= 0) {
|
|
31
112
|
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
@@ -105,6 +186,18 @@ int main(int argc, char *argv[])
|
|
|
105
186
|
return 1;
|
|
106
187
|
}
|
|
107
188
|
|
|
189
|
+
ret = test_unlink_badaddr(&ring);
|
|
190
|
+
if (ret != -EFAULT) {
|
|
191
|
+
fprintf(stderr, "badaddr unlink got %s\n", strerror(-ret));
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
ret = test_rmdir(&ring);
|
|
196
|
+
if (ret) {
|
|
197
|
+
fprintf(stderr, "rmdir failed: %s\n", strerror(-ret));
|
|
198
|
+
return 1;
|
|
199
|
+
}
|
|
200
|
+
|
|
108
201
|
return 0;
|
|
109
202
|
err:
|
|
110
203
|
unlink(buf);
|