summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-12-24 10:25:45 -0700
committerJens Axboe <axboe@kernel.dk>2019-12-24 10:25:45 -0700
commita80dabeabd108292166b1b70617f71badfab29e0 (patch)
treed9fb141aad2606c335b62847040221cbd287a4fa
parent34fa10bd109c8665f4e94e018686b330ae3ddf6d (diff)
downloadliburing-a80dabeabd108292166b1b70617f71badfab29e0.tar.gz
liburing-a80dabeabd108292166b1b70617f71badfab29e0.tar.bz2
test/accept: don't allocate send/recv data on the stack
We prep the sqe, but don't submit it. Hence we are at the mercy of the stack not going away, which it will. This ensures the data sent is sane. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/accept.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/accept.c b/test/accept.c
index edb7bc2..3de975f 100644
--- a/test/accept.c
+++ b/test/accept.c
@@ -21,30 +21,35 @@
static int no_accept;
+struct data {
+ char buf[128];
+ struct iovec iov;
+};
+
static void queue_send(struct io_uring *ring, int fd)
{
struct io_uring_sqe *sqe;
- char send_buff[128];
- struct iovec iov;
+ struct data *d;
- iov.iov_base = send_buff;
- iov.iov_len = sizeof(send_buff);
+ d = malloc(sizeof(*d));
+ d->iov.iov_base = d->buf;
+ d->iov.iov_len = sizeof(d->buf);
sqe = io_uring_get_sqe(ring);
- io_uring_prep_writev(sqe, fd, &iov, 1, 0);
+ io_uring_prep_writev(sqe, fd, &d->iov, 1, 0);
}
static void queue_recv(struct io_uring *ring, int fd)
{
struct io_uring_sqe *sqe;
- char recv_buff[128];
- struct iovec iov;
+ struct data *d;
- iov.iov_base = recv_buff;
- iov.iov_len = sizeof(recv_buff);
+ d = malloc(sizeof(*d));
+ d->iov.iov_base = d->buf;
+ d->iov.iov_len = sizeof(d->buf);
sqe = io_uring_get_sqe(ring);
- io_uring_prep_readv(sqe, fd, &iov, 1, 0);
+ io_uring_prep_readv(sqe, fd, &d->iov, 1, 0);
}
static int accept_conn(struct io_uring *ring, int fd)