You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2022/09/06 21:52:24 UTC

[qpid-proton-dotnet] branch main updated: PROTON-2600 Fix leak of delivery tracking if settled in read handler

This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton-dotnet.git


The following commit(s) were added to refs/heads/main by this push:
     new 6e919f1  PROTON-2600 Fix leak of delivery tracking if settled in read handler
6e919f1 is described below

commit 6e919f175ce86caefbfcc36a7a869766887db994
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Tue Sep 6 17:50:57 2022 -0400

    PROTON-2600 Fix leak of delivery tracking if settled in read handler
    
    If the delivery is settled immediately in the read handler the session
    should not add the delivery to its tracking map.
---
 .../Implementation/ProtonSessionIncomingWindow.cs  |  2 +-
 .../Engine/Implementation/ProtonReceiverTest.cs    | 64 ++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/src/Proton/Engine/Implementation/ProtonSessionIncomingWindow.cs b/src/Proton/Engine/Implementation/ProtonSessionIncomingWindow.cs
index 429e790..d400153 100644
--- a/src/Proton/Engine/Implementation/ProtonSessionIncomingWindow.cs
+++ b/src/Proton/Engine/Implementation/ProtonSessionIncomingWindow.cs
@@ -139,7 +139,7 @@ namespace Apache.Qpid.Proton.Engine.Implementation
 
          link.RemoteTransfer(transfer, payload, out ProtonIncomingDelivery delivery);
 
-         if (!delivery.IsRemotelySettled && delivery.IsFirstTransfer)
+         if (!delivery.IsSettled && !delivery.IsRemotelySettled && delivery.IsFirstTransfer)
          {
             unsettled.Add(delivery.DeliveryId, delivery);
          }
diff --git a/test/Proton.Tests/Engine/Implementation/ProtonReceiverTest.cs b/test/Proton.Tests/Engine/Implementation/ProtonReceiverTest.cs
index 0c07adf..c697cd2 100644
--- a/test/Proton.Tests/Engine/Implementation/ProtonReceiverTest.cs
+++ b/test/Proton.Tests/Engine/Implementation/ProtonReceiverTest.cs
@@ -4965,5 +4965,69 @@ namespace Apache.Qpid.Proton.Engine.Implementation
 
          Assert.IsNull(failure);
       }
+
+      [Test]
+      public void TestReceiveDeliveriesAndSendDispositionUponReceipt()
+      {
+         IEngine engine = IEngineFactory.Proton.CreateNonSaslEngine();
+         engine.ErrorHandler(result => failure = result.FailureCause);
+         ProtonTestConnector peer = CreateTestPeer(engine);
+
+         byte[] payload = new byte[] { 1 };
+
+         peer.ExpectAMQPHeader().RespondWithAMQPHeader();
+         peer.ExpectOpen().Respond().WithContainerId("driver");
+         peer.ExpectBegin().Respond().WithNextOutgoingId(0);
+         peer.ExpectAttach().Respond();
+         peer.ExpectFlow().WithLinkCredit(3);
+         peer.RemoteTransfer().WithDeliveryId(0)
+                              .WithDeliveryTag(new byte[] { 1 })
+                              .WithMore(false)
+                              .WithMessageFormat(0)
+                              .WithPayload(payload).Queue();
+         peer.ExpectDisposition().WithFirst(0)
+                                 .WithSettled(true)
+                                 .WithState().Accepted();
+         peer.RemoteTransfer().WithDeliveryId(1)
+                              .WithDeliveryTag(new byte[] { 2 })
+                              .WithMore(false)
+                              .WithMessageFormat(0)
+                              .WithPayload(payload).Queue();
+         peer.ExpectDisposition().WithFirst(1)
+                                 .WithSettled(true)
+                                 .WithState().Accepted();
+         peer.RemoteTransfer().WithDeliveryId(2)
+                              .WithDeliveryTag(new byte[] { 3 })
+                              .WithMore(false)
+                              .WithMessageFormat(0)
+                              .WithPayload(payload).Queue();
+         peer.ExpectDisposition().WithFirst(2)
+                                 .WithSettled(true)
+                                 .WithState().Accepted();
+
+         IConnection connection = engine.Start().Open();
+         ISession session = connection.Session().Open();
+         IReceiver receiver = session.Receiver("receiver");
+         receiver.DeliveryReadHandler((delivery) =>
+         {
+            delivery.Disposition(Accepted.Instance, true);
+         });
+
+         receiver.AddCredit(3);
+         receiver.Open();
+
+         peer.WaitForScriptToComplete();
+         peer.ExpectDetach().Respond();
+         peer.ExpectEnd().Respond();
+         peer.ExpectClose().Respond();
+
+         receiver.Close();
+         session.Close();
+         connection.Close();
+
+         // Check post conditions and done.
+         peer.WaitForScriptToComplete();
+         Assert.IsNull(failure);
+      }
    }
 }


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