if(m_max_packets_per_second < 100)
m_max_packets_per_second += 2;
} else {
- if(m_max_packets_per_second > 5)
- m_max_packets_per_second *= 0.5;
+ m_max_packets_per_second *= 0.8;
+ if(m_max_packets_per_second < 10)
+ m_max_packets_per_second = 10;
}
}
// TODO: We can not know how many layers of header there are.
// For now, just assume there are no other than the base headers.
u32 packet_maxsize = datasize + BASE_HEADER_SIZE;
- Buffer<u8> packetdata(packet_maxsize);
+ SharedBuffer<u8> packetdata(packet_maxsize);
bool single_wait_done = false;
{
try{
return m_event_queue.pop_front(timeout_ms);
- } catch(ItemNotFoundException &e){
+ } catch(ItemNotFoundException &ex){
ConnectionEvent e;
e.type = CONNEVENT_NONE;
return e;
putCommand(c);
}
-u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
+u32 Connection::Receive(u16 &peer_id, SharedBuffer<u8> &data)
{
for(;;){
ConnectionEvent e = waitEvent(m_bc_receive_timeout);
throw NoIncomingDataException("No incoming data");
case CONNEVENT_DATA_RECEIVED:
peer_id = e.peer_id;
- memcpy(data, *e.data, e.data.getSize());
+ data = SharedBuffer<u8>(e.data);
return e.data.getSize();
case CONNEVENT_PEER_ADDED: {
Peer tmp(e.peer_id, e.address);