Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions evpp/TcpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ class TcpClientEventLoopTmpl {

int startConnect() {
if (channel == NULL || channel->isClosed()) {
// Re-resolve DNS to get the latest IP address
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add if (reconn_setting && reconn_setting->cur_retry_cnt > 1) to use the old address on the first reconnection to speed up the reconnection process.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int connfd = -1;
if (reconn_setting && reconn_setting->cur_retry_cnt > 1) {
    connfd = createsocket(remote_port, remote_host.c_str());
} else {
    connfd = createsocket(&remote_addr.sa);
}

memset(&remote_addr, 0, sizeof(remote_addr));
int ret = sockaddr_set_ipport(&remote_addr, remote_host.c_str(), remote_port);
if (ret != 0) {
hloge("sockaddr_set_ipport %s:%d failed!\n", remote_host.c_str(), remote_port);
return ret;
}

int connfd = createsocket(&remote_addr.sa);
if (connfd < 0) {
hloge("createsocket %s:%d return %d!\n", remote_host.c_str(), remote_port, connfd);
Expand Down