qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [09/13] qpid-proton git commit: PROTON-848, PROTON-849: dont store the TransportSession or TransportLink state in maps, use the references set on the associated Session and Link objects. Update channel+link reference handling to behave more like proton-c
Date Sat, 25 Apr 2015 19:36:10 GMT
PROTON-848, PROTON-849: dont store the TransportSession or TransportLink state in maps, use
the references set on the associated Session and Link objects. Update channel+link reference
handling to behave more like proton-c in order to resolve the resulting test failures.

This closes #20

(cherry picked from commit f7e7ddde81cfbe02d1c24cf02df0e9a663c8dbc1)


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

Branch: refs/heads/0.9.x
Commit: 38006eb0030e445227cd211acccdfab8c6c55778
Parents: b912adb
Author: Robert Gemmell <robbie@apache.org>
Authored: Mon Apr 20 10:21:11 2015 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Sat Apr 25 20:24:17 2015 +0100

----------------------------------------------------------------------
 .../qpid/proton/engine/impl/TransportImpl.java  | 18 ++++-------
 .../qpid/proton/engine/impl/TransportLink.java  | 19 ++++++++++--
 .../proton/engine/impl/TransportSession.java    | 32 ++++++++++++++++++++
 tests/python/proton_tests/engine.py             |  3 +-
 4 files changed, 56 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38006eb0/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index ee190a6..551a699 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -96,10 +96,6 @@ public class TransportImpl extends EndpointImpl
     private TransportInput _inputProcessor;
     private TransportOutput _outputProcessor;
 
-    private Map<SessionImpl, TransportSession> _transportSessionState = new HashMap<SessionImpl,
TransportSession>();
-    private Map<LinkImpl, TransportLink<?>> _transportLinkState = new HashMap<LinkImpl,
TransportLink<?>>();
-
-
     private DecoderImpl _decoder = new DecoderImpl();
     private EncoderImpl _encoder = new EncoderImpl(_decoder);
 
@@ -252,12 +248,11 @@ public class TransportImpl extends EndpointImpl
     @Override
     public void unbind()
     {
-        for (TransportSession ts: _transportSessionState.values()) {
+        for (TransportSession ts: _localSessions.values()) {
             ts.unbind();
         }
-
-        for (TransportLink tl: _transportLinkState.values()) {
-            tl.unbind();
+        for (TransportSession ts: _remoteSessions.values()) {
+            ts.unbind();
         }
 
         put(Event.Type.CONNECTION_UNBOUND, _connectionEndpoint);
@@ -846,23 +841,21 @@ public class TransportImpl extends EndpointImpl
 
     private TransportSession getTransportState(SessionImpl session)
     {
-        TransportSession transportSession = _transportSessionState.get(session);
+        TransportSession transportSession = session.getTransportSession();
         if(transportSession == null)
         {
             transportSession = new TransportSession(this, session);
             session.setTransportSession(transportSession);
-            _transportSessionState.put(session, transportSession);
         }
         return transportSession;
     }
 
     private TransportLink<?> getTransportState(LinkImpl link)
     {
-        TransportLink<?> transportLink = _transportLinkState.get(link);
+        TransportLink<?> transportLink = link.getTransportLink();
         if(transportLink == null)
         {
             transportLink = TransportLink.createTransportLink(link);
-            _transportLinkState.put(link, transportLink);
         }
         return transportLink;
     }
@@ -1248,6 +1241,7 @@ public class TransportImpl extends EndpointImpl
         {
             _remoteSessions.remove(channel);
             transportSession.receivedEnd();
+            transportSession.unsetRemoteChannel();
             SessionImpl session = transportSession.getSession();
             session.setRemoteState(EndpointState.CLOSED);
             ErrorCondition errorCondition = end.getError();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38006eb0/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
index 2b60266..bdd80b5 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java
@@ -46,9 +46,22 @@ class TransportLink<T extends LinkImpl>
 
     static <L extends LinkImpl> TransportLink<L> createTransportLink(L link)
     {
-        return (TransportLink<L>) (link instanceof ReceiverImpl
-                       ? new TransportReceiver((ReceiverImpl)link)
-                       : new TransportSender((SenderImpl)link));
+        if (link instanceof ReceiverImpl)
+        {
+            ReceiverImpl r = (ReceiverImpl) link;
+            TransportReceiver tr = new TransportReceiver(r);
+            r.setTransportLink(tr);
+
+            return (TransportLink<L>) tr;
+        }
+        else
+        {
+            SenderImpl s = (SenderImpl) link;
+            TransportSender ts = new TransportSender(s);
+            s.setTransportLink(ts);
+
+            return (TransportLink<L>) ts;
+        }
     }
 
     void unbind()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38006eb0/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
index 1b23df7..fb537cc 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java
@@ -130,19 +130,46 @@ class TransportSession
     public void unsetLocalChannel()
     {
         if (isLocalChannelSet()) {
+            unsetLocalHandles();
             _session.decref();
         }
         _localChannel = -1;
     }
 
+    private void unsetLocalHandles()
+    {
+        for(int i = 0; i < _localHandleMap.length; i++)
+        {
+            TransportLink<?> tl = _localHandleMap[i];
+            if(tl != null)
+            {
+                _localHandleMap[i] = null;
+                tl.clearLocalHandle();
+            }
+        }
+    }
+
     public void unsetRemoteChannel()
     {
         if (isRemoteChannelSet()) {
+            unsetRemoteHandles();
             _session.decref();
         }
         _remoteChannel = -1;
     }
 
+    private void unsetRemoteHandles()
+    {
+        for(int i = 0; i < _remoteHandleMap.length; i++)
+        {
+            TransportLink<?> tl = _remoteHandleMap[i];
+            if(tl != null)
+            {
+                _remoteHandleMap[i] = null;
+                tl.clearRemoteHandle();
+            }
+        }
+    }
 
     public UnsignedInteger getHandleMax()
     {
@@ -334,6 +361,11 @@ class TransportSession
         unsetLocalChannel();
     }
 
+    public void freeRemoteChannel()
+    {
+        unsetRemoteChannel();
+    }
+
     private void setRemoteIncomingWindow(UnsignedInteger incomingWindow)
     {
         _remoteIncomingWindow = incomingWindow;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38006eb0/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 82869db..62e73c1 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -2394,9 +2394,10 @@ class TeardownLeakTest(PeerTest):
                   Event.TRANSPORT_CLOSED)
 
     self.connection.free()
+    self.expect(Event.LINK_FINAL, Event.SESSION_FINAL)
     self.transport.unbind()
 
-    self.expect(Event.LINK_FINAL, Event.SESSION_FINAL, Event.CONNECTION_UNBOUND, Event.CONNECTION_FINAL)
+    self.expect(Event.CONNECTION_UNBOUND, Event.CONNECTION_FINAL)
 
   def testLocalRemoteLeak(self):
     self.doLeak(True, True)


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


Mime
View raw message