Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32829 Avoid getPeerEndpoint refetchnig peer name #19212

Merged
Merged
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
16 changes: 4 additions & 12 deletions system/jlib/jsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@ class CSocket: public ISocket, public CInterface
enum { ss_open, ss_shutdown, ss_close, ss_pre_open } state;
T_SOCKET sock;
// char* hostname; // host address
unsigned short hostport; // host port
unsigned short hostport; // host port (NB: this is the peer port if an attached socket)
unsigned short localPort;
SOCKETMODE sockmode;
IpAddress targetip;
IpAddress targetip; // NB: this is peer if an attached socket
SocketEndpoint returnep; // set by set_return_addr

MCASTREQ * mcastreq;
Expand Down Expand Up @@ -1472,16 +1472,8 @@ SocketEndpoint &CSocket::getPeerEndpoint(SocketEndpoint &ep)
if (sockmode==sm_udp_server) { // udp server
ep.set(returnep);
}
else {
DEFINE_SOCKADDR(u);
socklen_t ul = sizeof(u);
if (::getpeername(sock,&u.sa, &ul)<0) {
DBGLOG("getpeername failed %d",SOCKETERRNO());
ep.set(NULL, 0);
}
else
getSockAddrEndpoint(u,ul,ep);
}
else
ep.set(hostport, targetip); // NB: if this is an attached socket, targetip/hostpost are the peer
return ep;
}

Expand Down
Loading