summaryrefslogtreecommitdiff
path: root/src/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup.c')
-rw-r--r--src/setup.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/setup.c b/src/setup.c
index dda4d1c..a52071b 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -94,6 +94,22 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring
return ret;
}
+int io_uring_queue_init_params(unsigned entries, struct io_uring *ring,
+ struct io_uring_params *p)
+{
+ int fd, ret;
+
+ fd = io_uring_setup(entries, p);
+ if (fd < 0)
+ return -errno;
+
+ ret = io_uring_queue_mmap(fd, p, ring);
+ if (ret)
+ close(fd);
+
+ return ret;
+}
+
/*
* Returns -1 on error, or zero on success. On success, 'ring'
* contains the necessary information to read/write to the rings.
@@ -101,20 +117,11 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring
int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags)
{
struct io_uring_params p;
- int fd, ret;
memset(&p, 0, sizeof(p));
p.flags = flags;
- fd = io_uring_setup(entries, &p);
- if (fd < 0)
- return -errno;
-
- ret = io_uring_queue_mmap(fd, &p, ring);
- if (ret)
- close(fd);
-
- return ret;
+ return io_uring_queue_init_params(entries, ring, &p);
}
void io_uring_queue_exit(struct io_uring *ring)