26#ifndef MYSQL_HARNESS_NET_TS_IMPL_KQUEUE_IO_SERVICE_H_
27#define MYSQL_HARNESS_NET_TS_IMPL_KQUEUE_IO_SERVICE_H_
38class kqueue_io_service :
public IoServiceBase {
42 ~kqueue_io_service()
override {
close(); }
44 bool is_open() const noexcept {
64 wakeup_fds_ = *pipe_res;
71 auto non_block_wakeup_0_res =
73 if (!non_block_wakeup_0_res)
return non_block_wakeup_0_res;
74 auto non_block_wakeup_1_res =
76 if (!non_block_wakeup_1_res)
return non_block_wakeup_1_res;
82 std::array<uint8_t, 256>
buf;
86 }
while (res != -1 || errno == EINTR);
92 res =
::write(wakeup_fds_.second,
".", 1);
94 }
while ((res == -1) && (errno == EINTR));
124 filter = EVFILT_READ;
127 filter = EVFILT_WRITE;
135 EV_SET(&ev, fd, filter, EV_ADD | EV_ONESHOT | EV_CLEAR, 0, 0,
NULL);
137 changelist_.push_back(ev);
146 EV_SET(&ev, fd, filter, EV_DELETE, 0, 0,
NULL);
148 changelist_.push_back(ev);
154 const struct kevent & ) {
166 EV_SET(&ev, fd, 0, EV_DELETE, 0, 0,
NULL);
168 changelist_.push_back(ev);
181 std::chrono::milliseconds
timeout)
override {
187 if (fd_events_processed_ == fd_events_size_) {
188 struct timespec ts, *p_ts{};
191 auto secs = std::chrono::duration_cast<std::chrono::seconds>(
timeout);
195 std::chrono::duration_cast<std::chrono::nanoseconds>(
timeout)
202 impl::kqueue::kevent(epfd_, changelist_.data(), changelist_.size(),
203 fd_events_.data(), fd_events_.size(), p_ts);
208 fd_events_processed_ = 0;
209 fd_events_size_ = *res;
211 if (fd_events_size_ == 0) {
216 const auto ev = fd_events_[fd_events_processed_++];
220 if (ev.flags & EV_ERROR) {
246 after_event_fired(ev);
249 if (ev.filter == EVFILT_READ) {
251 }
else if (ev.filter == EVFILT_WRITE) {
261 std::array<struct kevent, 16> fd_events_;
262 size_t fd_events_processed_{0};
263 size_t fd_events_size_{0};
265 std::vector<struct kevent> changelist_;
267 std::pair<impl::file::file_handle_type, impl::file::file_handle_type>
Definition: expected.h:944
static bool interrupted
Definition: mysqladmin.cc:66
Definition: buf0block_hint.cc:30
bool terminate(THD *thd)
Drop all DD tables in case there is an error while upgrading server.
Definition: upgrade.cc:686
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:496
int file_handle_type
Definition: file.h:53
constexpr file_handle_type kInvalidHandle
Definition: file.h:54
stdx::expected< std::pair< file_handle_type, file_handle_type >, std::error_code > pipe(int flags=0)
create pipe.
Definition: file.h:144
stdx::expected< void, std::error_code > close(file_handle_type native_handle)
close file handle.
Definition: file.h:239
wait_type
Definition: socket_constants.h:86
stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle)
Definition: socket.h:106
int native_handle_type
Definition: socket_constants.h:51
std::enable_if_t< is_const_buffer_sequence< ConstBufferSequence >::value, stdx::expected< size_t, std::error_code > > write(SyncWriteStream &stream, const ConstBufferSequence &buffers)
Definition: buffer.h:992
std::enable_if_t< is_mutable_buffer_sequence< MutableBufferSequence >::value, stdx::expected< size_t, std::error_code > > read(SyncReadStream &stream, const MutableBufferSequence &buffers)
Definition: buffer.h:838
std::error_code make_error_code(net::stream_errc e) noexcept
Definition: buffer.h:103
static mysql_service_status_t create(const char *service_names[], reference_caching_channel *out_channel) noexcept
Definition: component.cc:36
stdx::expected< int, std::error_code > open(const char *fname, int flags, mode_t mode) noexcept
Definition: file_handle.cc:79
constexpr auto make_unexpected(E &&e) -> unexpected< std::decay_t< E > >
Definition: expected.h:125
static bool notify(SvcTypes svc_type, Notification_context &ctx)
Auxiliary function to engage the service registry to notify a set of listeners.
Definition: notification.cc:87
#define NULL
Definition: types.h:55