mirror of https://gitee.com/bigwinds/arangodb
try to work around races
This commit is contained in:
parent
ab8a4ec176
commit
0d964bc704
|
@ -61,6 +61,18 @@ void ListenTask::start() {
|
|||
}
|
||||
|
||||
_handler = [this](boost::system::error_code const& ec) {
|
||||
// copy the shared_ptr so nobody can delete the Acceptor while the
|
||||
// callback is running
|
||||
std::shared_ptr<Acceptor> acceptorCopy(_acceptor);
|
||||
|
||||
if (acceptorCopy == nullptr) {
|
||||
// ListenTask already stopped
|
||||
return;
|
||||
}
|
||||
|
||||
// now it is safe to use _acceptor
|
||||
TRI_ASSERT(_acceptor != nullptr);
|
||||
|
||||
if (ec) {
|
||||
if (ec == boost::asio::error::operation_aborted) {
|
||||
return;
|
||||
|
|
|
@ -60,7 +60,7 @@ class ListenTask : virtual public rest::Task {
|
|||
|
||||
boost::asio::io_service* _ioService;
|
||||
|
||||
std::unique_ptr<Acceptor> _acceptor;
|
||||
std::shared_ptr<Acceptor> _acceptor;
|
||||
|
||||
std::function<void(boost::system::error_code const&)> _handler;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue