diff --git a/io/aio-wrapper.cpp b/io/aio-wrapper.cpp index 29654095..bd638921 100644 --- a/io/aio-wrapper.cpp +++ b/io/aio-wrapper.cpp @@ -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) { @@ -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); @@ -375,11 +373,11 @@ namespace photon std::unique_ptr 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)); @@ -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(); } diff --git a/photon.cpp b/photon.cpp index 5d7dd566..b20379c8 100644 --- a/photon.cpp +++ b/photon.cpp @@ -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; diff --git a/photon.h b/photon.h index 963afa2e..8c2d75fb 100644 --- a/photon.h +++ b/photon.h @@ -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; };