This commit is contained in:
azw 2023-04-24 08:16:27 +00:00
parent afffb63a95
commit 2444f1b8e2

View File

@ -5,7 +5,6 @@
#include <a8/udpsession.h> #include <a8/udpsession.h>
static const int DEFAULT_MAX_PACKET_LEN = 1024 * 10;
static const int DEFAULT_MAX_RECV_BUFFERSIZE = 1024 * 64; static const int DEFAULT_MAX_RECV_BUFFERSIZE = 1024 * 64;
namespace a8 namespace a8
@ -13,7 +12,7 @@ namespace a8
UdpSession::UdpSession() UdpSession::UdpSession()
{ {
max_packet_len_ = DEFAULT_MAX_PACKET_LEN; max_packet_len_ = DEFAULT_MAX_RECV_BUFFERSIZE;
SetMaxPacketLen(max_packet_len_); SetMaxPacketLen(max_packet_len_);
} }
@ -33,7 +32,7 @@ namespace a8
void UdpSession::SetMaxPacketLen(int max_packet_len) void UdpSession::SetMaxPacketLen(int max_packet_len)
{ {
max_packet_len_ = std::max(max_packet_len, DEFAULT_MAX_PACKET_LEN); max_packet_len_ = std::max(max_packet_len, DEFAULT_MAX_RECV_BUFFERSIZE);
if (!recv_buff_) { if (!recv_buff_) {
recv_buff_ = (char *)malloc(max_packet_len_ + 1); recv_buff_ = (char *)malloc(max_packet_len_ + 1);
} }