mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
node: use shared_ptr to manage Sockets
This commit is contained in:
1 parent
f9d48cd15a
commit
d2f91af946
2 files changed
+5
-5
No files matched your search
+3
-3
@@ -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
|
||||
|
||||
Reference in new issue
Block a user