From 1de0b1b2416f947ebea1418f627cb02e957401b7 Mon Sep 17 00:00:00 2001 From: "gaoziqianghi@163.com" Date: Thu, 2 Dec 2021 17:36:40 +0800 Subject: [PATCH 1/2] fix unreasonable function name --- webserver.cpp | 4 ++-- webserver.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/webserver.cpp b/webserver.cpp index a9dfae0b..0d7e410a 100644 --- a/webserver.cpp +++ b/webserver.cpp @@ -197,7 +197,7 @@ void WebServer::deal_timer(util_timer *timer, int sockfd) LOG_INFO("close fd %d", users_timer[sockfd].sockfd); } -bool WebServer::dealclinetdata() +bool WebServer::dealclientdata() { struct sockaddr_in client_address; socklen_t client_addrlength = sizeof(client_address); @@ -395,7 +395,7 @@ void WebServer::eventLoop() //处理新到的客户连接 if (sockfd == m_listenfd) { - bool flag = dealclinetdata(); + bool flag = dealclientdata(); if (false == flag) continue; } diff --git a/webserver.h b/webserver.h index 7381a13e..12e2be7d 100644 --- a/webserver.h +++ b/webserver.h @@ -38,7 +38,7 @@ class WebServer void timer(int connfd, struct sockaddr_in client_address); void adjust_timer(util_timer *timer); void deal_timer(util_timer *timer, int sockfd); - bool dealclinetdata(); + bool dealclientdata(); bool dealwithsignal(bool& timeout, bool& stop_server); void dealwithread(int sockfd); void dealwithwrite(int sockfd); From 2b995226fdedfe7e2b485d27003d90db5fdb4bf1 Mon Sep 17 00:00:00 2001 From: "gaoziqianghi@163.com" Date: Wed, 8 Dec 2021 20:26:33 +0800 Subject: [PATCH 2/2] complete delete pointer security --- timer/lst_timer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/timer/lst_timer.cpp b/timer/lst_timer.cpp index 7efba9bd..578c9a5b 100644 --- a/timer/lst_timer.cpp +++ b/timer/lst_timer.cpp @@ -71,6 +71,7 @@ void sort_timer_lst::del_timer(util_timer *timer) if ((timer == head) && (timer == tail)) { delete timer; + timer = nullptr; head = NULL; tail = NULL; return; @@ -80,6 +81,7 @@ void sort_timer_lst::del_timer(util_timer *timer) head = head->next; head->prev = NULL; delete timer; + timer = nullptr; return; } if (timer == tail) @@ -87,11 +89,13 @@ void sort_timer_lst::del_timer(util_timer *timer) tail = tail->prev; tail->next = NULL; delete timer; + timer = nullptr; return; } timer->prev->next = timer->next; timer->next->prev = timer->prev; delete timer; + timer = nullptr; } void sort_timer_lst::tick() {