Skip to content

Commit

Permalink
Network: fix a concurrency problem, by re-adding a copy in Connection…
Browse files Browse the repository at this point in the history
…Command
  • Loading branch information
nerzhul committed Sep 4, 2017
1 parent a383eb0 commit 5b04f5e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/network/connection.h
Expand Up @@ -330,6 +330,18 @@ struct ConnectionCommand
bool raw = false;

ConnectionCommand() = default;
ConnectionCommand &operator=(const ConnectionCommand &other)
{
type = other.type;
address = other.address;
peer_id = other.peer_id;
channelnum = other.channelnum;
// We must copy the buffer here to prevent race condition
data = SharedBuffer<u8>(*other.data, other.data.getSize());
reliable = other.reliable;
raw = other.reliable;

This comment has been minimized.

Copy link
@t0ny2

t0ny2 Sep 4, 2017

Contributor

should that not be other.raw ?

This comment has been minimized.

Copy link
@nerzhul

nerzhul Sep 4, 2017

Author Member

you are my hero ? i test it to ensure it's what causes problem :p

This comment has been minimized.

Copy link
@nerzhul

nerzhul Sep 4, 2017

Author Member

nice it was my connection problem cause, thanks for the tip :)

return *this;
}

void serve(Address address_)
{
Expand Down

0 comments on commit 5b04f5e

Please sign in to comment.