Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: Coldwings <coldwings@me.com>
  • Loading branch information
Coldwings committed Jan 16, 2024
1 parent 2f55e06 commit be04c36
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions io/aio-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ namespace photon
if (!libaio_ctx)
return 0;
LOG_INFO("reset libaio by reset handle");
auto iodepth = libaio_ctx->iodepth;
close(libaio_ctx->evfd);
libaio_ctx->evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
if (libaio_ctx->evfd < 0) {
Expand All @@ -356,8 +355,7 @@ namespace photon
}
io_destroy(libaio_ctx->aio_ctx);
libaio_ctx->aio_ctx = {0};
int ret = io_setup(iodepth < IODEPTH_MAX ? iodepth : IODEPTH_MAX,
&libaio_ctx->aio_ctx);
int ret = io_setup(libaio_ctx->iodepth, &libaio_ctx->aio_ctx);
if (ret < 0) {
LOG_ERROR("failed to create aio context by io_setup() ", ERRNO(), VALUE(ret));
exit(-1);
Expand All @@ -375,11 +373,11 @@ namespace photon

std::unique_ptr<libaio_ctx_t> ctx(new libaio_ctx_t);
ctx->evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
libaio_ctx->iodepth = iodepth > IODEPTH_MAX ? IODEPTH_MAX : iodepth;
if (ctx->evfd < 0)
LOG_ERRNO_RETURN(0, -1, "failed to create eventfd");

int ret = io_setup(iodepth < IODEPTH_MAX ? iodepth : IODEPTH_MAX,
&ctx->aio_ctx);
int ret = io_setup(ctx->iodepth, &ctx->aio_ctx);
if (ret < 0)
{
LOG_ERROR("failed to create aio context by io_setup() ", ERRNO(), VALUE(ret));
Expand All @@ -391,7 +389,6 @@ namespace photon
assert(ctx->polling_thread);
libaio_ctx = ctx.release();
libaio_ctx->running = 1;
libaio_ctx->iodepth = iodepth;
if (reset_handler == nullptr) {
reset_handler = new AioResetHandle();
}
Expand Down
2 changes: 1 addition & 1 deletion photon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int init(uint64_t event_engine, uint64_t io_engine, const PhotonOptions& options
INIT_IO(EXPORTFS, exportfs)
INIT_IO(LIBCURL, libcurl)
#ifdef __linux__
INIT_IO(LIBAIO, libaio_wrapper, options.libaio_ctx)
INIT_IO(LIBAIO, libaio_wrapper, options.libaio_queue_depth)
INIT_IO(SOCKET_EDGE_TRIGGER, et_poller)
#endif
g_event_engine = event_engine;
Expand Down
2 changes: 1 addition & 1 deletion photon.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const uint64_t INIT_IO_DEFAULT = INIT_IO_LIBCURL;
#undef SHIFT

struct PhotonOptions {
int libaio_ctx = 32;
int libaio_queue_depth = 32;
bool use_pooled_stack_allocator = false;
bool bypass_threadpool = false;
};
Expand Down

0 comments on commit be04c36

Please sign in to comment.