Subject: [Boost-bugs] [Boost C++ Libraries] #3238: asio, kqueue_reactor, result of kevent() isn't checked for error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-07-02 18:02:09
#3238: asio, kqueue_reactor, result of kevent() isn't checked for error
-------------------------------+--------------------------------------------
Reporter: devel@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: | Component: asio
Version: Boost 1.38.0 | Severity: Problem
Keywords: asio kqueue |
-------------------------------+--------------------------------------------
No kevent() result checking.
{{{
asio/detail/kqueue_reactor.hpp:438
...
wait_in_progress_ = true;
lock.unlock();
// Block on the kqueue descriptor.
struct kevent events[128];
int num_events = (block || need_kqueue_wait_)
? kevent(kqueue_fd_, 0, 0, events, 128, timeout)
: 0;
lock.lock();
wait_in_progress_ = false;
// Block signals while performing operations.
boost::asio::detail::signal_blocker sb;
// Dispatch the waiting events.
for (int i = 0; i < num_events; ++i)
{
// processing events
...
}}}
Here is '''int num_events = kevent(kqueue_fd_, ...''', then '''for (int i
= 0; i < num_events''' but '''num_events''' can be -1 here, and all this
code makes no sense then.
Suppose we have such code:
{{{
smtp_queue q("/var/spool/smtpq");
asio::io_service io_service;
smtp_server s(io_service, 25, q);
smtp_client c(io_service, "target.host", "smtp", q);
if(fork()) exit(0); // daemonize
io_service.run();
}}}
Here we call '''fork()''' then '''io_service.run()'''.
fork doesn't copy kqueue descriptor and subsequent kevent(fd,...) calls
return -1 with errno = 9 (EBADFD, "Bad file descriptor").
This case makes asio's kqueue reactor hangup.
Probably, kevent() result should be checked for error and exception thrown
if any.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3238> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC