Skip to content

Commit

Permalink
Merge pull request #19212 from jakesmith/HPCC-32829-peername
Browse files Browse the repository at this point in the history
HPCC-32829 Avoid getPeerEndpoint refetchnig peer name

Reviewed-by: Mark Kelly [email protected]
Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Oct 18, 2024
2 parents af90830 + 41ba3c9 commit e52b380
Showing 1 changed file with 4 additions and 12 deletions.
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

0 comments on commit e52b380

Please sign in to comment.