mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Pass SharedBuffer as value to increment reference count
This should fix #6332 Refcount is not increased due to reference, it can make this refcount incorrect in a multithread context
This commit is contained in:
parent
04158d0c84
commit
6fd8a27c91
@ -1098,7 +1098,7 @@ bool ConnectionReceiveThread::checkIncomingBuffers(Channel *channel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, u16 peer_id, u8 channelnum, bool reliable)
|
SharedBuffer<u8> packetdata, u16 peer_id, u8 channelnum, bool reliable)
|
||||||
{
|
{
|
||||||
PeerHelper peer = m_connection->getPeerNoEx(peer_id);
|
PeerHelper peer = m_connection->getPeerNoEx(peer_id);
|
||||||
|
|
||||||
@ -1137,7 +1137,7 @@ const ConnectionReceiveThread::PacketTypeHandler
|
|||||||
};
|
};
|
||||||
|
|
||||||
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *channel,
|
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum, bool reliable)
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum, bool reliable)
|
||||||
{
|
{
|
||||||
if (packetdata.getSize() < 2)
|
if (packetdata.getSize() < 2)
|
||||||
throw InvalidIncomingDataException("packetdata.getSize() < 2");
|
throw InvalidIncomingDataException("packetdata.getSize() < 2");
|
||||||
@ -1247,7 +1247,7 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *chan
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Original(Channel *channel,
|
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Original(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum, bool reliable)
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum, bool reliable)
|
||||||
{
|
{
|
||||||
if (packetdata.getSize() <= ORIGINAL_HEADER_SIZE)
|
if (packetdata.getSize() <= ORIGINAL_HEADER_SIZE)
|
||||||
throw InvalidIncomingDataException
|
throw InvalidIncomingDataException
|
||||||
@ -1261,7 +1261,7 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Original(Channel *cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Split(Channel *channel,
|
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Split(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum, bool reliable)
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum, bool reliable)
|
||||||
{
|
{
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
|
|
||||||
@ -1292,7 +1292,7 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Split(Channel *channe
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Reliable(Channel *channel,
|
SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Reliable(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum, bool reliable)
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum, bool reliable)
|
||||||
{
|
{
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
||||||
|
@ -118,26 +118,26 @@ private:
|
|||||||
channelnum: channel on which the packet was sent
|
channelnum: channel on which the packet was sent
|
||||||
reliable: true if recursing into a reliable packet
|
reliable: true if recursing into a reliable packet
|
||||||
*/
|
*/
|
||||||
SharedBuffer<u8> processPacket(Channel *channel, SharedBuffer<u8> &packetdata,
|
SharedBuffer<u8> processPacket(Channel *channel, SharedBuffer<u8> packetdata,
|
||||||
u16 peer_id, u8 channelnum, bool reliable);
|
u16 peer_id, u8 channelnum, bool reliable);
|
||||||
|
|
||||||
SharedBuffer<u8> handlePacketType_Control(Channel *channel,
|
SharedBuffer<u8> handlePacketType_Control(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum,
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum,
|
||||||
bool reliable);
|
bool reliable);
|
||||||
SharedBuffer<u8> handlePacketType_Original(Channel *channel,
|
SharedBuffer<u8> handlePacketType_Original(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum,
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum,
|
||||||
bool reliable);
|
bool reliable);
|
||||||
SharedBuffer<u8> handlePacketType_Split(Channel *channel,
|
SharedBuffer<u8> handlePacketType_Split(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum,
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum,
|
||||||
bool reliable);
|
bool reliable);
|
||||||
SharedBuffer<u8> handlePacketType_Reliable(Channel *channel,
|
SharedBuffer<u8> handlePacketType_Reliable(Channel *channel,
|
||||||
SharedBuffer<u8> &packetdata, Peer *peer, u8 channelnum,
|
SharedBuffer<u8> packetdata, Peer *peer, u8 channelnum,
|
||||||
bool reliable);
|
bool reliable);
|
||||||
|
|
||||||
struct PacketTypeHandler
|
struct PacketTypeHandler
|
||||||
{
|
{
|
||||||
SharedBuffer<u8> (ConnectionReceiveThread::*handler)(Channel *channel,
|
SharedBuffer<u8> (ConnectionReceiveThread::*handler)(Channel *channel,
|
||||||
SharedBuffer<u8> &packet, Peer *peer, u8 channelnum,
|
SharedBuffer<u8> packet, Peer *peer, u8 channelnum,
|
||||||
bool reliable);
|
bool reliable);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user