qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1494656 - in /qpid/trunk/qpid/cpp/src: qpid/broker/windows/ qpid/sys/ qpid/sys/posix/ tests/
Date Wed, 19 Jun 2013 15:30:50 GMT
Author: astitcher
Date: Wed Jun 19 15:30:50 2013
New Revision: 1494656

URL: http://svn.apache.org/r1494656
Log:
QPID-4931: Only allow broker to listen to a single address if "--port 0" specified
- If more than one address is specified or implied by the defaults the broker
  will log a warning
- This is intended to avoid testing problems where the broker fails to connect
  to the port of subsequent listening addresses

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/SocketAddress.h
    qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.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/SocketAddress.cpp
    qpid/trunk/qpid/cpp/src/tests/brokertest.py
    qpid/trunk/qpid/cpp/src/tests/interlink_tests.py
    qpid/trunk/qpid/cpp/src/tests/ipv6_test

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=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/windows/SslProtocolFactory.cpp Wed Jun 19 15:30:50
2013
@@ -125,7 +125,7 @@ static struct SslPlugin : public Plugin 
                 boost::shared_ptr<SslProtocolFactory> protocol(new SslProtocolFactory(opts,
options, broker->getTimer()));
                 uint16_t port =
                     protocol->listen(opts.listenInterfaces,
-                                     boost::lexical_cast<std::string>(options.port),
opts.connectionBacklog,
+                                     options.port, opts.connectionBacklog,
                                      &createSocket);
                 QPID_LOG(notice, "Listening for SSL connections on TCP port " << port);
                 broker->registerTransport("ssl", protocol, protocol, port);

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/SocketAddress.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/SocketAddress.h?rev=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/SocketAddress.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/SocketAddress.h Wed Jun 19 15:30:50 2013
@@ -45,7 +45,6 @@ public:
     QPID_COMMON_EXTERN bool nextAddress();
     QPID_COMMON_EXTERN std::string asString(bool numeric=true) const;
     QPID_COMMON_EXTERN std::string getHost() const;
-    QPID_COMMON_EXTERN void setAddrInfoPort(uint16_t port);
 
     QPID_COMMON_EXTERN static std::string asString(::sockaddr const * const addr, size_t
addrlen);
     QPID_COMMON_EXTERN static uint16_t getPort(::sockaddr const * const addr);

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.cpp?rev=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.cpp Wed Jun 19 15:30:50 2013
@@ -35,6 +35,7 @@
 #include "qpid/sys/SystemInfo.h"
 
 #include <boost/bind.hpp>
