[Boost-bugs] [Boost C++ Libraries] #2870: async_connect Handler invocation from deleted socket

Subject: [Boost-bugs] [Boost C++ Libraries] #2870: async_connect Handler invocation from deleted socket
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-03-19 08:27:43


#2870: async_connect Handler invocation from deleted socket
--------------------------------------------------------+-------------------
 Reporter: Benjamin Carlyle <ben.carlyle_at_[hidden]> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: Boost 1.39.0 | Component: asio
  Version: Boost 1.38.0 | Severity: Problem
 Keywords: |
--------------------------------------------------------+-------------------
 I have a program that creates several boost::asio::ip::tcp::socket
 instances and calls async_connect on them in parallel. The first to
 successfully establish a connection is used to communicate. The rest are
 deleted. This is a high availability environment where we don't want to be
 stuck waiting for a server that might currently be down.

 When multiple connection attempts are found to be successful in the same
 invocation of epoll_wait I find that callbacks for the deleted socket
 instances are still invoked. The sequence of events appears to be as
 follows:

 1. epoll_wait is called, yielding multiple successful connections

 2. The perform_operation() function is called for each relevant entry in
 the write_op_queue

 3. There are no cancellations, and the read, write, and except op queues
 are now empty

 4. The complete call of each operation is invoked, turning the operation
 into a post

 5. The first handler is invoked, destroying all sockets except the first
 one. The destructor of the destroyed sockets look in the write_op_queue
 for jobs to cancel, but find none.

 6. The second handler is invoked despite its related socket having already
 been destroyed.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2870>
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:49:59 UTC