You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mg...@apache.org on 2015/07/17 16:29:52 UTC

qpid-proton git commit: PROTON-919: make C behave same as Java wrt channel_max error

Repository: qpid-proton
Updated Branches:
  refs/heads/master 17250c947 -> 4ee726002


PROTON-919: make C behave same as Java wrt channel_max error


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

Branch: refs/heads/master
Commit: 4ee726002804d7286a8c76b42e0a0717e0798822
Parents: 17250c9
Author: mgoulish <mi...@redhat.com>
Authored: Fri Jul 17 10:29:13 2015 -0400
Committer: mgoulish <mi...@redhat.com>
Committed: Fri Jul 17 10:29:13 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/proton/__init__.py |  3 ++-
 proton-c/include/proton/error.h             |  1 +
 proton-c/include/proton/transport.h         |  3 ++-
 proton-c/src/transport/transport.c          | 16 +++++++++-------
 tests/python/proton_tests/engine.py         |  2 +-
 5 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4ee72600/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index d5dcceb..46b9466 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -3352,7 +3352,8 @@ Sets the maximum size for received frames (in bytes).
     return pn_transport_get_channel_max(self._impl)
 
   def _set_channel_max(self, value):
-    pn_transport_set_channel_max(self._impl, value)
+    if pn_transport_set_channel_max(self._impl, value):
+      raise SessionException("Too late to change channel max.")
 
   channel_max = property(_get_channel_max, _set_channel_max,
                          doc="""

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4ee72600/proton-c/include/proton/error.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/error.h b/proton-c/include/proton/error.h
index 2ed2f31..5945af8 100644
--- a/proton-c/include/proton/error.h
+++ b/proton-c/include/proton/error.h
@@ -31,6 +31,7 @@ extern "C" {
 
 typedef struct pn_error_t pn_error_t;
 
+#define PN_OK (0)
 #define PN_EOS (-1)
 #define PN_ERR (-2)
 #define PN_OVERFLOW (-3)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4ee72600/proton-c/include/proton/transport.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/transport.h b/proton-c/include/proton/transport.h
index 483f5a9..cfa6d71 100644
--- a/proton-c/include/proton/transport.h
+++ b/proton-c/include/proton/transport.h
@@ -345,8 +345,9 @@ PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *transport);
  *
  * @param[in] transport a transport object
  * @param[in] channel_max the maximum allowed channel
+ * @return PN_OK, or PN_STATE_ERR if it is too late to change channel_max
  */
-PN_EXTERN void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t channel_max);
+PN_EXTERN int pn_transport_set_channel_max(pn_transport_t *transport, uint16_t channel_max);
 
 /**
  * Get the maximum allowed channel of a transport's remote peer.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4ee72600/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index 7bce3b5..6abf862 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -2677,7 +2677,7 @@ uint16_t pn_transport_get_channel_max(pn_transport_t *transport)
   return transport->channel_max;
 }
 
-void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t requested_channel_max)
+int pn_transport_set_channel_max(pn_transport_t *transport, uint16_t requested_channel_max)
 {
   /*
    * Once the OPEN frame has been sent, we have communicated our 
@@ -2691,13 +2691,15 @@ void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t requested_
    */
   if(transport->open_sent) {
     pn_transport_logf(transport, "Cannot change local channel-max after OPEN frame sent.");
+    return PN_STATE_ERR;
   }
-  else {
-    transport->local_channel_max = (requested_channel_max < PN_IMPL_CHANNEL_MAX)
-                                   ? requested_channel_max
-                                   : PN_IMPL_CHANNEL_MAX;
-    pni_calculate_channel_max(transport);
-  }
+
+  transport->local_channel_max = (requested_channel_max < PN_IMPL_CHANNEL_MAX)
+                                 ? requested_channel_max
+                                 : PN_IMPL_CHANNEL_MAX;
+  pni_calculate_channel_max(transport);
+
+  return PN_OK;
 }
 
 uint16_t pn_transport_remote_channel_max(pn_transport_t *transport)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4ee72600/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index c18683f..7a1d539 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -267,8 +267,8 @@ class ConnectionTest(Test):
     # we have already sent the OPEN frame.
     try:
       self.c1.transport.channel_max = 666
+      assert False, "expected session exception"
     except:
-      # The java impl will throw an exception.
       pass
 
     assert self.c1.transport.channel_max == upper_limit


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