qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject qpid-proton git commit: PROTON-1608: Fix incorrect logic detecting violations of channel_max
Date Mon, 02 Oct 2017 22:22:57 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 9e862258f -> ec5c71a61


PROTON-1608: Fix incorrect logic detecting violations of channel_max


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

Branch: refs/heads/master
Commit: ec5c71a615e5db8b451982afc607ecc22c0f4fc1
Parents: 9e86225
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Thu Feb 16 04:46:09 2017 -0500
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Mon Oct 2 18:21:02 2017 -0400

----------------------------------------------------------------------
 proton-c/src/core/engine.c    | 15 ---------------
 proton-c/src/core/transport.c | 20 ++++++++++----------
 2 files changed, 10 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ec5c71a6/proton-c/src/core/engine.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/engine.c b/proton-c/src/core/engine.c
index b8dacad..cd929f4 100644
--- a/proton-c/src/core/engine.c
+++ b/proton-c/src/core/engine.c
@@ -976,21 +976,6 @@ static void pn_session_finalize(void *object)
 pn_session_t *pn_session(pn_connection_t *conn)
 {
   assert(conn);
-
-
-  pn_transport_t * transport = pn_connection_transport(conn);
-
-  if(transport) {
-    // channel_max is an index, not a count.  
-    if(pn_hash_size(transport->local_channels) > (size_t)transport->channel_max)
{
-      pn_transport_logf(transport, 
-                        "pn_session: too many sessions: %d  channel_max is %d",
-                        pn_hash_size(transport->local_channels),
-                        transport->channel_max);
-      return (pn_session_t *) 0;
-    }
-  }
-
 #define pn_session_free pn_object_free
   static const pn_class_t clazz = PN_METACLASS(pn_session);
 #undef pn_session_free

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ec5c71a6/proton-c/src/core/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/transport.c b/proton-c/src/core/transport.c
index 9d3381a..216adb6 100644
--- a/proton-c/src/core/transport.c
+++ b/proton-c/src/core/transport.c
@@ -1237,11 +1237,11 @@ int pn_do_begin(pn_transport_t *transport, uint8_t frame_type, uint16_t
channel,
 
   // AMQP 1.0 section 2.7.1 - if the peer doesn't honor our channel_max --
   // express our displeasure by closing the connection with a framing error.
-  if (remote_channel > transport->channel_max) {
+  if (channel > transport->channel_max) {
     pn_do_error(transport,
                 "amqp:connection:framing-error",
                 "remote channel %d is above negotiated channel_max %d.",
-                remote_channel,
+                channel,
                 transport->channel_max
                );
     return PN_TRANSPORT_ERROR;
@@ -1250,17 +1250,17 @@ int pn_do_begin(pn_transport_t *transport, uint8_t frame_type, uint16_t
channel,
   pn_session_t *ssn;
   if (reply) {
     ssn = (pn_session_t *) pn_hash_get(transport->local_channels, remote_channel);
+    if (ssn == 0) {
+      pn_do_error(transport,
+                "amqp:invalid-field",
+                "begin reply to unknown channel %d.",
+                remote_channel
+               );
+      return PN_TRANSPORT_ERROR;
+    }
   } else {
     ssn = pn_session(transport->connection);
   }
-  if (ssn == 0) {
-    pn_do_error(transport,
-                "amqp:connection:framing-error",
-                "remote channel is above negotiated channel_max %d.",
-                transport->channel_max
-               );
-    return PN_TRANSPORT_ERROR;
-  }
   ssn->state.incoming_transfer_count = next;
   pni_map_remote_channel(ssn, channel);
   PN_SET_REMOTE(ssn->endpoint.state, PN_REMOTE_ACTIVE);


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


Mime
View raw message