make fellow_io_fini() idempotent

during error paths, we might call it multiple times
parent a378525e
...@@ -161,6 +161,9 @@ fellow_io_init(int fd, unsigned entries, void *base, size_t len, ...@@ -161,6 +161,9 @@ fellow_io_init(int fd, unsigned entries, void *base, size_t len,
void void
fellow_io_fini(fellow_ioctx_t **ctxp) fellow_io_fini(fellow_ioctx_t **ctxp)
{ {
if (*ctxp == NULL)
return;
unsigned entries = fellow_io_entries(*ctxp); unsigned entries = fellow_io_entries(*ctxp);
struct fellow_io_aio_ctx *ctx; struct fellow_io_aio_ctx *ctx;
......
...@@ -156,6 +156,9 @@ fellow_io_fini(fellow_ioctx_t **ctxp) ...@@ -156,6 +156,9 @@ fellow_io_fini(fellow_ioctx_t **ctxp)
{ {
struct fellow_io_thread *ctx; struct fellow_io_thread *ctx;
if (*ctxp == NULL)
return;
TAKE_OBJ_NOTNULL(ctx, (void **)ctxp, FELLOW_IO_THREAD_MAGIC); TAKE_OBJ_NOTNULL(ctx, (void **)ctxp, FELLOW_IO_THREAD_MAGIC);
struct fellow_io_status results[ctx->free->nbits]; struct fellow_io_status results[ctx->free->nbits];
......
...@@ -320,6 +320,9 @@ fellow_io_fini(fellow_ioctx_t **ctxp) ...@@ -320,6 +320,9 @@ fellow_io_fini(fellow_ioctx_t **ctxp)
{ {
struct fellow_io_uring *ctx; struct fellow_io_uring *ctx;
if (*ctxp == NULL)
return;
TAKE_OBJ_NOTNULL(ctx, (void **)ctxp, FELLOW_IO_URING_MAGIC); TAKE_OBJ_NOTNULL(ctx, (void **)ctxp, FELLOW_IO_URING_MAGIC);
struct fellow_io_status results[ctx->entries]; struct fellow_io_status results[ctx->entries];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment