include/boost/corosio/native/detail/select/select_tcp_acceptor_service.hpp
54.1% Lines (111/205)
95.0% List of functions (19/20)
26.3% Branches (20/76)
Functions (20)
Function
Calls
Lines
Branches
Blocks
boost::corosio::detail::select_tcp_acceptor_service::scheduler() const
:77
126x
100.0%
–
100.0%
boost::corosio::detail::select_accept_op::cancel()
:94
0
0.0%
0.0%
0.0%
boost::corosio::detail::select_accept_op::operator()()
:103
1740x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor::select_tcp_acceptor(boost::corosio::detail::select_tcp_acceptor_service&)
:108
142x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor::accept(std::__1::coroutine_handle<void>, boost::capy::executor_ref, std::__1::stop_token, std::__1::error_code*, boost::corosio::io_object::implementation**)
:115
1740x
26.9%
14.0%
25.0%
boost::corosio::detail::select_tcp_acceptor::cancel()
:268
2x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor::close_socket()
:274
276x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::select_tcp_acceptor_service(boost::capy::execution_context&, boost::corosio::detail::select_tcp_service&)
:279
484x
100.0%
50.0%
100.0%
boost::corosio::detail::select_tcp_acceptor_service::~select_tcp_acceptor_service()
:288
726x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::shutdown()
:291
242x
80.0%
50.0%
75.0%
boost::corosio::detail::select_tcp_acceptor_service::construct()
:304
71x
100.0%
50.0%
42.0%
boost::corosio::detail::select_tcp_acceptor_service::destroy(boost::corosio::io_object::implementation*)
:317
71x
100.0%
50.0%
50.0%
boost::corosio::detail::select_tcp_acceptor_service::close(boost::corosio::io_object::handle&)
:327
138x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::open_acceptor_socket(boost::corosio::tcp_acceptor::implementation&, int, int, int)
:333
67x
65.7%
58.3%
64.0%
boost::corosio::detail::select_tcp_acceptor_service::bind_acceptor(boost::corosio::tcp_acceptor::implementation&, boost::corosio::endpoint)
:396
66x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::listen_acceptor(boost::corosio::tcp_acceptor::implementation&, int)
:403
63x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::post(boost::corosio::detail::scheduler_op*)
:410
3x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::work_started()
:416
1740x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::work_finished()
:422
3x
100.0%
–
100.0%
boost::corosio::detail::select_tcp_acceptor_service::tcp_service() const
:428
1737x
100.0%
–
100.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2026 Steve Gerbino | |||
| 3 | // | |||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||
| 6 | // | |||
| 7 | // Official repository: https://github.com/cppalliance/corosio | |||
| 8 | // | |||
| 9 | ||||
| 10 | #ifndef BOOST_COROSIO_NATIVE_DETAIL_SELECT_SELECT_TCP_ACCEPTOR_SERVICE_HPP | |||
| 11 | #define BOOST_COROSIO_NATIVE_DETAIL_SELECT_SELECT_TCP_ACCEPTOR_SERVICE_HPP | |||
| 12 | ||||
| 13 | #include <boost/corosio/detail/platform.hpp> | |||
| 14 | ||||
| 15 | #if BOOST_COROSIO_HAS_SELECT | |||
| 16 | ||||
| 17 | #include <boost/corosio/detail/config.hpp> | |||
| 18 | #include <boost/capy/ex/execution_context.hpp> | |||
| 19 | #include <boost/corosio/detail/tcp_acceptor_service.hpp> | |||
| 20 | ||||
| 21 | #include <boost/corosio/native/detail/select/select_tcp_acceptor.hpp> | |||
| 22 | #include <boost/corosio/native/detail/select/select_tcp_service.hpp> | |||
| 23 | #include <boost/corosio/native/detail/select/select_scheduler.hpp> | |||
| 24 | #include <boost/corosio/native/detail/reactor/reactor_service_state.hpp> | |||
| 25 | ||||
| 26 | #include <boost/corosio/native/detail/reactor/reactor_op_complete.hpp> | |||
| 27 | ||||
| 28 | #include <memory> | |||
| 29 | #include <mutex> | |||
| 30 | #include <utility> | |||
| 31 | ||||
| 32 | #include <errno.h> | |||
| 33 | #include <fcntl.h> | |||
| 34 | #include <netinet/in.h> | |||
| 35 | #include <sys/select.h> | |||
| 36 | #include <sys/socket.h> | |||
| 37 | #include <unistd.h> | |||
| 38 | ||||
| 39 | namespace boost::corosio::detail { | |||
| 40 | ||||
| 41 | /// State for select acceptor service. | |||
| 42 | using select_tcp_acceptor_state = | |||
| 43 | reactor_service_state<select_scheduler, select_tcp_acceptor>; | |||
| 44 | ||||
| 45 | /** select acceptor service implementation. | |||
| 46 | ||||
| 47 | Inherits from tcp_acceptor_service to enable runtime polymorphism. | |||
| 48 | Uses key_type = tcp_acceptor_service for service lookup. | |||
| 49 | */ | |||
| 50 | class BOOST_COROSIO_DECL select_tcp_acceptor_service final | |||
| 51 | : public tcp_acceptor_service | |||
| 52 | { | |||
| 53 | public: | |||
| 54 | explicit select_tcp_acceptor_service( | |||
| 55 | capy::execution_context& ctx, select_tcp_service& tcp_svc); | |||
| 56 | ~select_tcp_acceptor_service() override; | |||
| 57 | ||||
| 58 | select_tcp_acceptor_service(select_tcp_acceptor_service const&) = delete; | |||
| 59 | select_tcp_acceptor_service& | |||
| 60 | operator=(select_tcp_acceptor_service const&) = delete; | |||
| 61 | ||||
| 62 | void shutdown() override; | |||
| 63 | ||||
| 64 | io_object::implementation* construct() override; | |||
| 65 | void destroy(io_object::implementation*) override; | |||
| 66 | void close(io_object::handle&) override; | |||
| 67 | std::error_code open_acceptor_socket( | |||
| 68 | tcp_acceptor::implementation& impl, | |||
| 69 | int family, | |||
| 70 | int type, | |||
| 71 | int protocol) override; | |||
| 72 | std::error_code | |||
| 73 | bind_acceptor(tcp_acceptor::implementation& impl, endpoint ep) override; | |||
| 74 | std::error_code | |||
| 75 | listen_acceptor(tcp_acceptor::implementation& impl, int backlog) override; | |||
| 76 | ||||
| 77 | 126x | select_scheduler& scheduler() const noexcept | ||
| 78 | { | |||
| 79 | 126x | return state_->sched_; | ||
| 80 | } | |||
| 81 | void post(scheduler_op* op); | |||
| 82 | void work_started() noexcept; | |||
| 83 | void work_finished() noexcept; | |||
| 84 | ||||
| 85 | /** Get the TCP service for creating peer sockets during accept. */ | |||
| 86 | select_tcp_service* tcp_service() const noexcept; | |||
| 87 | ||||
| 88 | private: | |||
| 89 | select_tcp_service* tcp_svc_; | |||
| 90 | std::unique_ptr<select_tcp_acceptor_state> state_; | |||
| 91 | }; | |||
| 92 | ||||
| 93 | inline void | |||
| 94 | ✗ | select_accept_op::cancel() noexcept | ||
| 95 | { | |||
| 96 | ✗ | if (acceptor_impl_) | ||
| 97 | ✗ | acceptor_impl_->cancel_single_op(*this); | ||
| 98 | else | |||
| 99 | ✗ | request_cancel(); | ||
| 100 | ✗ | } | ||
| 101 | ||||
| 102 | inline void | |||
| 103 | 1740x | select_accept_op::operator()() | ||
| 104 | { | |||
| 105 | 1740x | complete_accept_op<select_tcp_socket>(*this); | ||
| 106 | 1740x | } | ||
| 107 | ||||
| 108 | 142x | inline select_tcp_acceptor::select_tcp_acceptor( | ||
| 109 | select_tcp_acceptor_service& svc) noexcept | |||
| 110 | 71x | : reactor_acceptor(svc) | ||
| 111 | 142x | { | ||
| 112 | 142x | } | ||
| 113 | ||||
| 114 | inline std::coroutine_handle<> | |||
| 115 | 1740x | select_tcp_acceptor::accept( | ||
| 116 | std::coroutine_handle<> h, | |||
| 117 | capy::executor_ref ex, | |||
| 118 | std::stop_token token, | |||
| 119 | std::error_code* ec, | |||
| 120 | io_object::implementation** impl_out) | |||
| 121 | { | |||
| 122 | 1740x | auto& op = acc_; | ||
| 123 | 1740x | op.reset(); | ||
| 124 | 1740x | op.h = h; | ||
| 125 | 1740x | op.ex = ex; | ||
| 126 | 1740x | op.ec_out = ec; | ||
| 127 | 1740x | op.impl_out = impl_out; | ||
| 128 | 1740x | op.fd = fd_; | ||
| 129 | 1740x | op.start(token, this); | ||
| 130 | ||||
| 131 | 1740x | sockaddr_storage peer_storage{}; | ||
| 132 | 1740x | socklen_t addrlen = sizeof(peer_storage); | ||
| 133 | int accepted; | |||
| 134 | 1740x | do | ||
| 135 | { | |||
| 136 | 1740x | accepted = | ||
| 137 | 1740x | ::accept(fd_, reinterpret_cast<sockaddr*>(&peer_storage), &addrlen); | ||
| 138 | 3480x | } | ||
| 139 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1740 times.
|
1740x | while (accepted < 0 && errno == EINTR); | |
| 140 | ||||
| 141 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1740 times.
|
1740x | if (accepted >= 0) | |
| 142 | { | |||
| 143 | ✗ | if (accepted >= FD_SETSIZE) | ||
| 144 | { | |||
| 145 | ✗ | ::close(accepted); | ||
| 146 | ✗ | op.complete(EINVAL, 0); | ||
| 147 | ✗ | op.impl_ptr = shared_from_this(); | ||
| 148 | ✗ | svc_.post(&op); | ||
| 149 | ✗ | return std::noop_coroutine(); | ||
| 150 | } | |||
| 151 | ||||
| 152 | ✗ | int flags = ::fcntl(accepted, F_GETFL, 0); | ||
| 153 | ✗ | if (flags == -1) | ||
| 154 | { | |||
| 155 | ✗ | int err = errno; | ||
| 156 | ✗ | ::close(accepted); | ||
| 157 | ✗ | op.complete(err, 0); | ||
| 158 | ✗ | op.impl_ptr = shared_from_this(); | ||
| 159 | ✗ | svc_.post(&op); | ||
| 160 | ✗ | return std::noop_coroutine(); | ||
| 161 | } | |||
| 162 | ||||
| 163 | ✗ | if (::fcntl(accepted, F_SETFL, flags | O_NONBLOCK) == -1) | ||
| 164 | { | |||
| 165 | ✗ | int err = errno; | ||
| 166 | ✗ | ::close(accepted); | ||
| 167 | ✗ | op.complete(err, 0); | ||
| 168 | ✗ | op.impl_ptr = shared_from_this(); | ||
| 169 | ✗ | svc_.post(&op); | ||
| 170 | ✗ | return std::noop_coroutine(); | ||
| 171 | } | |||
| 172 | ||||
| 173 | ✗ | if (::fcntl(accepted, F_SETFD, FD_CLOEXEC) == -1) | ||
| 174 | { | |||
| 175 | ✗ | int err = errno; | ||
| 176 | ✗ | ::close(accepted); | ||
| 177 | ✗ | op.complete(err, 0); | ||
| 178 | ✗ | op.impl_ptr = shared_from_this(); | ||
| 179 | ✗ | svc_.post(&op); | ||
| 180 | ✗ | return std::noop_coroutine(); | ||
| 181 | } | |||
| 182 | ||||
| 183 | { | |||
| 184 | ✗ | std::lock_guard lock(desc_state_.mutex); | ||
| 185 | ✗ | desc_state_.read_ready = false; | ||
| 186 | ✗ | } | ||
| 187 | ||||
| 188 | ✗ | if (svc_.scheduler().try_consume_inline_budget()) | ||
| 189 | { | |||
| 190 | ✗ | auto* socket_svc = svc_.tcp_service(); | ||
| 191 | ✗ | if (socket_svc) | ||
| 192 | { | |||
| 193 | ✗ | auto& impl = | ||
| 194 | ✗ | static_cast<select_tcp_socket&>(*socket_svc->construct()); | ||
| 195 | ✗ | impl.set_socket(accepted); | ||
| 196 | ||||
| 197 | ✗ | impl.desc_state_.fd = accepted; | ||
| 198 | { | |||
| 199 | ✗ | std::lock_guard lock(impl.desc_state_.mutex); | ||
| 200 | ✗ | impl.desc_state_.read_op = nullptr; | ||
| 201 | ✗ | impl.desc_state_.write_op = nullptr; | ||
| 202 | ✗ | impl.desc_state_.connect_op = nullptr; | ||
| 203 | ✗ | } | ||
| 204 | ✗ | socket_svc->scheduler().register_descriptor( | ||
| 205 | ✗ | accepted, &impl.desc_state_); | ||
| 206 | ||||
| 207 | ✗ | impl.set_endpoints( | ||
| 208 | ✗ | local_endpoint_, from_sockaddr(peer_storage)); | ||
| 209 | ||||
| 210 | ✗ | *ec = {}; | ||
| 211 | ✗ | if (impl_out) | ||
| 212 | ✗ | *impl_out = &impl; | ||
| 213 | ✗ | } | ||
| 214 | else | |||
| 215 | { | |||
| 216 | ✗ | ::close(accepted); | ||
| 217 | ✗ | *ec = make_err(ENOENT); | ||
| 218 | ✗ | if (impl_out) | ||
| 219 | ✗ | *impl_out = nullptr; | ||
| 220 | } | |||
| 221 | ✗ | op.cont_op.cont.h = h; | ||
| 222 | ✗ | return dispatch_coro(ex, op.cont_op.cont); | ||
| 223 | } | |||
| 224 | ||||
| 225 | ✗ | op.accepted_fd = accepted; | ||
| 226 | ✗ | op.peer_storage = peer_storage; | ||
| 227 | ✗ | op.complete(0, 0); | ||
| 228 | ✗ | op.impl_ptr = shared_from_this(); | ||
| 229 | ✗ | svc_.post(&op); | ||
| 230 | ✗ | return std::noop_coroutine(); | ||
| 231 | } | |||
| 232 | ||||
| 233 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1740 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1740x | if (errno == EAGAIN || errno == EWOULDBLOCK) | |
| 234 | { | |||
| 235 |
1/2✓ Branch 0 taken 1740 times.
✗ Branch 1 not taken.
|
1740x | op.impl_ptr = shared_from_this(); | |
| 236 | 1740x | svc_.work_started(); | ||
| 237 | ||||
| 238 | 1740x | std::lock_guard lock(desc_state_.mutex); | ||
| 239 | 1740x | bool io_done = false; | ||
| 240 |
1/2✓ Branch 0 taken 1740 times.
✗ Branch 1 not taken.
|
1740x | if (desc_state_.read_ready) | |
| 241 | { | |||
| 242 | ✗ | desc_state_.read_ready = false; | ||
| 243 | ✗ | op.perform_io(); | ||
| 244 | ✗ | io_done = (op.errn != EAGAIN && op.errn != EWOULDBLOCK); | ||
| 245 | ✗ | if (!io_done) | ||
| 246 | ✗ | op.errn = 0; | ||
| 247 | ✗ | } | ||
| 248 | ||||
| 249 |
2/4✓ Branch 0 taken 1740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1740 times.
|
1740x | if (io_done || op.cancelled.load(std::memory_order_acquire)) | |
| 250 | { | |||
| 251 | ✗ | svc_.post(&op); | ||
| 252 | ✗ | svc_.work_finished(); | ||
| 253 | ✗ | } | ||
| 254 | else | |||
| 255 | { | |||
| 256 | 1740x | desc_state_.read_op = &op; | ||
| 257 | } | |||
| 258 | 1740x | return std::noop_coroutine(); | ||
| 259 | 1740x | } | ||
| 260 | ||||
| 261 | ✗ | op.complete(errno, 0); | ||
| 262 | ✗ | op.impl_ptr = shared_from_this(); | ||
| 263 | ✗ | svc_.post(&op); | ||
| 264 | ✗ | return std::noop_coroutine(); | ||
| 265 | 1740x | } | ||
| 266 | ||||
| 267 | inline void | |||
| 268 | 2x | select_tcp_acceptor::cancel() noexcept | ||
| 269 | { | |||
| 270 | 2x | do_cancel(); | ||
| 271 | 2x | } | ||
| 272 | ||||
| 273 | inline void | |||
| 274 | 276x | select_tcp_acceptor::close_socket() noexcept | ||
| 275 | { | |||
| 276 | 276x | do_close_socket(); | ||
| 277 | 276x | } | ||
| 278 | ||||
| 279 | 484x | inline select_tcp_acceptor_service::select_tcp_acceptor_service( | ||
| 280 | capy::execution_context& ctx, select_tcp_service& tcp_svc) | |||
| 281 | 242x | : tcp_svc_(&tcp_svc) | ||
| 282 | 242x | , state_( | ||
| 283 |
1/2✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
|
242x | std::make_unique<select_tcp_acceptor_state>( | |
| 284 |
1/2✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
|
242x | ctx.use_service<select_scheduler>())) | |
| 285 | 484x | { | ||
| 286 | 484x | } | ||
| 287 | ||||
| 288 | 726x | inline select_tcp_acceptor_service::~select_tcp_acceptor_service() {} | ||
| 289 | ||||
| 290 | inline void | |||
| 291 | 242x | select_tcp_acceptor_service::shutdown() | ||
| 292 | { | |||
| 293 | 242x | std::lock_guard lock(state_->mutex_); | ||
| 294 | ||||
| 295 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
|
242x | while (auto* impl = state_->impl_list_.pop_front()) | |
| 296 | ✗ | impl->close_socket(); | ||
| 297 | ||||
| 298 | // Don't clear impl_ptrs_ here — same rationale as | |||
| 299 | // select_tcp_service::shutdown(). Let ~state_ release ptrs | |||
| 300 | // after scheduler shutdown has drained all queued ops. | |||
| 301 | 242x | } | ||
| 302 | ||||
| 303 | inline io_object::implementation* | |||
| 304 | 71x | select_tcp_acceptor_service::construct() | ||
| 305 | { | |||
| 306 | 71x | auto impl = std::make_shared<select_tcp_acceptor>(*this); | ||
| 307 | 71x | auto* raw = impl.get(); | ||
| 308 | ||||
| 309 |
1/2✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
|
71x | std::lock_guard lock(state_->mutex_); | |
| 310 |
1/2✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
|
71x | state_->impl_ptrs_.emplace(raw, std::move(impl)); | |
| 311 | 71x | state_->impl_list_.push_back(raw); | ||
| 312 | ||||
| 313 | 71x | return raw; | ||
| 314 | 71x | } | ||
| 315 | ||||
| 316 | inline void | |||
| 317 | 71x | select_tcp_acceptor_service::destroy(io_object::implementation* impl) | ||
| 318 | { | |||
| 319 | 71x | auto* select_impl = static_cast<select_tcp_acceptor*>(impl); | ||
| 320 | 71x | select_impl->close_socket(); | ||
| 321 | 71x | std::lock_guard lock(state_->mutex_); | ||
| 322 | 71x | state_->impl_list_.remove(select_impl); | ||
| 323 |
1/2✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
|
71x | state_->impl_ptrs_.erase(select_impl); | |
| 324 | 71x | } | ||
| 325 | ||||
| 326 | inline void | |||
| 327 | 138x | select_tcp_acceptor_service::close(io_object::handle& h) | ||
| 328 | { | |||
| 329 | 138x | static_cast<select_tcp_acceptor*>(h.get())->close_socket(); | ||
| 330 | 138x | } | ||
| 331 | ||||
| 332 | inline std::error_code | |||
| 333 | 67x | select_tcp_acceptor_service::open_acceptor_socket( | ||
| 334 | tcp_acceptor::implementation& impl, int family, int type, int protocol) | |||
| 335 | { | |||
| 336 | 67x | auto* select_impl = static_cast<select_tcp_acceptor*>(&impl); | ||
| 337 | 67x | select_impl->close_socket(); | ||
| 338 | ||||
| 339 | 67x | int fd = ::socket(family, type, protocol); | ||
| 340 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67x | if (fd < 0) | |
| 341 | ✗ | return make_err(errno); | ||
| 342 | ||||
| 343 | 67x | int flags = ::fcntl(fd, F_GETFL, 0); | ||
| 344 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67x | if (flags == -1) | |
| 345 | { | |||
| 346 | ✗ | int errn = errno; | ||
| 347 | ✗ | ::close(fd); | ||
| 348 | ✗ | return make_err(errn); | ||
| 349 | } | |||
| 350 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67x | if (::fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) | |
| 351 | { | |||
| 352 | ✗ | int errn = errno; | ||
| 353 | ✗ | ::close(fd); | ||
| 354 | ✗ | return make_err(errn); | ||
| 355 | } | |||
| 356 |
1/2✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
|
67x | if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) | |
| 357 | { | |||
| 358 | ✗ | int errn = errno; | ||
| 359 | ✗ | ::close(fd); | ||
| 360 | ✗ | return make_err(errn); | ||
| 361 | } | |||
| 362 | ||||
| 363 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
|
67x | if (fd >= FD_SETSIZE) | |
| 364 | { | |||
| 365 | ✗ | ::close(fd); | ||
| 366 | ✗ | return make_err(EMFILE); | ||
| 367 | } | |||
| 368 | ||||
| 369 |
2/2✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8 times.
|
67x | if (family == AF_INET6) | |
| 370 | { | |||
| 371 | 8x | int val = 0; // dual-stack default | ||
| 372 | 8x | ::setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)); | ||
| 373 | 8x | } | ||
| 374 | ||||
| 375 | #ifdef SO_NOSIGPIPE | |||
| 376 | { | |||
| 377 | 67x | int nosig = 1; | ||
| 378 | 67x | ::setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &nosig, sizeof(nosig)); | ||
| 379 | } | |||
| 380 | #endif | |||
| 381 | ||||
| 382 | 67x | select_impl->fd_ = fd; | ||
| 383 | ||||
| 384 | // Set up descriptor state but do NOT register with reactor yet | |||
| 385 | // (registration happens in do_listen via reactor_acceptor base) | |||
| 386 | 67x | select_impl->desc_state_.fd = fd; | ||
| 387 | { | |||
| 388 | 67x | std::lock_guard lock(select_impl->desc_state_.mutex); | ||
| 389 | 67x | select_impl->desc_state_.read_op = nullptr; | ||
| 390 | 67x | } | ||
| 391 | ||||
| 392 | 67x | return {}; | ||
| 393 | 67x | } | ||
| 394 | ||||
| 395 | inline std::error_code | |||
| 396 | 66x | select_tcp_acceptor_service::bind_acceptor( | ||
| 397 | tcp_acceptor::implementation& impl, endpoint ep) | |||
| 398 | { | |||
| 399 | 66x | return static_cast<select_tcp_acceptor*>(&impl)->do_bind(ep); | ||
| 400 | } | |||
| 401 | ||||
| 402 | inline std::error_code | |||
| 403 | 63x | select_tcp_acceptor_service::listen_acceptor( | ||
| 404 | tcp_acceptor::implementation& impl, int backlog) | |||
| 405 | { | |||
| 406 | 63x | return static_cast<select_tcp_acceptor*>(&impl)->do_listen(backlog); | ||
| 407 | } | |||
| 408 | ||||
| 409 | inline void | |||
| 410 | 3x | select_tcp_acceptor_service::post(scheduler_op* op) | ||
| 411 | { | |||
| 412 | 3x | state_->sched_.post(op); | ||
| 413 | 3x | } | ||
| 414 | ||||
| 415 | inline void | |||
| 416 | 1740x | select_tcp_acceptor_service::work_started() noexcept | ||
| 417 | { | |||
| 418 | 1740x | state_->sched_.work_started(); | ||
| 419 | 1740x | } | ||
| 420 | ||||
| 421 | inline void | |||
| 422 | 3x | select_tcp_acceptor_service::work_finished() noexcept | ||
| 423 | { | |||
| 424 | 3x | state_->sched_.work_finished(); | ||
| 425 | 3x | } | ||
| 426 | ||||
| 427 | inline select_tcp_service* | |||
| 428 | 1737x | select_tcp_acceptor_service::tcp_service() const noexcept | ||
| 429 | { | |||
| 430 | 1737x | return tcp_svc_; | ||
| 431 | } | |||
| 432 | ||||
| 433 | } // namespace boost::corosio::detail | |||
| 434 | ||||
| 435 | #endif // BOOST_COROSIO_HAS_SELECT | |||
| 436 | ||||
| 437 | #endif // BOOST_COROSIO_NATIVE_DETAIL_SELECT_SELECT_TCP_ACCEPTOR_SERVICE_HPP | |||
| 438 |