Skip to content

Commit fb037cf

Browse files
committed
Add config option to determine whether timerfd is used.
Add a new configuration option "reactor" / "use_timerfd" that is used by the epoll_reactor. When true (the default), the reactor uses a timerfd descriptor to manage timeouts. When false, the duration until the next timeout is computed and passed as a timeout to epoll_wait.
1 parent 6ca87cc commit fb037cf

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

include/asio/detail/impl/epoll_reactor.ipp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ epoll_reactor::epoll_reactor(asio::execution_context& ctx)
4343
config(ctx).get("reactor", "registration_locking_spin_count", 0)),
4444
interrupter_(),
4545
epoll_fd_(do_epoll_create()),
46-
timer_fd_(do_timerfd_create()),
46+
timer_fd_(config(ctx).get("reactor", "use_timerfd", true)
47+
? do_timerfd_create() : -1),
4748
shutdown_(false),
4849
io_locking_(config(ctx).get("reactor", "io_locking", true)),
4950
io_locking_spin_count_(
@@ -109,9 +110,11 @@ void epoll_reactor::notify_fork(
109110
epoll_fd_ = do_epoll_create();
110111

111112
if (timer_fd_ != -1)
113+
{
112114
::close(timer_fd_);
113-
timer_fd_ = -1;
114-
timer_fd_ = do_timerfd_create();
115+
timer_fd_ = -1;
116+
timer_fd_ = do_timerfd_create();
117+
}
115118

116119
interrupter_.recreate();
117120

src/doc/overview/configuration.qbk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ below.
177177
fails with `EAGAIN`.
178178
]
179179
]
180+
[
181+
[`reactor`]
182+
[`use_timerfd`]
183+
[`bool`]
184+
[`true`]
185+
[
186+
Linux [^epoll] backend only.
187+
188+
When `true`, the reactor uses a [^timerfd] descriptor to manage timeouts.
189+
When `false`, the duration until the next timeout is computed and passed
190+
as a timeout to [^epoll_wait].
191+
]
192+
]
180193
[
181194
[`timer`]
182195
[`heap_reserve`]

0 commit comments

Comments
 (0)