Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 533AB17FD5 for ; Sat, 25 Apr 2015 19:36:03 +0000 (UTC) Received: (qmail 45679 invoked by uid 500); 25 Apr 2015 19:36:03 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 45580 invoked by uid 500); 25 Apr 2015 19:36:03 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 45206 invoked by uid 99); 25 Apr 2015 19:36:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Apr 2015 19:36:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BEDAEE2F71; Sat, 25 Apr 2015 19:36:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: robbie@apache.org To: commits@qpid.apache.org Date: Sat, 25 Apr 2015 19:36:10 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer 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 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 Authored: Mon Apr 20 10:21:11 2015 +0100 Committer: Robert Gemmell 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 _transportSessionState = new HashMap(); - private Map> _transportLinkState = new HashMap>(); - - 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 static TransportLink createTransportLink(L link) { - return (TransportLink) (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) tr; + } + else + { + SenderImpl s = (SenderImpl) link; + TransportSender ts = new TransportSender(s); + s.setTransportLink(ts); + + return (TransportLink) 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