Skip to content

Commit

Permalink
network revised
Browse files Browse the repository at this point in the history
  • Loading branch information
cheniujh committed Aug 10, 2024
1 parent 2d7ca3a commit eefa127
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/net/src/worker_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ void* WorkerThread::ThreadMain() {
}

if (((pfe->mask & kErrorEvent) != 0) || (should_close != 0)) {
//check if this conn disconnected from being blocked by blpop/brpop
dynamic_cast<net::DispatchThread*>(server_thread_)->ClosingConnCheckForBlrPop(std::dynamic_pointer_cast<net::RedisConn>(in_conn));
net_multiplexer_->NetDelEvent(pfe->fd, 0);
CloseFd(in_conn);
in_conn = nullptr;
Expand Down Expand Up @@ -235,7 +233,6 @@ void WorkerThread::DoCronTask() {
}
conns_.clear();
deleting_conn_ipport_.clear();
return;
}

auto iter = conns_.begin();
Expand Down Expand Up @@ -274,9 +271,11 @@ void WorkerThread::DoCronTask() {
}
}
for (const auto& conn : to_close) {
net_multiplexer_->NetDelEvent(conn->fd(), 0);
CloseFd(conn);
}
for (const auto& conn : to_timeout) {
net_multiplexer_->NetDelEvent(conn->fd(), 0);
CloseFd(conn);
server_thread_->handle_->FdTimeoutHandle(conn->fd(), conn->ip_port());
}
Expand Down Expand Up @@ -304,6 +303,8 @@ bool WorkerThread::TryKillConn(const std::string& ip_port) {
void WorkerThread::CloseFd(const std::shared_ptr<NetConn>& conn) {
close(conn->fd());
if (auto dispatcher = dynamic_cast<DispatchThread *>(server_thread_); dispatcher != nullptr ) {
//check if this conn disconnected from being blocked by blpop/brpop
dispatcher->ClosingConnCheckForBlrPop(std::dynamic_pointer_cast<net::RedisConn>(conn));
dispatcher->RemoveWatchKeys(conn);
}
server_thread_->handle_->FdClosedHandle(conn->fd(), conn->ip_port());
Expand Down

0 comments on commit eefa127

Please sign in to comment.