Repository: qpid-proton
Updated Branches:
  refs/heads/master e91457c7e -> e828055b2


PROTON-1823: [c] pn_message_send() calls pn_link_advance()

Call pn_link_advance() at the end of pn_message_send()

Since pn_message_send() can only send complete messages, it makes no sense to
call it without calling pn_link_advance().


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

Branch: refs/heads/master
Commit: c7717a47d675bae12fcfbf31244009ddb247787c
Parents: e91457c
Author: Alan Conway <acon...@redhat.com>
Authored: Tue Apr 10 11:54:15 2018 -0400
Committer: Alan Conway <acon...@redhat.com>
Committed: Tue Apr 10 13:28:09 2018 -0400

----------------------------------------------------------------------
 c/examples/direct.c         | 1 -
 c/examples/send.c           | 1 -
 c/include/proton/message.h  | 6 ++++++
 c/src/core/message.c        | 7 +++----
 c/tests/connection_driver.c | 1 -
 5 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7717a47/c/examples/direct.c
----------------------------------------------------------------------
diff --git a/c/examples/direct.c b/c/examples/direct.c
index d2a4ae3..fd0c3a4 100644
--- a/c/examples/direct.c
+++ b/c/examples/direct.c
@@ -181,7 +181,6 @@ static void handle_send(app_data_t* app, pn_event_t* event) 
{
        /* Use sent counter as unique delivery tag. */
        pn_delivery(sender, pn_dtag((const char *)&app->sent, 
sizeof(app->sent)));
        send_message(app, sender);
-       pn_link_advance(sender);
      }
      break;
    }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7717a47/c/examples/send.c
----------------------------------------------------------------------
diff --git a/c/examples/send.c b/c/examples/send.c
index 8d979e6..265b66c 100644
--- a/c/examples/send.c
+++ b/c/examples/send.c
@@ -99,7 +99,6 @@ static bool handle(app_data_t* app, pn_event_t* event) {
        /* Use sent counter as unique delivery tag. */
        pn_delivery(sender, pn_dtag((const char *)&app->sent, 
sizeof(app->sent)));
        send_message(app, sender);
-       pn_link_advance(sender);
      }
      break;
    }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7717a47/c/include/proton/message.h
----------------------------------------------------------------------
diff --git a/c/include/proton/message.h b/c/include/proton/message.h
index fd69688..0f094be 100644
--- a/c/include/proton/message.h
+++ b/c/include/proton/message.h
@@ -742,6 +742,12 @@ struct pn_link_t;
 /**
  * Encode and send a message on a sender link.
  *
+ * Performs the following steps:
+ * - create or expand the buffer @buf as required
+ * - call pn_message_encode() to encode the message to a buffer
+ * - call pn_link_send() to send the encoded message bytes
+ * - call pn_link_advance() to indicate the message is complete
+ *
  * @param[in] msg A message object.
  * @param[in] sender A sending link.
  * The message will be encoded and sent with pn_link_send()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7717a47/c/src/core/message.c
----------------------------------------------------------------------
diff --git a/c/src/core/message.c b/c/src/core/message.c
index 3312f8c..dbbdacf 100644
--- a/c/src/core/message.c
+++ b/c/src/core/message.c
@@ -916,10 +916,9 @@ PN_EXTERN ssize_t pn_message_send(pn_message_t *msg, 
pn_link_t *sender, pn_rwbyt
     if (buffer->start == NULL) return PN_OUT_OF_MEMORY;
     size = buffer->size;
   }
-  if (err == 0) {
-    err = pn_link_send(sender, buffer->start, size);
-    if (err < 0) pn_error_copy(pn_message_error(msg), pn_link_error(sender));
-  }
+  if (err >= 0) err = pn_link_send(sender, buffer->start, size);
+  if (err >= 0) err = pn_link_advance(sender);
+  if (err < 0) pn_error_copy(pn_message_error(msg), pn_link_error(sender));
   free(local_buf.start);
   return err;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7717a47/c/tests/connection_driver.c
----------------------------------------------------------------------
diff --git a/c/tests/connection_driver.c b/c/tests/connection_driver.c
index 7e4489a..62655a7 100644
--- a/c/tests/connection_driver.c
+++ b/c/tests/connection_driver.c
@@ -106,7 +106,6 @@ static void test_message_transfer(test_t *t) {
   pn_message_send(m, snd, NULL);
   pn_message_free(m);
 
-  TEST_CHECK(t, pn_link_advance(snd));
   test_connection_drivers_run(&client, &server);
   TEST_HANDLER_EXPECT(&server.handler, PN_TRANSPORT, PN_DELIVERY, 0);
 


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

Reply via email to