diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2011-05-26 20:38:52 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2011-05-26 20:38:52 +0000 |
| commit | edab69a1a24d284218e47605d9a63dc3250e0b6e (patch) | |
| tree | f22dc8abd292df7e2888cba5f4a26c447c0f19b1 /cpp/src/qpid/sys/posix/Socket.cpp | |
| parent | a2e5523f68054f4361e6a1b2fdd8eceb300458c1 (diff) | |
| download | qpid-python-edab69a1a24d284218e47605d9a63dc3250e0b6e.tar.gz | |
QPID-3282: Potential bug in circular connection detection:
- make sure that we compare numeric addresses of both local and remote ends
of the connection (previously the remote end could be an unresolved hostname)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1128068 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/posix/Socket.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/posix/Socket.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cpp/src/qpid/sys/posix/Socket.cpp b/cpp/src/qpid/sys/posix/Socket.cpp index be757ba00f..aa25f8062d 100644 --- a/cpp/src/qpid/sys/posix/Socket.cpp +++ b/cpp/src/qpid/sys/posix/Socket.cpp @@ -122,7 +122,14 @@ void Socket::connect(const std::string& host, const std::string& port) const void Socket::connect(const SocketAddress& addr) const { - peername = addr.asString(); + // The display name for an outbound connection needs to be the name that was specified + // for the address rather than a resolved IP address as we don't know which of + // the IP addresses is actually the one that will be connected to. + peername = addr.asString(false); + + // However the string we compare with the local port must be numeric or it might not + // match when it should as getLocalAddress() will always be numeric + std::string connectname = addr.asString(); createSocket(addr); @@ -145,7 +152,7 @@ void Socket::connect(const SocketAddress& addr) const // Raise an error if we see such a connection, since we know there is // no listener on the peer address. // - if (getLocalAddress() == getPeerAddress()) { + if (getLocalAddress() == connectname) { close(); throw Exception(QPID_MSG("Connection refused: " << peername)); } |
