Skip to content

Commit

Permalink
add default value for need_destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
lzydmxy committed Dec 11, 2023
1 parent 0e7a657 commit 130daf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/Service/ForwardingConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void ForwardingConnectionHandler::onSocketReadable(const AutoPtr<ReadableNotific
case ForwardType::Operation:
current_package.is_done = false;
break;
case ForwardType::Destroy:
LOG_WARNING(log, "Got destroy forward package type {}", forward_type);
destroyMe();
return;
default:
LOG_ERROR(log, "Got unexpected forward package type {}", forward_type);
destroyMe();
Expand Down Expand Up @@ -294,9 +298,9 @@ void ForwardingConnectionHandler::onSocketWritable(const AutoPtr<WritableNotific

try
{
if (is_destroy)
if (need_destroy)
{
LOG_INFO(log, "Get destroy response!");
LOG_WARNING(log, "The connection for server {} client {} is stale, will close it", server_id, client_id);
delete this;
return;
}
Expand Down Expand Up @@ -382,7 +386,7 @@ void ForwardingConnectionHandler::sendResponse(ForwardResponsePtr response)

if (response->forwardType() == ForwardType::Destroy)
{
is_destroy = true;
need_destroy = true;
}

WriteBufferFromFiFoBuffer buf;
Expand Down
4 changes: 2 additions & 2 deletions src/Service/ForwardingConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class ForwardingConnectionHandler
void processRaftRequest(ForwardRequestPtr request);
void processSessions(ForwardRequestPtr request);

// mark is stop by dispatcher
bool is_destroy;
// The connection is stale and need destroyed
bool need_destroy{false};
};

}

0 comments on commit 130daf6

Please sign in to comment.