Skip to content

Commit

Permalink
test/sqwait: cleanup allocated iovecs
Browse files Browse the repository at this point in the history
Be nice and reclaim the resources allocated.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Jan 23, 2025
1 parent 19134a8 commit 6c509e2
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions test/sqwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ int main(int argc, char *argv[])
}

fret = T_EXIT_SKIP;
for (i = 0; i < INFLIGHT; i++) {
if (posix_memalign(&iovs[i].iov_base, 4096, 4096))
goto err;
iovs[i].iov_len = 4096;
}

ret = io_uring_queue_init(8, &ring, IORING_SETUP_SQPOLL);
if (ret < 0) {
if (errno == EINVAL || errno == EPERM)
Expand All @@ -78,12 +84,6 @@ int main(int argc, char *argv[])
goto err;
}

for (i = 0; i < INFLIGHT; i++) {
if (posix_memalign(&iovs[i].iov_base, 4096, 4096))
goto err;
iovs[i].iov_len = 4096;
}

iov_off = off = 0;
for (i = 0; i < NR_IOS; i++) {
struct iovec *iov = &iovs[iov_off];
Expand Down Expand Up @@ -121,16 +121,14 @@ int main(int argc, char *argv[])
}
}

if (fd != -1)
close(fd);
if (fname != argv[1])
unlink(fname);
io_uring_queue_exit(&ring);
return T_EXIT_PASS;
fret = T_EXIT_PASS;
err:
if (fd != -1)
close(fd);
if (fname != argv[1])
unlink(fname);
for (i = 0; i < INFLIGHT; i++)
free(iovs[i].iov_base);
return fret;
}

0 comments on commit 6c509e2

Please sign in to comment.