epoll_reactor.ipp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. //
  2. // detail/impl/epoll_reactor.ipp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_DETAIL_IMPL_EPOLL_REACTOR_IPP
  11. #define ASIO_DETAIL_IMPL_EPOLL_REACTOR_IPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if defined(ASIO_HAS_EPOLL)
  17. #include <cstddef>
  18. #include <sys/epoll.h>
  19. #include "asio/detail/epoll_reactor.hpp"
  20. #include "asio/detail/throw_error.hpp"
  21. #include "asio/error.hpp"
  22. #if defined(ASIO_HAS_TIMERFD)
  23. # include <sys/timerfd.h>
  24. #endif // defined(ASIO_HAS_TIMERFD)
  25. #include "asio/detail/push_options.hpp"
  26. namespace asio {
  27. namespace detail {
  28. epoll_reactor::epoll_reactor(asio::io_service& io_service)
  29. : asio::detail::service_base<epoll_reactor>(io_service),
  30. io_service_(use_service<io_service_impl>(io_service)),
  31. mutex_(),
  32. interrupter_(),
  33. epoll_fd_(do_epoll_create()),
  34. timer_fd_(do_timerfd_create()),
  35. shutdown_(false)
  36. {
  37. // Add the interrupter's descriptor to epoll.
  38. epoll_event ev = { 0, { 0 } };
  39. ev.events = EPOLLIN | EPOLLERR | EPOLLET;
  40. ev.data.ptr = &interrupter_;
  41. epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, interrupter_.read_descriptor(), &ev);
  42. interrupter_.interrupt();
  43. // Add the timer descriptor to epoll.
  44. if (timer_fd_ != -1)
  45. {
  46. ev.events = EPOLLIN | EPOLLERR;
  47. ev.data.ptr = &timer_fd_;
  48. epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, timer_fd_, &ev);
  49. }
  50. }
  51. epoll_reactor::~epoll_reactor()
  52. {
  53. if (epoll_fd_ != -1)
  54. close(epoll_fd_);
  55. if (timer_fd_ != -1)
  56. close(timer_fd_);
  57. }
  58. void epoll_reactor::shutdown_service()
  59. {
  60. mutex::scoped_lock lock(mutex_);
  61. shutdown_ = true;
  62. lock.unlock();
  63. op_queue<operation> ops;
  64. while (descriptor_state* state = registered_descriptors_.first())
  65. {
  66. for (int i = 0; i < max_ops; ++i)
  67. ops.push(state->op_queue_[i]);
  68. state->shutdown_ = true;
  69. registered_descriptors_.free(state);
  70. }
  71. timer_queues_.get_all_timers(ops);
  72. io_service_.abandon_operations(ops);
  73. }
  74. void epoll_reactor::fork_service(asio::io_service::fork_event fork_ev)
  75. {
  76. if (fork_ev == asio::io_service::fork_child)
  77. {
  78. if (epoll_fd_ != -1)
  79. ::close(epoll_fd_);
  80. epoll_fd_ = -1;
  81. epoll_fd_ = do_epoll_create();
  82. if (timer_fd_ != -1)
  83. ::close(timer_fd_);
  84. timer_fd_ = -1;
  85. timer_fd_ = do_timerfd_create();
  86. interrupter_.recreate();
  87. // Add the interrupter's descriptor to epoll.
  88. epoll_event ev = { 0, { 0 } };
  89. ev.events = EPOLLIN | EPOLLERR | EPOLLET;
  90. ev.data.ptr = &interrupter_;
  91. epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, interrupter_.read_descriptor(), &ev);
  92. interrupter_.interrupt();
  93. // Add the timer descriptor to epoll.
  94. if (timer_fd_ != -1)
  95. {
  96. ev.events = EPOLLIN | EPOLLERR;
  97. ev.data.ptr = &timer_fd_;
  98. epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, timer_fd_, &ev);
  99. }
  100. update_timeout();
  101. // Re-register all descriptors with epoll.
  102. mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_);
  103. for (descriptor_state* state = registered_descriptors_.first();
  104. state != 0; state = state->next_)
  105. {
  106. ev.events = state->registered_events_;
  107. ev.data.ptr = state;
  108. int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, state->descriptor_, &ev);
  109. if (result != 0)
  110. {
  111. asio::error_code ec(errno,
  112. asio::error::get_system_category());
  113. asio::detail::throw_error(ec, "epoll re-registration");
  114. }
  115. }
  116. }
  117. }
  118. void epoll_reactor::init_task()
  119. {
  120. io_service_.init_task();
  121. }
  122. int epoll_reactor::register_descriptor(socket_type descriptor,
  123. epoll_reactor::per_descriptor_data& descriptor_data)
  124. {
  125. descriptor_data = allocate_descriptor_state();
  126. {
  127. mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
  128. descriptor_data->reactor_ = this;
  129. descriptor_data->descriptor_ = descriptor;
  130. descriptor_data->shutdown_ = false;
  131. }
  132. epoll_event ev = { 0, { 0 } };
  133. ev.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLPRI | EPOLLET;
  134. descriptor_data->registered_events_ = ev.events;
  135. ev.data.ptr = descriptor_data;
  136. int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, descriptor, &ev);
  137. if (result != 0)
  138. return errno;
  139. return 0;
  140. }
  141. int epoll_reactor::register_internal_descriptor(
  142. int op_type, socket_type descriptor,
  143. epoll_reactor::per_descriptor_data& descriptor_data, reactor_op* op)
  144. {
  145. descriptor_data = allocate_descriptor_state();
  146. {
  147. mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
  148. descriptor_data->reactor_ = this;
  149. descriptor_data->descriptor_ = descriptor;
  150. descriptor_data->shutdown_ = false;
  151. descriptor_data->op_queue_[op_type].push(op);
  152. }
  153. epoll_event ev = { 0, { 0 } };
  154. ev.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLPRI | EPOLLET;
  155. descriptor_data->registered_events_ = ev.events;
  156. ev.data.ptr = descriptor_data;
  157. int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, descriptor, &ev);
  158. if (result != 0)
  159. return errno;
  160. return 0;
  161. }
  162. void epoll_reactor::move_descriptor(socket_type,
  163. epoll_reactor::per_descriptor_data& target_descriptor_data,
  164. epoll_reactor::per_descriptor_data& source_descriptor_data)
  165. {
  166. target_descriptor_data = source_descriptor_data;
  167. source_descriptor_data = 0;
  168. }
  169. void epoll_reactor::start_op(int op_type, socket_type descriptor,
  170. epoll_reactor::per_descriptor_data& descriptor_data, reactor_op* op,
  171. bool is_continuation, bool allow_speculative)
  172. {
  173. if (!descriptor_data)
  174. {
  175. op->ec_ = asio::error::bad_descriptor;
  176. post_immediate_completion(op, is_continuation);
  177. return;
  178. }
  179. mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
  180. if (descriptor_data->shutdown_)
  181. {
  182. post_immediate_completion(op, is_continuation);
  183. return;
  184. }
  185. if (descriptor_data->op_queue_[op_type].empty())
  186. {
  187. if (allow_speculative
  188. && (op_type != read_op
  189. || descriptor_data->op_queue_[except_op].empty()))
  190. {
  191. if (op->perform())
  192. {
  193. descriptor_lock.unlock();
  194. io_service_.post_immediate_completion(op, is_continuation);
  195. return;
  196. }
  197. if (op_type == write_op)
  198. {
  199. if ((descriptor_data->registered_events_ & EPOLLOUT) == 0)
  200. {
  201. epoll_event ev = { 0, { 0 } };
  202. ev.events = descriptor_data->registered_events_ | EPOLLOUT;
  203. ev.data.ptr = descriptor_data;
  204. if (epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev) == 0)
  205. {
  206. descriptor_data->registered_events_ |= ev.events;
  207. }
  208. else
  209. {
  210. op->ec_ = asio::error_code(errno,
  211. asio::error::get_system_category());
  212. io_service_.post_immediate_completion(op, is_continuation);
  213. return;
  214. }
  215. }
  216. }
  217. }
  218. else
  219. {
  220. if (op_type == write_op)
  221. {
  222. descriptor_data->registered_events_ |= EPOLLOUT;
  223. }
  224. epoll_event ev = { 0, { 0 } };
  225. ev.events = descriptor_data->registered_events_;
  226. ev.data.ptr = descriptor_data;
  227. epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
  228. }
  229. }
  230. descriptor_data->op_queue_[op_type].push(op);
  231. io_service_.work_started();
  232. }
  233. void epoll_reactor::cancel_ops(socket_type,
  234. epoll_reactor::per_descriptor_data& descriptor_data)
  235. {
  236. if (!descriptor_data)
  237. return;
  238. mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
  239. op_queue<operation> ops;
  240. for (int i = 0; i < max_ops; ++i)
  241. {
  242. while (reactor_op* op = descriptor_data->op_queue_[i].front())
  243. {
  244. op->ec_ = asio::error::operation_aborted;
  245. descriptor_data->op_queue_[i].pop();
  246. ops.push(op);
  247. }
  248. }
  249. descriptor_lock.unlock();
  250. io_service_.post_deferred_completions(ops);
  251. }
  252. void epoll_reactor::deregister_descriptor(socket_type descriptor,
  253. epoll_reactor::per_descriptor_data& descriptor_data, bool closing)
  254. {
  255. if (!descriptor_data)
  256. return;
  257. mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
  258. if (!descriptor_data->shutdown_)
  259. {
  260. if (closing)
  261. {
  262. // The descriptor will be automatically removed from the epoll set when
  263. // it is closed.
  264. }
  265. else
  266. {
  267. epoll_event ev = { 0, { 0 } };
  268. epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, descriptor, &ev);
  269. }
  270. op_queue<operation> ops;
  271. for (int i = 0; i < max_ops; ++i)
  272. {
  273. while (reactor_op* op = descriptor_data->op_queue_[i].front())
  274. {
  275. op->ec_ = asio::error::operation_aborted;
  276. descriptor_data->op_queue_[i].pop();
  277. ops.push(op);
  278. }
  279. }
  280. descriptor_data->descriptor_ = -1;
  281. descriptor_data->shutdown_ = true;
  282. descriptor_lock.unlock();
  283. free_descriptor_state(descriptor_data);
  284. descriptor_data = 0;
  285. io_service_.post_deferred_completions(ops);
  286. }
  287. }
  288. void epoll_reactor::deregister_internal_descriptor(socket_type descriptor,
  289. epoll_reactor::per_descriptor_data& descriptor_data)
  290. {
  291. if (!descriptor_data)
  292. return;
  293. mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
  294. if (!descriptor_data->shutdown_)
  295. {
  296. epoll_event ev = { 0, { 0 } };
  297. epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, descriptor, &ev);
  298. op_queue<operation> ops;
  299. for (int i = 0; i < max_ops; ++i)
  300. ops.push(descriptor_data->op_queue_[i]);
  301. descriptor_data->descriptor_ = -1;
  302. descriptor_data->shutdown_ = true;
  303. descriptor_lock.unlock();
  304. free_descriptor_state(descriptor_data);
  305. descriptor_data = 0;
  306. }
  307. }
  308. void epoll_reactor::run(bool block, op_queue<operation>& ops)
  309. {
  310. // This code relies on the fact that the task_io_service queues the reactor
  311. // task behind all descriptor operations generated by this function. This
  312. // means, that by the time we reach this point, any previously returned
  313. // descriptor operations have already been dequeued. Therefore it is now safe
  314. // for us to reuse and return them for the task_io_service to queue again.
  315. // Calculate a timeout only if timerfd is not used.
  316. int timeout;
  317. if (timer_fd_ != -1)
  318. timeout = block ? -1 : 0;
  319. else
  320. {
  321. mutex::scoped_lock lock(mutex_);
  322. timeout = block ? get_timeout() : 0;
  323. }
  324. // Block on the epoll descriptor.
  325. epoll_event events[128];
  326. int num_events = epoll_wait(epoll_fd_, events, 128, timeout);
  327. #if defined(ASIO_HAS_TIMERFD)
  328. bool check_timers = (timer_fd_ == -1);
  329. #else // defined(ASIO_HAS_TIMERFD)
  330. bool check_timers = true;
  331. #endif // defined(ASIO_HAS_TIMERFD)
  332. // Dispatch the waiting events.
  333. for (int i = 0; i < num_events; ++i)
  334. {
  335. void* ptr = events[i].data.ptr;
  336. if (ptr == &interrupter_)
  337. {
  338. // No need to reset the interrupter since we're leaving the descriptor
  339. // in a ready-to-read state and relying on edge-triggered notifications
  340. // to make it so that we only get woken up when the descriptor's epoll
  341. // registration is updated.
  342. #if defined(ASIO_HAS_TIMERFD)
  343. if (timer_fd_ == -1)
  344. check_timers = true;
  345. #else // defined(ASIO_HAS_TIMERFD)
  346. check_timers = true;
  347. #endif // defined(ASIO_HAS_TIMERFD)
  348. }
  349. #if defined(ASIO_HAS_TIMERFD)
  350. else if (ptr == &timer_fd_)
  351. {
  352. check_timers = true;
  353. }
  354. #endif // defined(ASIO_HAS_TIMERFD)
  355. else
  356. {
  357. // The descriptor operation doesn't count as work in and of itself, so we
  358. // don't call work_started() here. This still allows the io_service to
  359. // stop if the only remaining operations are descriptor operations.
  360. descriptor_state* descriptor_data = static_cast<descriptor_state*>(ptr);
  361. descriptor_data->set_ready_events(events[i].events);
  362. ops.push(descriptor_data);
  363. }
  364. }
  365. if (check_timers)
  366. {
  367. mutex::scoped_lock common_lock(mutex_);
  368. timer_queues_.get_ready_timers(ops);
  369. #if defined(ASIO_HAS_TIMERFD)
  370. if (timer_fd_ != -1)
  371. {
  372. itimerspec new_timeout;
  373. itimerspec old_timeout;
  374. int flags = get_timeout(new_timeout);
  375. timerfd_settime(timer_fd_, flags, &new_timeout, &old_timeout);
  376. }
  377. #endif // defined(ASIO_HAS_TIMERFD)
  378. }
  379. }
  380. void epoll_reactor::interrupt()
  381. {
  382. epoll_event ev = { 0, { 0 } };
  383. ev.events = EPOLLIN | EPOLLERR | EPOLLET;
  384. ev.data.ptr = &interrupter_;
  385. epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, interrupter_.read_descriptor(), &ev);
  386. }
  387. int epoll_reactor::do_epoll_create()
  388. {
  389. #if defined(EPOLL_CLOEXEC)
  390. int fd = epoll_create1(EPOLL_CLOEXEC);
  391. #else // defined(EPOLL_CLOEXEC)
  392. int fd = -1;
  393. errno = EINVAL;
  394. #endif // defined(EPOLL_CLOEXEC)
  395. if (fd == -1 && (errno == EINVAL || errno == ENOSYS))
  396. {
  397. fd = epoll_create(epoll_size);
  398. if (fd != -1)
  399. ::fcntl(fd, F_SETFD, FD_CLOEXEC);
  400. }
  401. if (fd == -1)
  402. {
  403. asio::error_code ec(errno,
  404. asio::error::get_system_category());
  405. asio::detail::throw_error(ec, "epoll");
  406. }
  407. return fd;
  408. }
  409. int epoll_reactor::do_timerfd_create()
  410. {
  411. #if defined(ASIO_HAS_TIMERFD)
  412. # if defined(TFD_CLOEXEC)
  413. int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
  414. # else // defined(TFD_CLOEXEC)
  415. int fd = -1;
  416. errno = EINVAL;
  417. # endif // defined(TFD_CLOEXEC)
  418. if (fd == -1 && errno == EINVAL)
  419. {
  420. fd = timerfd_create(CLOCK_MONOTONIC, 0);
  421. if (fd != -1)
  422. ::fcntl(fd, F_SETFD, FD_CLOEXEC);
  423. }
  424. return fd;
  425. #else // defined(ASIO_HAS_TIMERFD)
  426. return -1;
  427. #endif // defined(ASIO_HAS_TIMERFD)
  428. }
  429. epoll_reactor::descriptor_state* epoll_reactor::allocate_descriptor_state()
  430. {
  431. mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_);
  432. return registered_descriptors_.alloc();
  433. }
  434. void epoll_reactor::free_descriptor_state(epoll_reactor::descriptor_state* s)
  435. {
  436. mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_);
  437. registered_descriptors_.free(s);
  438. }
  439. void epoll_reactor::do_add_timer_queue(timer_queue_base& queue)
  440. {
  441. mutex::scoped_lock lock(mutex_);
  442. timer_queues_.insert(&queue);
  443. }
  444. void epoll_reactor::do_remove_timer_queue(timer_queue_base& queue)
  445. {
  446. mutex::scoped_lock lock(mutex_);
  447. timer_queues_.erase(&queue);
  448. }
  449. void epoll_reactor::update_timeout()
  450. {
  451. #if defined(ASIO_HAS_TIMERFD)
  452. if (timer_fd_ != -1)
  453. {
  454. itimerspec new_timeout;
  455. itimerspec old_timeout;
  456. int flags = get_timeout(new_timeout);
  457. timerfd_settime(timer_fd_, flags, &new_timeout, &old_timeout);
  458. return;
  459. }
  460. #endif // defined(ASIO_HAS_TIMERFD)
  461. interrupt();
  462. }
  463. int epoll_reactor::get_timeout()
  464. {
  465. // By default we will wait no longer than 5 minutes. This will ensure that
  466. // any changes to the system clock are detected after no longer than this.
  467. return timer_queues_.wait_duration_msec(5 * 60 * 1000);
  468. }
  469. #if defined(ASIO_HAS_TIMERFD)
  470. int epoll_reactor::get_timeout(itimerspec& ts)
  471. {
  472. ts.it_interval.tv_sec = 0;
  473. ts.it_interval.tv_nsec = 0;
  474. long usec = timer_queues_.wait_duration_usec(5 * 60 * 1000 * 1000);
  475. ts.it_value.tv_sec = usec / 1000000;
  476. ts.it_value.tv_nsec = usec ? (usec % 1000000) * 1000 : 1;
  477. return usec ? 0 : TFD_TIMER_ABSTIME;
  478. }
  479. #endif // defined(ASIO_HAS_TIMERFD)
  480. struct epoll_reactor::perform_io_cleanup_on_block_exit
  481. {
  482. explicit perform_io_cleanup_on_block_exit(epoll_reactor* r)
  483. : reactor_(r), first_op_(0)
  484. {
  485. }
  486. ~perform_io_cleanup_on_block_exit()
  487. {
  488. if (first_op_)
  489. {
  490. // Post the remaining completed operations for invocation.
  491. if (!ops_.empty())
  492. reactor_->io_service_.post_deferred_completions(ops_);
  493. // A user-initiated operation has completed, but there's no need to
  494. // explicitly call work_finished() here. Instead, we'll take advantage of
  495. // the fact that the task_io_service will call work_finished() once we
  496. // return.
  497. }
  498. else
  499. {
  500. // No user-initiated operations have completed, so we need to compensate
  501. // for the work_finished() call that the task_io_service will make once
  502. // this operation returns.
  503. reactor_->io_service_.work_started();
  504. }
  505. }
  506. epoll_reactor* reactor_;
  507. op_queue<operation> ops_;
  508. operation* first_op_;
  509. };
  510. epoll_reactor::descriptor_state::descriptor_state()
  511. : operation(&epoll_reactor::descriptor_state::do_complete)
  512. {
  513. }
  514. operation* epoll_reactor::descriptor_state::perform_io(uint32_t events)
  515. {
  516. mutex_.lock();
  517. perform_io_cleanup_on_block_exit io_cleanup(reactor_);
  518. mutex::scoped_lock descriptor_lock(mutex_, mutex::scoped_lock::adopt_lock);
  519. // Exception operations must be processed first to ensure that any
  520. // out-of-band data is read before normal data.
  521. static const int flag[max_ops] = { EPOLLIN, EPOLLOUT, EPOLLPRI };
  522. for (int j = max_ops - 1; j >= 0; --j)
  523. {
  524. if (events & (flag[j] | EPOLLERR | EPOLLHUP))
  525. {
  526. while (reactor_op* op = op_queue_[j].front())
  527. {
  528. if (op->perform())
  529. {
  530. op_queue_[j].pop();
  531. io_cleanup.ops_.push(op);
  532. }
  533. else
  534. break;
  535. }
  536. }
  537. }
  538. // The first operation will be returned for completion now. The others will
  539. // be posted for later by the io_cleanup object's destructor.
  540. io_cleanup.first_op_ = io_cleanup.ops_.front();
  541. io_cleanup.ops_.pop();
  542. return io_cleanup.first_op_;
  543. }
  544. void epoll_reactor::descriptor_state::do_complete(
  545. io_service_impl* owner, operation* base,
  546. const asio::error_code& ec, std::size_t bytes_transferred)
  547. {
  548. if (owner)
  549. {
  550. descriptor_state* descriptor_data = static_cast<descriptor_state*>(base);
  551. uint32_t events = static_cast<uint32_t>(bytes_transferred);
  552. if (operation* op = descriptor_data->perform_io(events))
  553. {
  554. op->complete(*owner, ec, 0);
  555. }
  556. }
  557. }
  558. } // namespace detail
  559. } // namespace asio
  560. #include "asio/detail/pop_options.hpp"
  561. #endif // defined(ASIO_HAS_EPOLL)
  562. #endif // ASIO_DETAIL_IMPL_EPOLL_REACTOR_IPP