Skip to content

Commit

Permalink
🐛 fix exten time
Browse files Browse the repository at this point in the history
  • Loading branch information
markparticle committed Jun 25, 2020
1 parent 5e2a074 commit f578366
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions code/server/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ void WebServer::DealListen_() {
}
}

bool WebServer::ExtentTime_(HttpConn* client) {
void WebServer::ExtentTime_(HttpConn* client) {
LOG_INFO("Extent client[%d] time", client->GetFd());
return timer_->adjust(client, time(nullptr) + 3 * TIME_SLOT);
timer_->adjust(client, time(nullptr) + 3 * TIME_SLOT);
}

void WebServer::DealRead_(int fd) {
ExtentTime_(&users_[fd]);
if(isReactor_) {
threadpool_->addTask(ExtentTime_, &users_[fd]);
threadpool_->addTask(ReadCallback, &users_[fd]);
} else {
ExtentTime_(&users_[fd]);
Expand All @@ -318,7 +318,6 @@ void WebServer::DealRead_(int fd) {
void WebServer::DealWrite_(int fd) {
ExtentTime_(&users_[fd]);
if(isReactor_) {
threadpool_->addTask(ExtentTime_, &users_[fd]);
threadpool_->addTask(WriteCallback, &users_[fd]);
} else {
users_[fd].write();
Expand Down
3 changes: 1 addition & 2 deletions code/server/webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ class WebServer {
void DealRead_(int fd);

void SendError_(int fd, const char*info);
bool ExtentTime_(HttpConn* client);


void ExtentTime_(HttpConn* client);
static void ReadCallback(HttpConn* client);
static void WriteCallback(HttpConn* client);
static void SetSignal(int sig, void(handler)(int), bool restart = true);
Expand Down
3 changes: 1 addition & 2 deletions code/timer/heaptimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ void HeapTimer::del(HttpConn* node) {
hash_.erase(node);
}

bool HeapTimer::adjust(HttpConn* node, time_t newExpires) {
void HeapTimer::adjust(HttpConn* node, time_t newExpires) {
assert(hash_.count(node) > 0);
node->SetExpires(newExpires);
siftdown_(hash_[node], heap_.size());
return true;
}

void HeapTimer::tick() {
Expand Down
2 changes: 1 addition & 1 deletion code/timer/heaptimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HeapTimer {

~HeapTimer() { clear(); }

bool adjust(HttpConn* node, time_t newExpires);
void adjust(HttpConn* node, time_t newExpires);

void add(HttpConn* node, time_t timeSlot);

Expand Down

0 comments on commit f578366

Please sign in to comment.