+#include <boost/lexical_cast.hpp>
 
 namespace qpid {
 namespace sys {
@@ -130,9 +131,11 @@ void SocketAcceptor::addListener(Socket*
     listeners.push_back(socket);
 }
 
-uint16_t SocketAcceptor::listen(const std::vector<std::string>& interfaces, const
std::string& port, int backlog, const SocketFactory& factory)
+uint16_t SocketAcceptor::listen(const std::vector<std::string>& interfaces, uint16_t
port, int backlog, const SocketFactory& factory)
 {
     std::vector<std::string> addresses = expandInterfaces(interfaces);
+    std::string sport(boost::lexical_cast<std::string>(port));
+
     if (addresses.empty()) {
         // We specified some interfaces, but couldn't find addresses for them
         QPID_LOG(warning, "TCP/TCP6: No specified network interfaces found: Not Listening");
@@ -142,7 +145,7 @@ uint16_t SocketAcceptor::listen(const st
     int listeningPort = 0;
     for (unsigned i = 0; i<addresses.size(); ++i) {
         QPID_LOG(debug, "Using interface: " << addresses[i]);
-        SocketAddress sa(addresses[i], port);
+        SocketAddress sa(addresses[i], sport);
 
         // We must have at least one resolved address
         QPID_LOG(info, "Listening to: " << sa.asString())
@@ -153,10 +156,18 @@ uint16_t SocketAcceptor::listen(const st
 
         listeningPort = lport;
 
+        // If we were told to figure out the port then only allow listening to one address
+        if (port==0) {
+            // Print warning if the user specified more than one interface
+            // or there if is another address for this one
+            if (sa.nextAddress() || addresses.size()>1 ) {
+                QPID_LOG(warning, "Specified port=0: Only listened to: " << sa.asString());
+            }
+            break;
+        }
+
         // Try any other resolved addresses
         while (sa.nextAddress()) {
-            // Hack to ensure that all listening connections are on the same port
-            sa.setAddrInfoPort(listeningPort);
             QPID_LOG(info, "Listening to: " << sa.asString())
             Socket* s = factory();
             uint16_t lport = s->listen(sa, backlog);

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.h?rev=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/SocketTransport.h Wed Jun 19 15:30:50 2013
@@ -63,7 +63,7 @@ public:
     SocketAcceptor(bool tcpNoDelay, bool nodict, uint32_t maxNegotiateTime, Timer& timer,
const EstablishedCallback& established);
 
     // Create sockets from list of interfaces and listen to them
-    uint16_t listen(const std::vector<std::string>& interfaces, const std::string&
port, int backlog, const SocketFactory& factory);
+    uint16_t listen(const std::vector<std::string>& interfaces, uint16_t port,
int backlog, const SocketFactory& factory);
 
     // Import sockets that are already being listened to
     void addListener(Socket* socket);

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=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/SslPlugin.cpp Wed Jun 19 15:30:50 2013
@@ -123,7 +123,7 @@ static struct SslPlugin : public Plugin 
             if (broker->shouldListen("ssl")) {
                 SocketAcceptor* sa =
                     new SocketAcceptor(opts.tcpNoDelay, options.nodict, opts.maxNegotiateTime,
broker->getTimer());
-                    port = sa->listen(opts.listenInterfaces, boost::lexical_cast<std::string>(options.port),
opts.connectionBacklog,
+                    port = sa->listen(opts.listenInterfaces, options.port, opts.connectionBacklog,
                                         multiplex ?
                                             boost::bind(&createServerSSLMuxSocket, options)
:
                                             boost::bind(&createServerSSLSocket, options));

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=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/TCPIOPlugin.cpp Wed Jun 19 15:30:50 2013
@@ -47,7 +47,7 @@ static class TCPIOPlugin : public Plugin
             if (broker->shouldListen("tcp")) {
                 SocketAcceptor* aa = new SocketAcceptor(opts.tcpNoDelay, false, opts.maxNegotiateTime,
broker->getTimer());
                 ta.reset(aa);
-                port = aa->listen(opts.listenInterfaces, boost::lexical_cast<std::string>(opts.port),
opts.connectionBacklog, &createSocket);
+                port = aa->listen(opts.listenInterfaces, opts.port, opts.connectionBacklog,
&createSocket);
                 if ( port!=0 ) {
                     QPID_LOG(notice, "Listening on TCP/TCP6 port " << port);
                 }

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=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/SocketAddress.cpp Wed Jun 19 15:30:50 2013
@@ -115,17 +115,6 @@ bool SocketAddress::nextAddress() {
     return r;
 }
 
-void SocketAddress::setAddrInfoPort(uint16_t port) {
-    if (!currentAddrInfo) return;
-
-    ::addrinfo& ai = *currentAddrInfo;
-    switch (ai.ai_family) {
-    case AF_INET: ((::sockaddr_in*)(void*)ai.ai_addr)->sin_port = htons(port); return;
-    case AF_INET6:((::sockaddr_in6*)(void*)ai.ai_addr)->sin6_port = htons(port); return;
-    default: throw Exception(QPID_MSG("Unexpected socket type"));
-    }
-}
-
 const ::addrinfo& getAddrInfo(const SocketAddress& sa)
 {
     if (!sa.addrInfo) {

Modified: qpid/trunk/qpid/cpp/src/tests/brokertest.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/brokertest.py?rev=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/brokertest.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/brokertest.py Wed Jun 19 15:30:50 2013
@@ -265,7 +265,7 @@ class Broker(Popen):
             if BrokerTest.sql_clfs_store_lib:
                 args = args + ['--load-module', BrokerTest.sql_clfs_store_lib]
                 args = args + ['--catalog', BrokerTest.sql_catalog]
-        cmd = [BrokerTest.qpidd_exec, "--port", port, "--no-module-dir"] + args
+        cmd = [BrokerTest.qpidd_exec, "--port", port, "--interface", "127.0.0.1", "--no-module-dir"]
+ args
         if not "--auth" in args: cmd.append("--auth=no")
         if wait != None:
             cmd += ["--wait", str(wait)]

Modified: qpid/trunk/qpid/cpp/src/tests/interlink_tests.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/interlink_tests.py?rev=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/interlink_tests.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/interlink_tests.py Wed Jun 19 15:30:50 2013
@@ -250,7 +250,6 @@ class AmqpBrokerTest(BrokerTest):
     def amqp_broker(self):
         assert BrokerTest.amqp_lib, "Cannot locate AMQP 1.0 plug-in"
         args = ["--load-module", BrokerTest.amqp_lib,
-                "--interface=127.0.0.1",
                 "--max-negotiate-time=600000",
                 "--log-enable=trace+:Protocol",
                 "--log-enable=info+"]

Modified: qpid/trunk/qpid/cpp/src/tests/ipv6_test
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/ipv6_test?rev=1494656&r1=1494655&r2=1494656&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/ipv6_test (original)
+++ qpid/trunk/qpid/cpp/src/tests/ipv6_test Wed Jun 19 15:30:50 2013
@@ -44,7 +44,7 @@ trap cleanup EXIT
 error() { echo $*; exit 1; }
 
 # Don't need --no-module-dir or --no-data-dir as they are set as env vars in test_env.sh
-COMMON_OPTS="--daemon --auth no --config $CONFIG"
+COMMON_OPTS="--interface [::1] --daemon --auth no --config $CONFIG"
 
 # Record all broker ports started
 unset PORTS



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message