DHT nodes can NOT share a receive buffer
While the simulation is single threaded, because async_receive_from_impl uses post() to invoke the receive handler it is possible for multiple receive handlers to be queued up in the io_service at the same time. If this happens with a shared receive buffer the last packet received will overwrite all the other packets before they are handled. The use of post() is necessary to avoid unbounded recursion in the read handler so each node must get its own buffer.
This commit is contained in:
parent
4e86c2257a
commit
7b5bdc3be9
|
@ -254,14 +254,9 @@ private:
|
||||||
#endif
|
#endif
|
||||||
lt::udp::endpoint m_ep;
|
lt::udp::endpoint m_ep;
|
||||||
bool m_add_dead_nodes;
|
bool m_add_dead_nodes;
|
||||||
// since the simulation is single-threaded, only one socket at a time will
|
char m_buffer[1300];
|
||||||
// actually be receiving a packet, so we can get away with just allocating
|
|
||||||
// one receive buffer, shared by all nodes
|
|
||||||
static char m_buffer[1300];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
char dht_node::m_buffer[1300];
|
|
||||||
|
|
||||||
dht_network::dht_network(sim::simulation& sim, int num_nodes)
|
dht_network::dht_network(sim::simulation& sim, int num_nodes)
|
||||||
{
|
{
|
||||||
m_sett.ignore_dark_internet = false;
|
m_sett.ignore_dark_internet = false;
|
||||||
|
|
Loading…
Reference in New Issue