@nxtedition/rocksdb 5.2.36 → 5.2.39
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.
- package/binding.cc +66 -91
- package/deps/liburing/liburing/COPYING +502 -0
- package/deps/liburing/liburing/COPYING.GPL +339 -0
- package/deps/liburing/liburing/LICENSE +7 -0
- package/deps/liburing/liburing/Makefile +84 -0
- package/deps/liburing/liburing/Makefile.quiet +11 -0
- package/deps/liburing/liburing/README +46 -0
- package/deps/liburing/liburing/configure +420 -0
- package/deps/liburing/liburing/debian/README.Debian +7 -0
- package/deps/liburing/liburing/debian/changelog +27 -0
- package/deps/liburing/liburing/debian/compat +1 -0
- package/deps/liburing/liburing/debian/control +48 -0
- package/deps/liburing/liburing/debian/copyright +49 -0
- package/deps/liburing/liburing/debian/liburing-dev.install +4 -0
- package/deps/liburing/liburing/debian/liburing-dev.manpages +6 -0
- package/deps/liburing/liburing/debian/liburing1-udeb.install +1 -0
- package/deps/liburing/liburing/debian/liburing1.install +1 -0
- package/deps/liburing/liburing/debian/liburing1.symbols +32 -0
- package/deps/liburing/liburing/debian/patches/series +1 -0
- package/deps/liburing/liburing/debian/rules +81 -0
- package/deps/liburing/liburing/debian/source/format +1 -0
- package/deps/liburing/liburing/debian/source/local-options +2 -0
- package/deps/liburing/liburing/debian/source/options +1 -0
- package/deps/liburing/liburing/debian/watch +3 -0
- package/deps/liburing/liburing/examples/Makefile +29 -0
- package/deps/liburing/liburing/examples/io_uring-cp.c +279 -0
- package/deps/liburing/liburing/examples/io_uring-test.c +112 -0
- package/deps/liburing/liburing/examples/link-cp.c +193 -0
- package/deps/liburing/liburing/examples/ucontext-cp.c +273 -0
- package/deps/liburing/liburing/liburing.pc.in +12 -0
- package/deps/liburing/liburing/liburing.spec +66 -0
- package/deps/liburing/liburing/make-debs.sh +53 -0
- package/deps/liburing/liburing/man/io_uring.7 +736 -0
- package/deps/liburing/liburing/man/io_uring_enter.2 +1403 -0
- package/deps/liburing/liburing/man/io_uring_get_sqe.3 +37 -0
- package/deps/liburing/liburing/man/io_uring_queue_exit.3 +27 -0
- package/deps/liburing/liburing/man/io_uring_queue_init.3 +44 -0
- package/deps/liburing/liburing/man/io_uring_register.2 +605 -0
- package/deps/liburing/liburing/man/io_uring_setup.2 +515 -0
- package/deps/liburing/liburing/src/Makefile +76 -0
- package/deps/liburing/liburing/src/include/liburing/barrier.h +73 -0
- package/deps/liburing/liburing/src/include/liburing/io_uring.h +422 -0
- package/deps/liburing/liburing/src/include/liburing.h +775 -0
- package/deps/liburing/liburing/src/liburing.map +46 -0
- package/deps/liburing/liburing/src/queue.c +403 -0
- package/deps/liburing/liburing/src/register.c +299 -0
- package/deps/liburing/liburing/src/setup.c +356 -0
- package/deps/liburing/liburing/src/syscall.c +73 -0
- package/deps/liburing/liburing/src/syscall.h +20 -0
- package/deps/liburing/liburing/test/232c93d07b74-test.c +305 -0
- package/deps/liburing/liburing/test/35fa71a030ca-test.c +329 -0
- package/deps/liburing/liburing/test/500f9fbadef8-test.c +89 -0
- package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +93 -0
- package/deps/liburing/liburing/test/8a9973408177-test.c +106 -0
- package/deps/liburing/liburing/test/917257daa0fe-test.c +53 -0
- package/deps/liburing/liburing/test/Makefile +312 -0
- package/deps/liburing/liburing/test/a0908ae19763-test.c +58 -0
- package/deps/liburing/liburing/test/a4c0b3decb33-test.c +180 -0
- package/deps/liburing/liburing/test/accept-link.c +251 -0
- package/deps/liburing/liburing/test/accept-reuse.c +164 -0
- package/deps/liburing/liburing/test/accept-test.c +79 -0
- package/deps/liburing/liburing/test/accept.c +476 -0
- package/deps/liburing/liburing/test/across-fork.c +283 -0
- package/deps/liburing/liburing/test/b19062a56726-test.c +53 -0
- package/deps/liburing/liburing/test/b5837bd5311d-test.c +77 -0
- package/deps/liburing/liburing/test/ce593a6c480a-test.c +135 -0
- package/deps/liburing/liburing/test/close-opath.c +122 -0
- package/deps/liburing/liburing/test/config +10 -0
- package/deps/liburing/liburing/test/connect.c +398 -0
- package/deps/liburing/liburing/test/cq-full.c +96 -0
- package/deps/liburing/liburing/test/cq-overflow.c +294 -0
- package/deps/liburing/liburing/test/cq-peek-batch.c +102 -0
- package/deps/liburing/liburing/test/cq-ready.c +94 -0
- package/deps/liburing/liburing/test/cq-size.c +58 -0
- package/deps/liburing/liburing/test/d4ae271dfaae-test.c +96 -0
- package/deps/liburing/liburing/test/d77a67ed5f27-test.c +65 -0
- package/deps/liburing/liburing/test/defer.c +307 -0
- package/deps/liburing/liburing/test/double-poll-crash.c +186 -0
- package/deps/liburing/liburing/test/eeed8b54e0df-test.c +114 -0
- package/deps/liburing/liburing/test/empty-eownerdead.c +42 -0
- package/deps/liburing/liburing/test/eventfd-disable.c +151 -0
- package/deps/liburing/liburing/test/eventfd-ring.c +97 -0
- package/deps/liburing/liburing/test/eventfd.c +112 -0
- package/deps/liburing/liburing/test/fadvise.c +202 -0
- package/deps/liburing/liburing/test/fallocate.c +249 -0
- package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +138 -0
- package/deps/liburing/liburing/test/file-register.c +843 -0
- package/deps/liburing/liburing/test/file-update.c +173 -0
- package/deps/liburing/liburing/test/files-exit-hang-poll.c +128 -0
- package/deps/liburing/liburing/test/files-exit-hang-timeout.c +134 -0
- package/deps/liburing/liburing/test/fixed-link.c +90 -0
- package/deps/liburing/liburing/test/fsync.c +224 -0
- package/deps/liburing/liburing/test/hardlink.c +136 -0
- package/deps/liburing/liburing/test/helpers.c +135 -0
- package/deps/liburing/liburing/test/helpers.h +67 -0
- package/deps/liburing/liburing/test/io-cancel.c +537 -0
- package/deps/liburing/liburing/test/io_uring_enter.c +296 -0
- package/deps/liburing/liburing/test/io_uring_register.c +664 -0
- package/deps/liburing/liburing/test/io_uring_setup.c +192 -0
- package/deps/liburing/liburing/test/iopoll.c +366 -0
- package/deps/liburing/liburing/test/lfs-openat-write.c +117 -0
- package/deps/liburing/liburing/test/lfs-openat.c +273 -0
- package/deps/liburing/liburing/test/link-timeout.c +1107 -0
- package/deps/liburing/liburing/test/link.c +496 -0
- package/deps/liburing/liburing/test/link_drain.c +229 -0
- package/deps/liburing/liburing/test/madvise.c +195 -0
- package/deps/liburing/liburing/test/mkdir.c +108 -0
- package/deps/liburing/liburing/test/multicqes_drain.c +383 -0
- package/deps/liburing/liburing/test/nop-all-sizes.c +107 -0
- package/deps/liburing/liburing/test/nop.c +115 -0
- package/deps/liburing/liburing/test/open-close.c +146 -0
- package/deps/liburing/liburing/test/openat2.c +240 -0
- package/deps/liburing/liburing/test/personality.c +204 -0
- package/deps/liburing/liburing/test/pipe-eof.c +81 -0
- package/deps/liburing/liburing/test/pipe-reuse.c +105 -0
- package/deps/liburing/liburing/test/poll-cancel-ton.c +139 -0
- package/deps/liburing/liburing/test/poll-cancel.c +135 -0
- package/deps/liburing/liburing/test/poll-link.c +227 -0
- package/deps/liburing/liburing/test/poll-many.c +208 -0
- package/deps/liburing/liburing/test/poll-mshot-update.c +273 -0
- package/deps/liburing/liburing/test/poll-ring.c +48 -0
- package/deps/liburing/liburing/test/poll-v-poll.c +353 -0
- package/deps/liburing/liburing/test/poll.c +109 -0
- package/deps/liburing/liburing/test/probe.c +137 -0
- package/deps/liburing/liburing/test/read-write.c +876 -0
- package/deps/liburing/liburing/test/register-restrictions.c +633 -0
- package/deps/liburing/liburing/test/rename.c +134 -0
- package/deps/liburing/liburing/test/ring-leak.c +173 -0
- package/deps/liburing/liburing/test/ring-leak2.c +249 -0
- package/deps/liburing/liburing/test/rsrc_tags.c +449 -0
- package/deps/liburing/liburing/test/runtests-loop.sh +16 -0
- package/deps/liburing/liburing/test/runtests.sh +170 -0
- package/deps/liburing/liburing/test/rw_merge_test.c +97 -0
- package/deps/liburing/liburing/test/self.c +91 -0
- package/deps/liburing/liburing/test/send_recv.c +291 -0
- package/deps/liburing/liburing/test/send_recvmsg.c +345 -0
- package/deps/liburing/liburing/test/sendmsg_fs_cve.c +198 -0
- package/deps/liburing/liburing/test/shared-wq.c +84 -0
- package/deps/liburing/liburing/test/short-read.c +75 -0
- package/deps/liburing/liburing/test/shutdown.c +163 -0
- package/deps/liburing/liburing/test/sigfd-deadlock.c +74 -0
- package/deps/liburing/liburing/test/socket-rw-eagain.c +156 -0
- package/deps/liburing/liburing/test/socket-rw.c +147 -0
- package/deps/liburing/liburing/test/splice.c +511 -0
- package/deps/liburing/liburing/test/sq-full-cpp.cc +45 -0
- package/deps/liburing/liburing/test/sq-full.c +45 -0
- package/deps/liburing/liburing/test/sq-poll-dup.c +200 -0
- package/deps/liburing/liburing/test/sq-poll-kthread.c +168 -0
- package/deps/liburing/liburing/test/sq-poll-share.c +137 -0
- package/deps/liburing/liburing/test/sq-space_left.c +159 -0
- package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +159 -0
- package/deps/liburing/liburing/test/sqpoll-disable-exit.c +195 -0
- package/deps/liburing/liburing/test/sqpoll-exit-hang.c +77 -0
- package/deps/liburing/liburing/test/sqpoll-sleep.c +68 -0
- package/deps/liburing/liburing/test/statx.c +172 -0
- package/deps/liburing/liburing/test/stdout.c +232 -0
- package/deps/liburing/liburing/test/submit-link-fail.c +154 -0
- package/deps/liburing/liburing/test/submit-reuse.c +239 -0
- package/deps/liburing/liburing/test/symlink.c +116 -0
- package/deps/liburing/liburing/test/teardowns.c +58 -0
- package/deps/liburing/liburing/test/thread-exit.c +131 -0
- package/deps/liburing/liburing/test/timeout-new.c +246 -0
- package/deps/liburing/liburing/test/timeout-overflow.c +204 -0
- package/deps/liburing/liburing/test/timeout.c +1354 -0
- package/deps/liburing/liburing/test/unlink.c +111 -0
- package/deps/liburing/liburing/test/wakeup-hang.c +162 -0
- package/deps/liburing/liburing.gyp +20 -0
- package/deps/rocksdb/rocksdb/db/corruption_test.cc +62 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +7 -62
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +25 -11
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +74 -155
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +1 -2
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +2 -2
- package/deps/rocksdb/rocksdb/env/fs_posix.cc +13 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +4 -2
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +22 -4
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +15 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -0
- package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +3 -7
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +2 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +44 -29
- package/deps/rocksdb/rocksdb.gyp +4 -3
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/prebuilds/linux-x64/node.napi.node +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Check that writev on a socket that has been shutdown(2) fails
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <stdlib.h>
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
#include <assert.h>
|
|
10
|
+
|
|
11
|
+
#include <errno.h>
|
|
12
|
+
#include <fcntl.h>
|
|
13
|
+
#include <unistd.h>
|
|
14
|
+
#include <sys/socket.h>
|
|
15
|
+
#include <sys/un.h>
|
|
16
|
+
#include <netinet/tcp.h>
|
|
17
|
+
#include <netinet/in.h>
|
|
18
|
+
|
|
19
|
+
#include "liburing.h"
|
|
20
|
+
|
|
21
|
+
static void sig_pipe(int sig)
|
|
22
|
+
{
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
int main(int argc, char *argv[])
|
|
26
|
+
{
|
|
27
|
+
int p_fd[2], ret;
|
|
28
|
+
int32_t recv_s0;
|
|
29
|
+
int32_t val = 1;
|
|
30
|
+
struct sockaddr_in addr;
|
|
31
|
+
|
|
32
|
+
if (argc > 1)
|
|
33
|
+
return 0;
|
|
34
|
+
|
|
35
|
+
srand(getpid());
|
|
36
|
+
|
|
37
|
+
recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
|
38
|
+
|
|
39
|
+
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
|
|
40
|
+
assert(ret != -1);
|
|
41
|
+
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
|
42
|
+
assert(ret != -1);
|
|
43
|
+
|
|
44
|
+
addr.sin_family = AF_INET;
|
|
45
|
+
addr.sin_port = (rand() % 61440) + 4096;
|
|
46
|
+
addr.sin_addr.s_addr = 0x0100007fU;
|
|
47
|
+
|
|
48
|
+
ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
|
|
49
|
+
assert(ret != -1);
|
|
50
|
+
ret = listen(recv_s0, 128);
|
|
51
|
+
assert(ret != -1);
|
|
52
|
+
|
|
53
|
+
p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
|
54
|
+
|
|
55
|
+
val = 1;
|
|
56
|
+
ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
|
|
57
|
+
assert(ret != -1);
|
|
58
|
+
|
|
59
|
+
int32_t flags = fcntl(p_fd[1], F_GETFL, 0);
|
|
60
|
+
assert(flags != -1);
|
|
61
|
+
|
|
62
|
+
flags |= O_NONBLOCK;
|
|
63
|
+
ret = fcntl(p_fd[1], F_SETFL, flags);
|
|
64
|
+
assert(ret != -1);
|
|
65
|
+
|
|
66
|
+
ret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));
|
|
67
|
+
assert(ret == -1);
|
|
68
|
+
|
|
69
|
+
flags = fcntl(p_fd[1], F_GETFL, 0);
|
|
70
|
+
assert(flags != -1);
|
|
71
|
+
|
|
72
|
+
flags &= ~O_NONBLOCK;
|
|
73
|
+
ret = fcntl(p_fd[1], F_SETFL, flags);
|
|
74
|
+
assert(ret != -1);
|
|
75
|
+
|
|
76
|
+
p_fd[0] = accept(recv_s0, NULL, NULL);
|
|
77
|
+
assert(p_fd[0] != -1);
|
|
78
|
+
|
|
79
|
+
signal(SIGPIPE, sig_pipe);
|
|
80
|
+
|
|
81
|
+
while (1) {
|
|
82
|
+
int32_t code;
|
|
83
|
+
socklen_t code_len = sizeof(code);
|
|
84
|
+
|
|
85
|
+
ret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);
|
|
86
|
+
assert(ret != -1);
|
|
87
|
+
|
|
88
|
+
if (!code)
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
struct io_uring m_io_uring;
|
|
93
|
+
|
|
94
|
+
ret = io_uring_queue_init(32, &m_io_uring, 0);
|
|
95
|
+
assert(ret >= 0);
|
|
96
|
+
|
|
97
|
+
{
|
|
98
|
+
struct io_uring_cqe *cqe;
|
|
99
|
+
struct io_uring_sqe *sqe;
|
|
100
|
+
int res;
|
|
101
|
+
|
|
102
|
+
sqe = io_uring_get_sqe(&m_io_uring);
|
|
103
|
+
io_uring_prep_shutdown(sqe, p_fd[1], SHUT_WR);
|
|
104
|
+
sqe->user_data = 1;
|
|
105
|
+
|
|
106
|
+
res = io_uring_submit_and_wait(&m_io_uring, 1);
|
|
107
|
+
assert(res != -1);
|
|
108
|
+
|
|
109
|
+
res = io_uring_wait_cqe(&m_io_uring, &cqe);
|
|
110
|
+
if (res < 0) {
|
|
111
|
+
fprintf(stderr, "wait: %s\n", strerror(-ret));
|
|
112
|
+
goto err;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (cqe->res) {
|
|
116
|
+
if (cqe->res == -EINVAL) {
|
|
117
|
+
fprintf(stdout, "Shutdown not supported, skipping\n");
|
|
118
|
+
goto done;
|
|
119
|
+
}
|
|
120
|
+
fprintf(stderr, "writev: %d\n", cqe->res);
|
|
121
|
+
goto err;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
io_uring_cqe_seen(&m_io_uring, cqe);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
{
|
|
128
|
+
struct io_uring_cqe *cqe;
|
|
129
|
+
struct io_uring_sqe *sqe;
|
|
130
|
+
struct iovec iov[1];
|
|
131
|
+
char send_buff[128];
|
|
132
|
+
int res;
|
|
133
|
+
|
|
134
|
+
iov[0].iov_base = send_buff;
|
|
135
|
+
iov[0].iov_len = sizeof(send_buff);
|
|
136
|
+
|
|
137
|
+
sqe = io_uring_get_sqe(&m_io_uring);
|
|
138
|
+
assert(sqe != NULL);
|
|
139
|
+
|
|
140
|
+
io_uring_prep_writev(sqe, p_fd[1], iov, 1, 0);
|
|
141
|
+
res = io_uring_submit_and_wait(&m_io_uring, 1);
|
|
142
|
+
assert(res != -1);
|
|
143
|
+
|
|
144
|
+
res = io_uring_wait_cqe(&m_io_uring, &cqe);
|
|
145
|
+
if (res < 0) {
|
|
146
|
+
fprintf(stderr, "wait: %s\n", strerror(-ret));
|
|
147
|
+
goto err;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (cqe->res != -EPIPE) {
|
|
151
|
+
fprintf(stderr, "writev: %d\n", cqe->res);
|
|
152
|
+
goto err;
|
|
153
|
+
}
|
|
154
|
+
io_uring_cqe_seen(&m_io_uring, cqe);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
done:
|
|
158
|
+
io_uring_queue_exit(&m_io_uring);
|
|
159
|
+
return 0;
|
|
160
|
+
err:
|
|
161
|
+
io_uring_queue_exit(&m_io_uring);
|
|
162
|
+
return 1;
|
|
163
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: test that sigfd reading/polling works. A regression test for
|
|
4
|
+
* the upstream commit:
|
|
5
|
+
*
|
|
6
|
+
* fd7d6de22414 ("io_uring: don't recurse on tsk->sighand->siglock with signalfd")
|
|
7
|
+
*/
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
#include <sys/signalfd.h>
|
|
10
|
+
#include <sys/epoll.h>
|
|
11
|
+
#include <sys/poll.h>
|
|
12
|
+
#include <stdio.h>
|
|
13
|
+
#include "liburing.h"
|
|
14
|
+
|
|
15
|
+
static int setup_signal(void)
|
|
16
|
+
{
|
|
17
|
+
sigset_t mask;
|
|
18
|
+
int sfd;
|
|
19
|
+
|
|
20
|
+
sigemptyset(&mask);
|
|
21
|
+
sigaddset(&mask, SIGINT);
|
|
22
|
+
|
|
23
|
+
sigprocmask(SIG_BLOCK, &mask, NULL);
|
|
24
|
+
sfd = signalfd(-1, &mask, SFD_NONBLOCK);
|
|
25
|
+
if (sfd < 0)
|
|
26
|
+
perror("signalfd");
|
|
27
|
+
return sfd;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static int test_uring(int sfd)
|
|
31
|
+
{
|
|
32
|
+
struct io_uring_sqe *sqe;
|
|
33
|
+
struct io_uring_cqe *cqe;
|
|
34
|
+
struct io_uring ring;
|
|
35
|
+
int ret;
|
|
36
|
+
|
|
37
|
+
io_uring_queue_init(32, &ring, 0);
|
|
38
|
+
|
|
39
|
+
sqe = io_uring_get_sqe(&ring);
|
|
40
|
+
io_uring_prep_poll_add(sqe, sfd, POLLIN);
|
|
41
|
+
io_uring_submit(&ring);
|
|
42
|
+
|
|
43
|
+
kill(getpid(), SIGINT);
|
|
44
|
+
|
|
45
|
+
io_uring_wait_cqe(&ring, &cqe);
|
|
46
|
+
if (cqe->res & POLLIN) {
|
|
47
|
+
ret = 0;
|
|
48
|
+
} else {
|
|
49
|
+
fprintf(stderr, "Unexpected poll mask %x\n", cqe->res);
|
|
50
|
+
ret = 1;
|
|
51
|
+
}
|
|
52
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
53
|
+
io_uring_queue_exit(&ring);
|
|
54
|
+
return ret;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
int main(int argc, char *argv[])
|
|
58
|
+
{
|
|
59
|
+
int sfd, ret;
|
|
60
|
+
|
|
61
|
+
if (argc > 1)
|
|
62
|
+
return 0;
|
|
63
|
+
|
|
64
|
+
sfd = setup_signal();
|
|
65
|
+
if (sfd < 0)
|
|
66
|
+
return 1;
|
|
67
|
+
|
|
68
|
+
ret = test_uring(sfd);
|
|
69
|
+
if (ret)
|
|
70
|
+
fprintf(stderr, "test_uring signalfd failed\n");
|
|
71
|
+
|
|
72
|
+
close(sfd);
|
|
73
|
+
return ret;
|
|
74
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Check that a readv on a nonblocking socket queued before a writev doesn't
|
|
4
|
+
* wait for data to arrive.
|
|
5
|
+
*/
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <stdlib.h>
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
#include <assert.h>
|
|
10
|
+
|
|
11
|
+
#include <errno.h>
|
|
12
|
+
#include <fcntl.h>
|
|
13
|
+
#include <unistd.h>
|
|
14
|
+
#include <sys/socket.h>
|
|
15
|
+
#include <sys/un.h>
|
|
16
|
+
#include <netinet/tcp.h>
|
|
17
|
+
#include <netinet/in.h>
|
|
18
|
+
|
|
19
|
+
#include "liburing.h"
|
|
20
|
+
|
|
21
|
+
int main(int argc, char *argv[])
|
|
22
|
+
{
|
|
23
|
+
int p_fd[2], ret;
|
|
24
|
+
int32_t recv_s0;
|
|
25
|
+
int32_t val = 1;
|
|
26
|
+
struct sockaddr_in addr;
|
|
27
|
+
|
|
28
|
+
if (argc > 1)
|
|
29
|
+
return 0;
|
|
30
|
+
|
|
31
|
+
srand(getpid());
|
|
32
|
+
|
|
33
|
+
recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
|
34
|
+
|
|
35
|
+
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
|
|
36
|
+
assert(ret != -1);
|
|
37
|
+
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
|
38
|
+
assert(ret != -1);
|
|
39
|
+
|
|
40
|
+
addr.sin_family = AF_INET;
|
|
41
|
+
addr.sin_addr.s_addr = 0x0100007fU;
|
|
42
|
+
|
|
43
|
+
do {
|
|
44
|
+
addr.sin_port = (rand() % 61440) + 4096;
|
|
45
|
+
ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
|
|
46
|
+
if (!ret)
|
|
47
|
+
break;
|
|
48
|
+
if (errno != EADDRINUSE) {
|
|
49
|
+
perror("bind");
|
|
50
|
+
exit(1);
|
|
51
|
+
}
|
|
52
|
+
} while (1);
|
|
53
|
+
|
|
54
|
+
ret = listen(recv_s0, 128);
|
|
55
|
+
assert(ret != -1);
|
|
56
|
+
|
|
57
|
+
p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
|
58
|
+
|
|
59
|
+
val = 1;
|
|
60
|
+
ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
|
|
61
|
+
assert(ret != -1);
|
|
62
|
+
|
|
63
|
+
int32_t flags = fcntl(p_fd[1], F_GETFL, 0);
|
|
64
|
+
assert(flags != -1);
|
|
65
|
+
|
|
66
|
+
flags |= O_NONBLOCK;
|
|
67
|
+
ret = fcntl(p_fd[1], F_SETFL, flags);
|
|
68
|
+
assert(ret != -1);
|
|
69
|
+
|
|
70
|
+
ret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));
|
|
71
|
+
assert(ret == -1);
|
|
72
|
+
|
|
73
|
+
p_fd[0] = accept(recv_s0, NULL, NULL);
|
|
74
|
+
assert(p_fd[0] != -1);
|
|
75
|
+
|
|
76
|
+
flags = fcntl(p_fd[0], F_GETFL, 0);
|
|
77
|
+
assert(flags != -1);
|
|
78
|
+
|
|
79
|
+
flags |= O_NONBLOCK;
|
|
80
|
+
ret = fcntl(p_fd[0], F_SETFL, flags);
|
|
81
|
+
assert(ret != -1);
|
|
82
|
+
|
|
83
|
+
while (1) {
|
|
84
|
+
int32_t code;
|
|
85
|
+
socklen_t code_len = sizeof(code);
|
|
86
|
+
|
|
87
|
+
ret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);
|
|
88
|
+
assert(ret != -1);
|
|
89
|
+
|
|
90
|
+
if (!code)
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
struct io_uring m_io_uring;
|
|
95
|
+
|
|
96
|
+
ret = io_uring_queue_init(32, &m_io_uring, 0);
|
|
97
|
+
assert(ret >= 0);
|
|
98
|
+
|
|
99
|
+
char recv_buff[128];
|
|
100
|
+
char send_buff[128];
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
struct iovec iov[1];
|
|
104
|
+
|
|
105
|
+
iov[0].iov_base = recv_buff;
|
|
106
|
+
iov[0].iov_len = sizeof(recv_buff);
|
|
107
|
+
|
|
108
|
+
struct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);
|
|
109
|
+
assert(sqe != NULL);
|
|
110
|
+
|
|
111
|
+
io_uring_prep_readv(sqe, p_fd[0], iov, 1, 0);
|
|
112
|
+
sqe->user_data = 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
struct iovec iov[1];
|
|
117
|
+
|
|
118
|
+
iov[0].iov_base = send_buff;
|
|
119
|
+
iov[0].iov_len = sizeof(send_buff);
|
|
120
|
+
|
|
121
|
+
struct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);
|
|
122
|
+
assert(sqe != NULL);
|
|
123
|
+
|
|
124
|
+
io_uring_prep_writev(sqe, p_fd[1], iov, 1, 0);
|
|
125
|
+
sqe->user_data = 2;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
ret = io_uring_submit_and_wait(&m_io_uring, 2);
|
|
129
|
+
assert(ret != -1);
|
|
130
|
+
|
|
131
|
+
struct io_uring_cqe* cqe;
|
|
132
|
+
uint32_t head;
|
|
133
|
+
uint32_t count = 0;
|
|
134
|
+
|
|
135
|
+
while (count != 2) {
|
|
136
|
+
io_uring_for_each_cqe(&m_io_uring, head, cqe) {
|
|
137
|
+
if (cqe->user_data == 2 && cqe->res != 128) {
|
|
138
|
+
fprintf(stderr, "write=%d\n", cqe->res);
|
|
139
|
+
goto err;
|
|
140
|
+
} else if (cqe->user_data == 1 && cqe->res != -EAGAIN) {
|
|
141
|
+
fprintf(stderr, "read=%d\n", cqe->res);
|
|
142
|
+
goto err;
|
|
143
|
+
}
|
|
144
|
+
count++;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
assert(count <= 2);
|
|
148
|
+
io_uring_cq_advance(&m_io_uring, count);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
io_uring_queue_exit(&m_io_uring);
|
|
152
|
+
return 0;
|
|
153
|
+
err:
|
|
154
|
+
io_uring_queue_exit(&m_io_uring);
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Check that a readv on a socket queued before a writev doesn't hang
|
|
4
|
+
* the processing.
|
|
5
|
+
*
|
|
6
|
+
* From Hrvoje Zeba <zeba.hrvoje@gmail.com>
|
|
7
|
+
*/
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
#include <assert.h>
|
|
12
|
+
|
|
13
|
+
#include <errno.h>
|
|
14
|
+
#include <fcntl.h>
|
|
15
|
+
#include <unistd.h>
|
|
16
|
+
#include <sys/socket.h>
|
|
17
|
+
#include <sys/un.h>
|
|
18
|
+
#include <netinet/tcp.h>
|
|
19
|
+
#include <netinet/in.h>
|
|
20
|
+
|
|
21
|
+
#include "liburing.h"
|
|
22
|
+
|
|
23
|
+
int main(int argc, char *argv[])
|
|
24
|
+
{
|
|
25
|
+
int p_fd[2], ret;
|
|
26
|
+
int32_t recv_s0;
|
|
27
|
+
int32_t val = 1;
|
|
28
|
+
struct sockaddr_in addr;
|
|
29
|
+
|
|
30
|
+
if (argc > 1)
|
|
31
|
+
return 0;
|
|
32
|
+
|
|
33
|
+
srand(getpid());
|
|
34
|
+
|
|
35
|
+
recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
|
36
|
+
|
|
37
|
+
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
|
|
38
|
+
assert(ret != -1);
|
|
39
|
+
ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
|
40
|
+
assert(ret != -1);
|
|
41
|
+
|
|
42
|
+
addr.sin_family = AF_INET;
|
|
43
|
+
addr.sin_addr.s_addr = 0x0100007fU;
|
|
44
|
+
|
|
45
|
+
do {
|
|
46
|
+
addr.sin_port = (rand() % 61440) + 4096;
|
|
47
|
+
ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
|
|
48
|
+
if (!ret)
|
|
49
|
+
break;
|
|
50
|
+
if (errno != EADDRINUSE) {
|
|
51
|
+
perror("bind");
|
|
52
|
+
exit(1);
|
|
53
|
+
}
|
|
54
|
+
} while (1);
|
|
55
|
+
ret = listen(recv_s0, 128);
|
|
56
|
+
assert(ret != -1);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
|
60
|
+
|
|
61
|
+
val = 1;
|
|
62
|
+
ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
|
|
63
|
+
assert(ret != -1);
|
|
64
|
+
|
|
65
|
+
int32_t flags = fcntl(p_fd[1], F_GETFL, 0);
|
|
66
|
+
assert(flags != -1);
|
|
67
|
+
|
|
68
|
+
flags |= O_NONBLOCK;
|
|
69
|
+
ret = fcntl(p_fd[1], F_SETFL, flags);
|
|
70
|
+
assert(ret != -1);
|
|
71
|
+
|
|
72
|
+
ret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));
|
|
73
|
+
assert(ret == -1);
|
|
74
|
+
|
|
75
|
+
flags = fcntl(p_fd[1], F_GETFL, 0);
|
|
76
|
+
assert(flags != -1);
|
|
77
|
+
|
|
78
|
+
flags &= ~O_NONBLOCK;
|
|
79
|
+
ret = fcntl(p_fd[1], F_SETFL, flags);
|
|
80
|
+
assert(ret != -1);
|
|
81
|
+
|
|
82
|
+
p_fd[0] = accept(recv_s0, NULL, NULL);
|
|
83
|
+
assert(p_fd[0] != -1);
|
|
84
|
+
|
|
85
|
+
while (1) {
|
|
86
|
+
int32_t code;
|
|
87
|
+
socklen_t code_len = sizeof(code);
|
|
88
|
+
|
|
89
|
+
ret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);
|
|
90
|
+
assert(ret != -1);
|
|
91
|
+
|
|
92
|
+
if (!code)
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
struct io_uring m_io_uring;
|
|
97
|
+
|
|
98
|
+
ret = io_uring_queue_init(32, &m_io_uring, 0);
|
|
99
|
+
assert(ret >= 0);
|
|
100
|
+
|
|
101
|
+
char recv_buff[128];
|
|
102
|
+
char send_buff[128];
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
struct iovec iov[1];
|
|
106
|
+
|
|
107
|
+
iov[0].iov_base = recv_buff;
|
|
108
|
+
iov[0].iov_len = sizeof(recv_buff);
|
|
109
|
+
|
|
110
|
+
struct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);
|
|
111
|
+
assert(sqe != NULL);
|
|
112
|
+
|
|
113
|
+
io_uring_prep_readv(sqe, p_fd[0], iov, 1, 0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
{
|
|
117
|
+
struct iovec iov[1];
|
|
118
|
+
|
|
119
|
+
iov[0].iov_base = send_buff;
|
|
120
|
+
iov[0].iov_len = sizeof(send_buff);
|
|
121
|
+
|
|
122
|
+
struct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);
|
|
123
|
+
assert(sqe != NULL);
|
|
124
|
+
|
|
125
|
+
io_uring_prep_writev(sqe, p_fd[1], iov, 1, 0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
ret = io_uring_submit_and_wait(&m_io_uring, 2);
|
|
129
|
+
assert(ret != -1);
|
|
130
|
+
|
|
131
|
+
struct io_uring_cqe* cqe;
|
|
132
|
+
uint32_t head;
|
|
133
|
+
uint32_t count = 0;
|
|
134
|
+
|
|
135
|
+
while (count != 2) {
|
|
136
|
+
io_uring_for_each_cqe(&m_io_uring, head, cqe) {
|
|
137
|
+
assert(cqe->res == 128);
|
|
138
|
+
count++;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
assert(count <= 2);
|
|
142
|
+
io_uring_cq_advance(&m_io_uring, count);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
io_uring_queue_exit(&m_io_uring);
|
|
146
|
+
return 0;
|
|
147
|
+
}
|