[TE] fix(transfer): correct handshake daemon initialization order (#765)

Fix incorrect initialization sequence in startHandshakeDaemon by moving handshake_plugin_->startDaemon() call after callback registrations to ensure proper setup before daemon starts.

Signed-off-by: staryxchen <staryxchen@tencent.com>
This commit is contained in:
Stary 2025-08-28 19:54:18 +08:00 committed by GitHub
parent 6fbb85b37c
commit fc04a31cae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -672,11 +672,6 @@ int TransferMetadata::getRpcMetaEntry(const std::string &server_name,
int TransferMetadata::startHandshakeDaemon(
OnReceiveHandShake on_receive_handshake, uint16_t listen_port, int sockfd) {
int rc = handshake_plugin_->startDaemon(listen_port, sockfd);
if (rc != 0) {
return rc;
}
handshake_plugin_->registerOnConnectionCallBack(
[on_receive_handshake](const Json::Value &peer,
Json::Value &local) -> int {
@ -693,6 +688,11 @@ int TransferMetadata::startHandshakeDaemon(
[this](const Json::Value &peer, Json::Value &local) -> int {
return receivePeerNotify(peer, local);
});
int rc = handshake_plugin_->startDaemon(listen_port, sockfd);
if (rc != 0) {
return rc;
}
return 0;
}