qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1128065 - in /qpid/trunk/qpid/cpp/src/qpid: broker/windows/ client/ sys/ sys/posix/ sys/windows/
Date Thu, 26 May 2011 20:38:28 GMT
Author: astitcher
Date: Thu May 26 20:38:27 2011
New Revision: 1128065

URL: http://svn.apache.org/viewvc?rev=1128065&view=rev
Log:
NO-JIRA: Remove a lot of redundant stuff from the Socket code
- Removal of unused code

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h
    qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h
    qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp Thu May 26 20:38:27
2011
@@ -86,7 +86,6 @@ class SslProtocolFactory : public qpid::
                  ConnectFailedCallback failed);
 
     uint16_t getPort() const;
-    std::string getHost() const;
     bool supports(const std::string& capability);
 
   private:
@@ -237,10 +236,6 @@ uint16_t SslProtocolFactory::getPort() c
     return listeningPort; // Immutable no need for lock.
 }
 
-std::string SslProtocolFactory::getHost() const {
-    return listener.getSockname();
-}
-
 void SslProtocolFactory::accept(sys::Poller::shared_ptr poller,
                                 sys::ConnectionCodec::Factory* fact) {
     acceptor.reset(

Modified: qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/TCPConnector.cpp Thu May 26 20:38:27 2011
@@ -121,7 +121,7 @@ void TCPConnector::start(sys::AsynchIO* 
         aio->queueReadBuffer(new Buff(maxFrameSize));
     }
 
-    identifier = str(format("[%1% %2%]") % socket.getLocalPort() % socket.getPeerAddress());
+    identifier = str(format("[%1%]") % socket.getFullAddress());
 }
 
 void TCPConnector::initAmqp() {

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/ProtocolFactory.h Thu May 26 20:38:27 2011
@@ -39,7 +39,6 @@ class ProtocolFactory : public qpid::Sha
 
     virtual ~ProtocolFactory() = 0;
     virtual uint16_t getPort() const = 0;
-    virtual std::string getHost() const = 0;
     virtual void accept(boost::shared_ptr<Poller>, ConnectionCodec::Factory*) = 0;
     virtual void connect(
         boost::shared_ptr<Poller>,

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/RdmaIOPlugin.cpp Thu May 26 20:38:27 2011
@@ -256,7 +256,6 @@ class RdmaIOProtocolFactory : public Pro
     void connect(Poller::shared_ptr, const string& host, const std::string& port,
ConnectionCodec::Factory*, ConnectFailedCallback);
 
     uint16_t getPort() const;
-    string getHost() const;
 
   private:
     bool request(Rdma::Connection::intrusive_ptr, const Rdma::ConnectionParams&, ConnectionCodec::Factory*);
@@ -346,11 +345,6 @@ uint16_t RdmaIOProtocolFactory::getPort(
     return listeningPort; // Immutable no need for lock.
 }
 
-string RdmaIOProtocolFactory::getHost() const {
-    //return listener.getSockname();
-    return "";
-}
-
 void RdmaIOProtocolFactory::accept(Poller::shared_ptr poller, ConnectionCodec::Factory* fact)
{
     ::sockaddr_in sin;
 

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/Socket.h Thu May 26 20:38:27 2011
@@ -39,9 +39,6 @@ public:
     /** Create a socket wrapper for descriptor. */
     QPID_COMMON_EXTERN Socket();
 
-    /** Set timeout for read and write */
-    void setTimeout(const Duration& interval) const;
-
     /** Set socket non blocking */
     void setNonblocking() const;
 
@@ -60,16 +57,6 @@ public:
     QPID_COMMON_EXTERN int listen(const std::string& host = "", const std::string&
port = "0", int backlog = 10) const;
     QPID_COMMON_EXTERN int listen(const SocketAddress&, int backlog = 10) const;
 
-    /** Returns the "socket name" ie the address bound to
-     * the near end of the socket
-     */
-    QPID_COMMON_EXTERN std::string getSockname() const;
-
-    /** Returns the "peer name" ie the address bound to
-     * the remote end of the socket
-     */
-    std::string getPeername() const;
-
     /**
      * Returns an address (host and port) for the remote end of the
      * socket
@@ -86,9 +73,6 @@ public:
      */
     QPID_COMMON_INLINE_EXTERN std::string getFullAddress() const { return getLocalAddress()+"-"+getPeerAddress();
}
 
-    QPID_COMMON_EXTERN uint16_t getLocalPort() const;
-    uint16_t getRemotePort() const;
-
     /**
      * Returns the error code stored in the socket.  This may be used
      * to determine the result of a non-blocking connect.

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp Thu May 26 20:38:27 2011
@@ -71,7 +71,6 @@ class SslProtocolFactory : public Protoc
                  boost::function2<void, int, std::string> failed);
 
     uint16_t getPort() const;
-    std::string getHost() const;
     bool supports(const std::string& capability);
 
   private:
@@ -146,10 +145,6 @@ uint16_t SslProtocolFactory::getPort() c
     return listeningPort; // Immutable no need for lock.
 }
 
-std::string SslProtocolFactory::getHost() const {
-    return listener.getSockname();
-}
-
 void SslProtocolFactory::accept(Poller::shared_ptr poller,
                                      ConnectionCodec::Factory* fact) {
     acceptor.reset(

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp Thu May 26 20:38:27 2011
@@ -49,7 +49,6 @@ class AsynchIOProtocolFactory : public P
                  ConnectFailedCallback);
 
     uint16_t getPort() const;
-    std::string getHost() const;
 
   private:
     void established(Poller::shared_ptr, const Socket&, ConnectionCodec::Factory*,
@@ -110,10 +109,6 @@ uint16_t AsynchIOProtocolFactory::getPor
     return listeningPort; // Immutable no need for lock.
 }
 
-std::string AsynchIOProtocolFactory::getHost() const {
-    return listener.getSockname();
-}
-
 void AsynchIOProtocolFactory::accept(Poller::shared_ptr poller,
                                      ConnectionCodec::Factory* fact) {
     acceptor.reset(

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/Socket.cpp Thu May 26 20:38:27 2011
@@ -42,7 +42,7 @@ namespace qpid {
 namespace sys {
 
 namespace {
-std::string getName(int fd, bool local, bool includeService = false)
+std::string getName(int fd, bool local)
 {
     ::sockaddr_storage name; // big enough for any socket address
     ::socklen_t namelen = sizeof(name);
@@ -53,45 +53,15 @@ std::string getName(int fd, bool local, 
     } else {
         result = ::getpeername(fd, (::sockaddr*)&name, &namelen);
     }
-
     QPID_POSIX_CHECK(result);
 
     char servName[NI_MAXSERV];
     char dispName[NI_MAXHOST];
-    if (includeService) {
-        if (int rc=::getnameinfo((::sockaddr*)&name, namelen, dispName, sizeof(dispName),
-                                 servName, sizeof(servName),
-                                 NI_NUMERICHOST | NI_NUMERICSERV) != 0)
-            throw QPID_POSIX_ERROR(rc);
-        return std::string(dispName) + ":" + std::string(servName);
-
-    } else {
-        if (int rc=::getnameinfo((::sockaddr*)&name, namelen, dispName, sizeof(dispName),
0, 0, NI_NUMERICHOST) != 0)
-            throw QPID_POSIX_ERROR(rc);
-        return dispName;
-    }
-}
-
-std::string getService(int fd, bool local)
-{
-    ::sockaddr_storage name; // big enough for any socket address
-    ::socklen_t namelen = sizeof(name);
-
-    int result = -1;
-    if (local) {
-        result = ::getsockname(fd, (::sockaddr*)&name, &namelen);
-    } else {
-        result = ::getpeername(fd, (::sockaddr*)&name, &namelen);
-    }
-
-    QPID_POSIX_CHECK(result);
-
-    char servName[NI_MAXSERV];
-    if (int rc=::getnameinfo((::sockaddr*)&name, namelen, 0, 0,
-                                 servName, sizeof(servName),
-                                 NI_NUMERICHOST | NI_NUMERICSERV) != 0)
+    if (int rc=::getnameinfo((::sockaddr*)&name, namelen, dispName, sizeof(dispName),
+                                servName, sizeof(servName),
+                                NI_NUMERICHOST | NI_NUMERICSERV) != 0)
         throw QPID_POSIX_ERROR(rc);
-    return servName;
+    return std::string(dispName) + ":" + std::string(servName);
 }
 }
 
@@ -125,15 +95,6 @@ void Socket::createSocket(const SocketAd
     }
 }
 
-void Socket::setTimeout(const Duration& interval) const
-{
-    const int& socket = impl->fd;
-    struct timeval tv;
-    toTimeval(tv, interval);
-    setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
-    setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
-}
-
 void Socket::setNonblocking() const {
     int& socket = impl->fd;
     nonblocking = true;
@@ -246,37 +207,17 @@ int Socket::write(const void *buf, size_
     return ::write(impl->fd, buf, count);
 }
 
-std::string Socket::getSockname() const
-{
-    return getName(impl->fd, true);
-}
-
-std::string Socket::getPeername() const
-{
-    return getName(impl->fd, false);
-}
-
 std::string Socket::getPeerAddress() const
 {
     if (connectname.empty()) {
-        connectname = getName(impl->fd, false, true);
+        connectname = getName(impl->fd, false);
     }
     return connectname;
 }
 
 std::string Socket::getLocalAddress() const
 {
-    return getName(impl->fd, true, true);
-}
-
-uint16_t Socket::getLocalPort() const
-{
-    return std::atoi(getService(impl->fd, true).c_str());
-}
-
-uint16_t Socket::getRemotePort() const
-{
-    return std::atoi(getService(impl->fd, true).c_str());
+    return getName(impl->fd, true);
 }
 
 int Socket::getError() const

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp?rev=1128065&r1=1128064&r2=1128065&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp Thu May 26 20:38:27 2011
@@ -101,41 +101,12 @@ std::string getName(SOCKET fd, bool loca
 
     char servName[NI_MAXSERV];
     char dispName[NI_MAXHOST];
-    if (includeService) {
-        if (int rc = ::getnameinfo((sockaddr*)&name, namelen,
-                                   dispName, sizeof(dispName), 
-                                   servName, sizeof(servName), 
-                                   NI_NUMERICHOST | NI_NUMERICSERV) != 0)
-            throw qpid::Exception(QPID_MSG(gai_strerror(rc)));
-        return std::string(dispName) + ":" + std::string(servName);
-    } else {
-        if (int rc = ::getnameinfo((sockaddr*)&name, namelen,
-                                   dispName, sizeof(dispName),
-                                   0, 0,
-                                   NI_NUMERICHOST) != 0)
-            throw qpid::Exception(QPID_MSG(gai_strerror(rc)));
-        return dispName;
-    }
-}
-
-std::string getService(SOCKET fd, bool local)
-{
-    sockaddr_in name; // big enough for any socket address    
-    socklen_t namelen = sizeof(name);
-    
-    if (local) {
-        QPID_WINSOCK_CHECK(::getsockname(fd, (sockaddr*)&name, &namelen));
-    } else {
-        QPID_WINSOCK_CHECK(::getpeername(fd, (sockaddr*)&name, &namelen));
-    }
-
-    char servName[NI_MAXSERV];
     if (int rc = ::getnameinfo((sockaddr*)&name, namelen,
-                               0, 0, 
+                               dispName, sizeof(dispName), 
                                servName, sizeof(servName), 
                                NI_NUMERICHOST | NI_NUMERICSERV) != 0)
         throw qpid::Exception(QPID_MSG(gai_strerror(rc)));
-    return servName;
+    return std::string(dispName) + ":" + std::string(servName);
 }
 }  // namespace
 
@@ -179,20 +150,6 @@ Socket::createSocket(const SocketAddress
     }
 }
 
-void Socket::setTimeout(const Duration& interval) const
-{
-    const SOCKET& socket = impl->fd;
-    int64_t nanosecs = interval;
-    nanosecs /= (1000 * 1000); // nsecs -> usec -> msec
-    int msec = 0;
-    if (nanosecs > std::numeric_limits<int>::max())
-        msec = std::numeric_limits<int>::max();
-    else
-        msec = static_cast<int>(nanosecs);
-    setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&msec, sizeof(msec));
-    setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&msec, sizeof(msec));
-}
-
 void Socket::setNonblocking() const {
     u_long nonblock = 1;
     QPID_WINSOCK_CHECK(ioctlsocket(impl->fd, FIONBIO, &nonblock));
@@ -282,36 +239,16 @@ Socket* Socket::accept() const
     else throw QPID_WINDOWS_ERROR(WSAGetLastError());
 }
 
-std::string Socket::getSockname() const
-{
-    return getName(impl->fd, true);
-}
-
-std::string Socket::getPeername() const
-{
-    return getName(impl->fd, false);
-}
-
 std::string Socket::getPeerAddress() const
 {
     if (!connectname.empty())
-        return std::string (connectname);
-    return getName(impl->fd, false, true);
+        connectname = getName(impl->fd, false);
+    return connectname;
 }
 
 std::string Socket::getLocalAddress() const
 {
-    return getName(impl->fd, true, true);
-}
-
-uint16_t Socket::getLocalPort() const
-{
-    return atoi(getService(impl->fd, true).c_str());
-}
-
-uint16_t Socket::getRemotePort() const
-{
-    return atoi(getService(impl->fd, true).c_str());
+    return getName(impl->fd, true);
 }
 
 int Socket::getError() const



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


Mime
View raw message