You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by cl...@apache.org on 2016/12/04 01:52:57 UTC

qpid-proton git commit: PROTON-1311: C interface to get/set the link max-msessage-size

Repository: qpid-proton
Updated Branches:
  refs/heads/master 325e399e3 -> 0a2d28e13


PROTON-1311: C interface to get/set the link max-msessage-size


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

Branch: refs/heads/master
Commit: 0a2d28e13978603f2a699a4bff91adf3dd90d309
Parents: 325e399
Author: Clifford Jansen <cl...@apache.org>
Authored: Sat Dec 3 17:42:40 2016 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Sat Dec 3 17:45:03 2016 -0800

----------------------------------------------------------------------
 proton-c/bindings/python/proton/__init__.py | 10 ++++++++
 proton-c/include/proton/link.h              | 30 ++++++++++++++++++++++++
 proton-c/src/core/engine-internal.h         |  2 ++
 proton-c/src/core/engine.c                  | 17 ++++++++++++++
 proton-c/src/core/transport.c               | 13 ++++++----
 tests/python/proton_tests/engine.py         | 11 +++++++++
 6 files changed, 79 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a2d28e1/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 516daf1..d3f6922 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -2868,6 +2868,16 @@ class Link(Wrapper, Endpoint):
   def drained(self):
     return pn_link_drained(self._impl)
 
+  @property
+  def remote_max_message_size(self):
+    return pn_link_remote_max_message_size(self._impl)
+
+  def _get_max_message_size(self):
+    return pn_link_max_message_size(self._impl)
+  def _set_max_message_size(self, mode):
+    pn_link_set_max_message_size(self._impl, mode)
+  max_message_size = property(_get_max_message_size, _set_max_message_size)
+
   def detach(self):
     return pn_link_detach(self._impl)
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a2d28e1/proton-c/include/proton/link.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/link.h b/proton-c/include/proton/link.h
index 8ec162e..d52e6e7 100644
--- a/proton-c/include/proton/link.h
+++ b/proton-c/include/proton/link.h
@@ -647,6 +647,36 @@ PN_EXTERN ssize_t pn_link_recv(pn_link_t *receiver, char *bytes, size_t n);
 PN_EXTERN bool pn_link_draining(pn_link_t *receiver);
 
 /**
+ * **Experimental** - Get the maximum message size for a link.
+ *
+ * A zero maximum message size means the size is unlimited.
+ *
+ * @param[in] link a link object
+ * @return the maximum message size for a link.
+ */
+PN_EXTERN uint64_t pn_link_max_message_size(pn_link_t *link);
+
+/**
+ * **Experimental** - Set the maximum message size for a link.
+ *
+ * A zero maximum message size means the size is unlimited.
+ *
+ * @param[in] link a link object
+ * @param[in] size the maximum message size for the link
+ */
+PN_EXTERN void pn_link_set_max_message_size(pn_link_t *link, uint64_t size);
+
+/**
+ * **Experimental** - Get the remote view of the maximum message size for a link.
+ *
+ * A zero maximum message size means the size is unlimited.
+ *
+ * @param[in] link a link object
+ * @return the remote view of the maximum message size for a link
+ */
+PN_EXTERN uint64_t pn_link_remote_max_message_size(pn_link_t *link);
+
+/**
  * @}
  */
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a2d28e1/proton-c/src/core/engine-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/engine-internal.h b/proton-c/src/core/engine-internal.h
index fdaf272..1dbe91c 100644
--- a/proton-c/src/core/engine-internal.h
+++ b/proton-c/src/core/engine-internal.h
@@ -291,6 +291,8 @@ struct pn_link_t {
   pn_delivery_t *current;
   pn_record_t *context;
   size_t unsettled_count;
+  uint64_t max_message_size;
+  uint64_t remote_max_message_size;
   pn_sequence_t available;
   pn_sequence_t credit;
   pn_sequence_t queued;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a2d28e1/proton-c/src/core/engine.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/engine.c b/proton-c/src/core/engine.c
index 99d311b..8c2aeb0 100644
--- a/proton-c/src/core/engine.c
+++ b/proton-c/src/core/engine.c
@@ -1176,6 +1176,8 @@ pn_link_t *pn_link_new(int type, pn_session_t *session, const char *name)
   pni_terminus_init(&link->remote_target, PN_UNSPECIFIED);
   link->unsettled_head = link->unsettled_tail = link->current = NULL;
   link->unsettled_count = 0;
+  link->max_message_size = 0;
+  link->remote_max_message_size = 0;
   link->available = 0;
   link->credit = 0;
   link->queued = 0;
@@ -1956,6 +1958,21 @@ bool pn_link_draining(pn_link_t *receiver)
   return receiver->drain && (pn_link_credit(receiver) > pn_link_queued(receiver));
 }
 
