node: use shared_ptr to manage Sockets

This commit is contained in:
Adrien Béraud committed 2017-12-02 16:03:27 +01:00
1 parent f9d48cd15a
commit d2f91af946
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -134,18 +134,18 @@ Node::openSocket(SocketCb&& cb)
if (++transaction_id == 0)
transaction_id = 1;
auto sock = Socket(std::move(cb));
auto sock = std::make_shared<Socket>(std::move(cb));
auto s = sockets_.emplace(transaction_id, std::move(sock));
if (not s.second)
s.first->second = std::move(sock);
return transaction_id;
}
Socket*
Sp<Socket>
Node::getSocket(Tid id)
{
auto it = sockets_.find(id);
return it == sockets_.end() ? nullptr : &it->second;
return it == sockets_.end() ? nullptr : it->second;
}
void