修复内存泄露问题
This commit is contained in:
parent
0765079661
commit
0ae4192e3a
@ -335,7 +335,7 @@ namespace a8
|
|||||||
}
|
}
|
||||||
epoll_event *events = new epoll_event[max_clients];
|
epoll_event *events = new epoll_event[max_clients];
|
||||||
while (!worker_thread_shutdown) {
|
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) {
|
for (int i = 0; i < nfds; ++i) {
|
||||||
a8::TcpSession* session = (a8::TcpSession*)events[i].data.ptr;
|
a8::TcpSession* session = (a8::TcpSession*)events[i].data.ptr;
|
||||||
if (events[i].events & EPOLLIN) {
|
if (events[i].events & EPOLLIN) {
|
||||||
|
@ -34,7 +34,6 @@ namespace a8
|
|||||||
|
|
||||||
TcpSession::~TcpSession()
|
TcpSession::~TcpSession()
|
||||||
{
|
{
|
||||||
Destory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TcpSession::SetMaxPacketLen(int max_packet_len)
|
void TcpSession::SetMaxPacketLen(int max_packet_len)
|
||||||
|
@ -32,6 +32,7 @@ namespace a8
|
|||||||
virtual void OnError(int);
|
virtual void OnError(int);
|
||||||
virtual void OnConnect();
|
virtual void OnConnect();
|
||||||
virtual void OnDisConnect();
|
virtual void OnDisConnect();
|
||||||
|
virtual void Destory();
|
||||||
bool Alive();
|
bool Alive();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -40,7 +41,6 @@ namespace a8
|
|||||||
void SetSocket(int sock);
|
void SetSocket(int sock);
|
||||||
bool AllocRecvBuf();
|
bool AllocRecvBuf();
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
virtual void Destory();
|
|
||||||
void _ForceClose();
|
void _ForceClose();
|
||||||
virtual void OnSocketRead(char* buf, unsigned int buflen);
|
virtual void OnSocketRead(char* buf, unsigned int buflen);
|
||||||
virtual void DecodePacket(char* buf, int& offset, unsigned int buflen);
|
virtual void DecodePacket(char* buf, int& offset, unsigned int buflen);
|
||||||
|
@ -29,6 +29,7 @@ namespace a8
|
|||||||
while (top_node_) {
|
while (top_node_) {
|
||||||
pdelnode = top_node_;
|
pdelnode = top_node_;
|
||||||
top_node_ = top_node_->next;
|
top_node_ = top_node_->next;
|
||||||
|
pdelnode->session->Destory();
|
||||||
delete pdelnode->session;
|
delete pdelnode->session;
|
||||||
delete pdelnode;
|
delete pdelnode;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace a8
|
|||||||
void WebSocketSession::Destory()
|
void WebSocketSession::Destory()
|
||||||
{
|
{
|
||||||
a8::TcpSession::Destory();
|
a8::TcpSession::Destory();
|
||||||
if (!decoded_buff_) {
|
if (decoded_buff_) {
|
||||||
free(decoded_buff_);
|
free(decoded_buff_);
|
||||||
decoded_buff_ = nullptr;
|
decoded_buff_ = nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user