+uint64_t pn_link_max_message_size(pn_link_t *link)
+{
+  return link->max_message_size;
+}
+
+void pn_link_set_max_message_size(pn_link_t *link, uint64_t size)
+{
+  link->max_message_size = size;
+}
+
+uint64_t pn_link_remote_max_message_size(pn_link_t *link)
+{
+  return link->remote_max_message_size;
+}
+
 pn_link_t *pn_delivery_link(pn_delivery_t *delivery)
 {
   assert(delivery);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a2d28e1/proton-c/src/core/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/transport.c b/proton-c/src/core/transport.c
index e3b88b1..444145a 100644
--- a/proton-c/src/core/transport.c
+++ b/proton-c/src/core/transport.c
@@ -1342,13 +1342,14 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel
   pn_bytes_t dist_mode;
   bool snd_settle, rcv_settle;
   uint8_t snd_settle_mode, rcv_settle_mode;
-  int err = pn_data_scan(args, "D.[SIo?B?BD.[SIsIo.s]D.[SIsIo]..I]", &name, &handle,
+  uint64_t max_msgsz;
+  int err = pn_data_scan(args, "D.[SIo?B?BD.[SIsIo.s]D.[SIsIo]..IL]", &name, &handle,
                          &is_sender,
                          &snd_settle, &snd_settle_mode,
                          &rcv_settle, &rcv_settle_mode,
                          &source, &src_dr, &src_exp, &src_timeout, &src_dynamic, &dist_mode,
                          &target, &tgt_dr, &tgt_exp, &tgt_timeout, &tgt_dynamic,
-                         &idc);
+                         &idc, &max_msgsz);
   if (err) return err;
   char strbuf[128];      // avoid malloc for most link names
   char *strheap = (name.size >= sizeof(strbuf)) ? (char *) malloc(name.size + 1) : NULL;
@@ -1444,6 +1445,10 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel
     link->state.delivery_count = idc;
   }
 
+  if (max_msgsz) {
+    link->remote_max_message_size = max_msgsz;
+  }
+
   pn_collector_put(transport->connection->collector, PN_OBJECT, link, PN_LINK_REMOTE_OPEN);
   return 0;
 }
@@ -1988,7 +1993,7 @@ static int pni_process_link_setup(pn_transport_t *transport, pn_endpoint_t *endp
         if (err) return err;
       } else {
         int err = pn_post_frame(transport, AMQP_FRAME_TYPE, ssn_state->local_channel,
-                                "DL[SIoBB?DL[SIsIoC?sCnCC]?DL[SIsIoCC]nnI]", ATTACH,
+                                "DL[SIoBB?DL[SIsIoC?sCnCC]?DL[SIsIoCC]nnIL]", ATTACH,
                                 pn_string_get(link->name),
                                 state->local_handle,
                                 endpoint->type == RECEIVER,
@@ -2013,7 +2018,7 @@ static int pni_process_link_setup(pn_transport_t *transport, pn_endpoint_t *endp
                                 link->target.dynamic,
                                 link->target.properties,
                                 link->target.capabilities,
-                                0);
+                                0, link->max_message_size);
         if (err) return err;
       }
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a2d28e1/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index d011210..497bb7d 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -746,6 +746,17 @@ class LinkTest(Test):
     assert self.snd.remote_rcv_settle_mode == Link.RCV_SECOND
     assert self.rcv.remote_snd_settle_mode == Link.SND_UNSETTLED
 
+  def test_max_message_size(self):
+    if "java" in sys.platform:
+      raise Skipped()
+    assert self.snd.max_message_size == 0
+    assert self.rcv.remote_max_message_size == 0
+    self.snd.max_message_size = 13579
+    self.snd.open()
+    self.rcv.open()
+    self.pump()
+    assert self.rcv.remote_max_message_size == 13579
+
   def test_cleanup(self):
     snd, rcv = self.link("test-link")
     snd.open()


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