Fix RPC network server segfault

Reviewers: teon.banek, buda

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1139
This commit is contained in:
Matej Ferencevic
2018-01-24 16:43:42 +01:00
parent fc20ddcd25
commit 60d7be5c19
4 changed files with 29 additions and 10 deletions

View File

@@ -73,8 +73,10 @@ class Server {
socket_.endpoint().port())
<< std::endl;
io::network::SocketEventDispatcher<ConnectionAcceptor> dispatcher;
ConnectionAcceptor acceptor(socket_, *this);
std::vector<std::unique_ptr<ConnectionAcceptor>> acceptors;
acceptors.emplace_back(std::make_unique<ConnectionAcceptor>(socket_, *this));
auto &acceptor = *acceptors.back().get();
io::network::SocketEventDispatcher<ConnectionAcceptor> dispatcher{acceptors};
dispatcher.AddListener(socket_.fd(), acceptor, EPOLLIN);
while (alive_) {
dispatcher.WaitAndProcessEvents();