Skip to content
Permalink
Browse files

Network: fix a concurrency problem, by re-adding a copy in Connection…

…Command
  • Loading branch information...
nerzhul committed Sep 4, 2017
1 parent a383eb0 commit 5b04f5e7d231437b534f4cad39da78624d97c584
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/network/connection.h
@@ -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_)
{

0 comments on commit 5b04f5e

Please sign in to comment.
You can’t perform that action at this time.