修复内存泄露问题

This commit is contained in:
aozhiwei 2019-05-29 14:23:47 +08:00
parent 0765079661
commit 0ae4192e3a
5 changed files with 4 additions and 4 deletions

View File

@ -335,7 +335,7 @@ namespace a8
}
epoll_event *events = new epoll_event[max_clients];
while (!worker_thread_shutdown) {
int nfds = ::epoll_wait(epoll_fd, events, max_clients, -1);
int nfds = ::epoll_wait(epoll_fd, events, max_clients, 1000 * 10);
for (int i = 0; i < nfds; ++i) {
a8::TcpSession* session = (a8::TcpSession*)events[i].data.ptr;
if (events[i].events & EPOLLIN) {

View File

@ -34,7 +34,6 @@ namespace a8
TcpSession::~TcpSession()
{
Destory();
}
void TcpSession::SetMaxPacketLen(int max_packet_len)

View File

@ -32,6 +32,7 @@ namespace a8
virtual void OnError(int);
virtual void OnConnect();
virtual void OnDisConnect();
virtual void Destory();
bool Alive();
protected:
@ -40,7 +41,6 @@ namespace a8
void SetSocket(int sock);
bool AllocRecvBuf();
virtual void Reset();
virtual void Destory();
void _ForceClose();
virtual void OnSocketRead(char* buf, unsigned int buflen);
virtual void DecodePacket(char* buf, int& offset, unsigned int buflen);

View File

@ -29,6 +29,7 @@ namespace a8
while (top_node_) {
pdelnode = top_node_;
top_node_ = top_node_->next;
pdelnode->session->Destory();
delete pdelnode->session;
delete pdelnode;
}

View File

@ -75,7 +75,7 @@ namespace a8
void WebSocketSession::Destory()
{
a8::TcpSession::Destory();
if (!decoded_buff_) {
if (decoded_buff_) {
free(decoded_buff_);
decoded_buff_ = nullptr;
}