Skip to content

Commit 5b04f5e

Browse files
committedSep 4, 2017
Network: fix a concurrency problem, by re-adding a copy in ConnectionCommand
1 parent a383eb0 commit 5b04f5e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎src/network/connection.h

+12
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@ struct ConnectionCommand
330330
bool raw = false;
331331

332332
ConnectionCommand() = default;
333+
ConnectionCommand &operator=(const ConnectionCommand &other)
334+
{
335+
type = other.type;
336+
address = other.address;
337+
peer_id = other.peer_id;
338+
channelnum = other.channelnum;
339+
// We must copy the buffer here to prevent race condition
340+
data = SharedBuffer<u8>(*other.data, other.data.getSize());
341+
reliable = other.reliable;
342+
raw = other.reliable;
Has conversations. Original line has conversations.
343+
return *this;
344+
}
333345

334346
void serve(Address address_)
335347
{

0 commit comments

Comments
 (0)
Please sign in to comment.