You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2017/01/11 18:58:33 UTC

qpid-dispatch git commit: DISPATCH-606 - Default maxSessionFrames to 0. Zero now means the maximum possible session window (2^31-1 on 64-buit arches and (2^31-1)/max_frame_size on 32-bit architectures. The latter restriction is a result of a limitation

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 52ddd4745 -> 2950f08b7


DISPATCH-606 - Default maxSessionFrames to 0.  Zero now means the maximum possible session window (2^31-1 on 64-buit arches and (2^31-1)/max_frame_size on 32-bit architectures.  The latter restriction is a result of a limitation in the Proton API.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/2950f08b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/2950f08b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/2950f08b

Branch: refs/heads/master
Commit: 2950f08b76e11268e9ff7be47b542e1351bf7139
Parents: 52ddd47
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Jan 11 13:55:39 2017 -0500
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Jan 11 13:55:39 2017 -0500

----------------------------------------------------------------------
 include/qpid/dispatch/server.h                |  2 +-
 python/qpid_dispatch/management/qdrouter.json |  6 +--
 src/connection_manager.c                      | 38 ++++++++++--------
 tests/system_tests_protocol_settings.py       | 45 ++--------------------
 4 files changed, 28 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2950f08b/include/qpid/dispatch/server.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/server.h b/include/qpid/dispatch/server.h
index b28f1cc..0562222 100644
--- a/include/qpid/dispatch/server.h
+++ b/include/qpid/dispatch/server.h
@@ -444,7 +444,7 @@ typedef struct qd_server_config_t {
      * to equal the specified sessionMaxFrames value measured in units of transfer frames.
      * This calculation is done to satisfy proton pn_session_set_incoming_capacity().
      */
-    uint32_t incoming_capacity;
+    size_t incoming_capacity;
 
     /**
      * The idle timeout, in seconds.  If the peer sends no data frames in this many seconds, the

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2950f08b/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index 3c6bb88..f4ab551 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -640,8 +640,7 @@
                 },
                 "maxSessionFrames": {
                     "type": "integer",
-                    "description": "Session incoming window measured in transfer frames for sessions created on this connection. This is the number of transfer frames that may simultaneously be in flight for all links in the session. Setting this value to zero selects the default session window size. Policy settings, if specified, will overwrite this value. The numerical product of maxFrameSize and maxSessionFrames may not exceed 2^31-1. If (maxFrameSize x maxSessionFrames) exceeds 2^31-1 then maxSessionFrames is reduced to (2^31-1 / maxFrameSize). maxSessionFrames has a minimum value of 1. Defaults to 100.",
-                    "default": 100,
+                    "description": "Session incoming window measured in transfer frames for sessions created on this connection. This is the number of transfer frames that may simultaneously be in flight for all links in the session. Setting this value to zero selects the default session window size. Policy settings, if specified, will overwrite this value. The numerical product of maxFrameSize and maxSessionFrames may not exceed 2^31-1. If (maxFrameSize x maxSessionFrames) exceeds 2^31-1 then maxSessionFrames is reduced to (2^31-1 / maxFrameSize). maxSessionFrames has a minimum value of 1. Defaults to 0 (unlimited window).",
                     "required": false,
                     "create": true
                 },
@@ -784,8 +783,7 @@
                 },
                 "maxSessionFrames": {
                     "type": "integer",
-                    "description": "Session incoming window measured in transfer frames for sessions created on this connection. This is the number of transfer frames that may simultaneously be in flight for all links in the session. Setting this value to zero selects the default session window size. Policy settings will not overwrite this value. The numerical product of maxFrameSize and maxSessionFrames may not exceed 2^31-1. If (maxFrameSize x maxSessionFrames) exceeds 2^31-1 then maxSessionFrames is reduced to (2^31-1 / maxFrameSize). maxSessionFrames has a minimum value of 1. Defaults to 100.",
-                    "default": 100,
+                    "description": "Session incoming window measured in transfer frames for sessions created on this connection. This is the number of transfer frames that may simultaneously be in flight for all links in the session. Setting this value to zero selects the default session window size. Policy settings will not overwrite this value. The numerical product of maxFrameSize and maxSessionFrames may not exceed 2^31-1. If (maxFrameSize x maxSessionFrames) exceeds 2^31-1 then maxSessionFrames is reduced to (2^31-1 / maxFrameSize). maxSessionFrames has a minimum value of 1.  Defaults to 0 (unlimited window).",
                     "required": false,
                     "create": true
                 },

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2950f08b/src/connection_manager.c
----------------------------------------------------------------------
diff --git a/src/connection_manager.c b/src/connection_manager.c
index c4253c8..70ebe6d 100644
--- a/src/connection_manager.c
+++ b/src/connection_manager.c
@@ -29,6 +29,7 @@
 #include "schema_enum.h"
 #include <string.h>
 #include <stdio.h>
+#include <inttypes.h>
 
 static char* HOST_ADDR_DEFAULT = "127.0.0.1";
 
@@ -247,7 +248,7 @@ static qd_error_t load_server_config(qd_dispatch_t *qd, qd_server_config_t *conf
     config->http = config->http || config->http_root; /* httpRoot implies http */
     config->max_frame_size       = qd_entity_get_long(entity, "maxFrameSize");        CHECK();
     config->max_sessions         = qd_entity_get_long(entity, "maxSessions");         CHECK();
-    uint64_t ssn_frames          = qd_entity_get_long(entity, "maxSessionFrames");    CHECK();
+    uint64_t ssn_frames          = qd_entity_opt_long(entity, "maxSessionFrames", 0); CHECK();
     config->idle_timeout_seconds = qd_entity_get_long(entity, "idleTimeoutSeconds");  CHECK();
     config->sasl_username        = qd_entity_opt_string(entity, "saslUsername", 0);   CHECK();
     config->sasl_password        = qd_entity_opt_string(entity, "saslPassword", 0);   CHECK();
@@ -275,22 +276,25 @@ static qd_error_t load_server_config(qd_dispatch_t *qd, qd_server_config_t *conf
 
     //
     // Given session frame count and max frame size compute session incoming_capacity
-    // Limit total capacity to 2^31-1.
-    // 
-    uint64_t mfs      = (uint64_t)config->max_frame_size;
-    uint64_t trial_ic = ssn_frames * mfs;
-    uint64_t limit    = (1ll << 31) - 1;
-    if (trial_ic < limit) {
-        // Silently promote incoming capacity of zero to one
-        config->incoming_capacity = 
-            (trial_ic < QD_AMQP_MIN_MAX_FRAME_SIZE ? QD_AMQP_MIN_MAX_FRAME_SIZE : trial_ic);
-    } else {
-        config->incoming_capacity = limit;
-        uint64_t computed_ssn_frames = limit / mfs;
-        qd_log(qd->connection_manager->log_source, QD_LOG_WARNING,
-               "Server configuation for I/O adapter entity name:'%s', host:'%s', port:'%s', "
-               "requested maxSessionFrames truncated from %llu to %llu",
-               config->name, config->host, config->port, ssn_frames, computed_ssn_frames);
+    //
+    if (ssn_frames == 0)
+        config->incoming_capacity = (sizeof(size_t) < 8) ? 0x7FFFFFFFLL : 0x7FFFFFFFLL * config->max_frame_size;
+    else {
+        uint64_t mfs      = (uint64_t) config->max_frame_size;
+        uint64_t trial_ic = ssn_frames * mfs;
+        uint64_t limit    = (sizeof(size_t) < 8) ? (1ll << 31) - 1 : 0;
+        if (limit == 0 || trial_ic < limit) {
+            // Silently promote incoming capacity of zero to one
+            config->incoming_capacity = 
+                (trial_ic < QD_AMQP_MIN_MAX_FRAME_SIZE ? QD_AMQP_MIN_MAX_FRAME_SIZE : trial_ic);
+        } else {
+            config->incoming_capacity = limit;
+            uint64_t computed_ssn_frames = limit / mfs;
+            qd_log(qd->connection_manager->log_source, QD_LOG_WARNING,
+                   "Server configuation for I/O adapter entity name:'%s', host:'%s', port:'%s', "
+                   "requested maxSessionFrames truncated from %"PRId64" to %"PRId64,
+                   config->name, config->host, config->port, ssn_frames, computed_ssn_frames);
+        }
     }
 
     //

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2950f08b/tests/system_tests_protocol_settings.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_protocol_settings.py b/tests/system_tests_protocol_settings.py
index 7a9b73d..9cc0529 100644
--- a/tests/system_tests_protocol_settings.py
+++ b/tests/system_tests_protocol_settings.py
@@ -234,46 +234,9 @@ class MaxSessionFramesDefaultTest(TestCase):
             self.assertTrue(" max-frame-size=16384" in open_lines[0])
             begin_lines = [s for s in log_lines if "-> @begin" in s]
             # incoming-window is from the config
-            self.assertTrue(" incoming-window=100," in begin_lines[0])
+            self.assertTrue(" incoming-window=2147483647," in begin_lines[0])
 
 
-class MaxFrameMaxSessionFramesTooBigTest(TestCase):
-    """
-    System tests setting proton negotiated size max-frame-size and incoming-window
-    when the product of the two is > 2^31-1. There must be a warning and the incoming
-    window will be reduced to 2^31-1 / max-frame-size
-    """
-    @classmethod
-    def setUpClass(cls):
-        '''Start a router'''
-        super(MaxFrameMaxSessionFramesTooBigTest, cls).setUpClass()
-        name = "MaxFrameMaxSessionFramesTooBig"
-        config = Qdrouterd.Config([
-            ('router', {'mode': 'standalone', 'id': 'QDR'}),
-
-            ('listener', {'host': '0.0.0.0', 'port': cls.tester.get_port(), 'maxFrameSize': '1000000', 'maxSessionFrames': '5000000'}),
-        ])
-        cls.router = cls.tester.qdrouterd(name, config)
-        cls.router.wait_ready()
-        cls.address = cls.router.addresses[0]
-
-    def test_max_frame_max_session_too_big(self):
-        # Set up a connection to get the Open and a receiver to get a Begin frame in the log
-        bc = BlockingConnection(self.router.addresses[0])
-        bc.create_receiver("xxx")
-        bc.close()
-
-        with  open('../setUpClass/MaxFrameMaxSessionFramesTooBig.log', 'r') as router_log:
-            log_lines = router_log.read().split("\n")
-            open_lines = [s for s in log_lines if "-> @open" in s]
-            # max-frame is from the config
-            self.assertTrue(' max-frame-size=1000000,' in open_lines[0])
-            begin_lines = [s for s in log_lines if "-> @begin" in s]
-            # incoming-window is truncated
-            self.assertTrue(" incoming-window=2147," in begin_lines[0])
-            warning_lines = [s for s in log_lines if "requested maxSessionFrames truncated from 5000000 to 2147" in s]
-            self.assertTrue(len(warning_lines) == 1)
-
 class MaxFrameMaxSessionFramesZeroTest(TestCase):
     """
     System tests setting proton negotiated size max-frame-size and incoming-window
@@ -306,8 +269,8 @@ class MaxFrameMaxSessionFramesZeroTest(TestCase):
             # max-frame gets set to protocol min
             self.assertTrue(' max-frame-size=512,' in open_lines[0])
             begin_lines = [s for s in log_lines if "-> @begin" in s]
-            # incoming-window is promoted to 1
-            self.assertTrue(" incoming-window=1," in begin_lines[0])
+            # incoming-window is defaulted to 2^31-1
+            self.assertTrue(" incoming-window=2147483647," in begin_lines[0])
 
 
 class ConnectorSettingsDefaultTest(TestCase):
@@ -361,7 +324,7 @@ class ConnectorSettingsDefaultTest(TestCase):
             self.assertTrue(' channel-max=32767,' in open_lines[0])
             begin_lines = [s for s in log_lines if "<- @begin" in s]
             # defaults
-            self.assertTrue(" incoming-window=100," in begin_lines[0])
+            self.assertTrue(" incoming-window=2147483647," in begin_lines[0])
 
 
 class ConnectorSettingsNondefaultTest(TestCase):


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