mirror of https://gitee.com/bigwinds/arangodb
re-enable shared_from_this
This commit is contained in:
parent
6d80a77005
commit
fc0170f2a8
|
@ -46,11 +46,7 @@ using namespace arangodb::rest;
|
|||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
GeneralServer::~GeneralServer() {
|
||||
for (auto& task : _listenTasks) {
|
||||
delete task;
|
||||
}
|
||||
}
|
||||
GeneralServer::~GeneralServer() {}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
|
@ -106,7 +102,7 @@ bool GeneralServer::openEndpoint(Endpoint* endpoint) {
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<ListenTask> task(new GeneralListenTask(
|
||||
std::shared_ptr<ListenTask> task(new GeneralListenTask(
|
||||
SchedulerFeature::SCHEDULER->eventLoop(), this, endpoint, protocolType));
|
||||
task->start();
|
||||
|
||||
|
@ -114,7 +110,6 @@ bool GeneralServer::openEndpoint(Endpoint* endpoint) {
|
|||
return false;
|
||||
}
|
||||
|
||||
_listenTasks.emplace_back(task.get());
|
||||
task.release();
|
||||
_listenTasks.emplace_back(std::move(task));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class GeneralServer {
|
|||
bool openEndpoint(Endpoint* endpoint);
|
||||
|
||||
private:
|
||||
std::vector<ListenTask*> _listenTasks;
|
||||
std::vector<std::shared_ptr<ListenTask>> _listenTasks;
|
||||
EndpointList const* _endpointList = nullptr;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -63,8 +63,9 @@ void ListenTask::start() {
|
|||
|
||||
TRI_ASSERT(_bound);
|
||||
|
||||
// auto self = shared_from_this();
|
||||
_handler = [this](boost::system::error_code const& ec) {
|
||||
auto self = shared_from_this();
|
||||
|
||||
_handler = [this, self](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);
|
||||
|
@ -111,7 +112,7 @@ void ListenTask::start() {
|
|||
acceptorCopy->asyncAccept(_handler);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
_acceptor->asyncAccept(_handler);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue