You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2011/05/26 22:38:35 UTC

svn commit: r1128066 - /qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp

Author: astitcher
Date: Thu May 26 20:38:35 2011
New Revision: 1128066

URL: http://svn.apache.org/viewvc?rev=1128066&view=rev
Log:
NO-JIRA: Small improvements to Socket code
- Rewrite SocketAddress::operator= in terms of copy constructor
- Improve error diagnostic

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp?rev=1128066&r1=1128065&r2=1128066&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp Thu May 26 20:38:35 2011
@@ -27,6 +27,8 @@
 #include <string.h>
 #include <netdb.h>
 
+#include <algorithm>
+
 namespace qpid {
 namespace sys {
 
@@ -46,15 +48,9 @@ SocketAddress::SocketAddress(const Socke
 
 SocketAddress& SocketAddress::operator=(const SocketAddress& sa)
 {
-    if (&sa != this) {
-        host = sa.host;
-        port = sa.port;
-
-        if (addrInfo) {
-            ::freeaddrinfo(addrInfo);
-            addrInfo = 0;
-        }
-    }
+    SocketAddress temp(sa);
+
+    std::swap(temp, *this);
     return *this;
 }
 
@@ -88,7 +84,7 @@ const ::addrinfo& getAddrInfo(const Sock
 
         int n = ::getaddrinfo(node, service, &hints, &sa.addrInfo);
         if (n != 0)
-            throw Exception(QPID_MSG("Cannot resolve " << sa.host << ": " << ::gai_strerror(n)));
+            throw Exception(QPID_MSG("Cannot resolve " << sa.asString() << ": " << ::gai_strerror(n)));
     }
 
     return *sa.addrInfo;



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org