Opened 11 years ago

Closed 11 years ago

#6005 closed Bugs (invalid)

Potential epoll fd leak in boost::asio::detail::epoll_reactor

Reported by: yafei.zhang@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.40.0 Severity: Problem
Keywords: asio linux epoll fd leak Cc:

Description

in boost/asio/detail/impl/epoll_reactor.ipp:

epoll_reactor::epoll_reactor(boost::asio::io_service& io_service)

: boost::asio::detail::service_base<epoll_reactor>(io_service),

io_service_(use_service<io_service_impl>(io_service)), mutex_(), epoll_fd_(do_epoll_create()), ------> epoll_fd_ may leak if the following member's initialization throws an exception timer_fd_(do_timerfd_create()), interrupter_(), ------> may throw because of EMFILE shutdown_(false)

{

Add the interrupter's descriptor to epoll. epoll_event ev = { 0, { 0 } }; ev.events = EPOLLIN | EPOLLERR | EPOLLET; ev.data.ptr = &interrupter_; epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, interrupter_.read_descriptor(), &ev); interrupter_.interrupt();

Add the timer descriptor to epoll. if (timer_fd_ != -1) {

ev.events = EPOLLIN | EPOLLERR; ev.data.ptr = &timer_fd_; epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, timer_fd_, &ev);

}

}

Attachments (1)

epoll_reactor.hpp.patch_1.40.0 (855 bytes ) - added by yafei.zhang@… 11 years ago.
only for boost 1.40.0

Download all attachments as: .zip

Change History (3)

by yafei.zhang@…, 11 years ago

only for boost 1.40.0

comment:1 by anonymous, 11 years ago

Version: Boost 1.47.0Boost 1.40.0

my patch only works, but it may not be the boost way and not graceful enough.

in reply to:  description comment:2 by anonymous, 11 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.