qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1539569 - in /qpid/trunk/qpid/java: amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/ amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/
Date Thu, 07 Nov 2013 09:09:03 GMT
Author: rgodfrey
Date: Thu Nov  7 09:09:02 2013
New Revision: 1539569

URL: http://svn.apache.org/r1539569
Log:
QPID-5295 : Thread deadlock on creating Sender

Modified:
    qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java
    qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
    qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
    qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java
    qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java

Modified: qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java?rev=1539569&r1=1539568&r2=1539569&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java
(original)
+++ qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java
Thu Nov  7 09:09:02 2013
@@ -142,31 +142,11 @@ public class Sender implements DeliveryS
     {
 
         _session = session;
+        _windowSize = window;
         session.getConnection().checkNotClosed();
         configureSource(source);
         configureTarget(target);
-        _endpoint = session.getEndpoint().createSendingLinkEndpoint(linkName,
-                                                                    source, target, unsettled);
-
-
-        switch(mode)
-        {
-            case ALO:
-                _endpoint.setSendingSettlementMode(SenderSettleMode.UNSETTLED);
-                _endpoint.setReceivingSettlementMode(ReceiverSettleMode.FIRST);
-                break;
-            case AMO:
-                _endpoint.setSendingSettlementMode(SenderSettleMode.SETTLED);
-                break;
-            case EO:
-                _endpoint.setSendingSettlementMode(SenderSettleMode.UNSETTLED);
-                _endpoint.setReceivingSettlementMode(ReceiverSettleMode.SECOND);
-                break;
-
-        }
-        _endpoint.setDeliveryStateHandler(this);
-        _endpoint.attach();
-        _windowSize = window;
+        _endpoint = session.createSendingLinkEndpoint(linkName, target, source, mode, unsettled,
this);
 
         synchronized(_endpoint.getLock())
         {
@@ -181,10 +161,14 @@ public class Sender implements DeliveryS
                     throw new SenderCreationException(e);
                 }
             }
+            if (session.getEndpoint().isEnded())
+            {
+                throw new SenderCreationException("Session is closed while creating link,
target: " + target.getAddress());
+            }
             if(_endpoint.getTarget()== null)
             {
                 throw new SenderCreationException("Peer did not create remote endpoint for
link, target: " + target.getAddress());
-            };
+            }
         }
 
         _endpoint.setLinkEventListener(new SendingLinkListener.DefaultLinkEventListener()

Modified: qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java?rev=1539569&r1=1539568&r2=1539569&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
(original)
+++ qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
Thu Nov  7 09:09:02 2013
@@ -24,6 +24,7 @@ import org.apache.qpid.amqp_1_0.messagin
 import org.apache.qpid.amqp_1_0.messaging.SectionDecoderImpl;
 import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
 import org.apache.qpid.amqp_1_0.messaging.SectionEncoderImpl;
+import org.apache.qpid.amqp_1_0.transport.DeliveryStateHandler;
 import org.apache.qpid.amqp_1_0.transport.SendingLinkEndpoint;
 import org.apache.qpid.amqp_1_0.transport.SessionEndpoint;
 import org.apache.qpid.amqp_1_0.transport.SessionState;
@@ -64,7 +65,7 @@ public class Session
     }
 
 
-    public synchronized Sender createSender(final String targetName)
+    public Sender createSender(final String targetName)
             throws Sender.SenderCreationException, ConnectionClosedException
     {
 
@@ -74,7 +75,7 @@ public class Session
     }
 
 
-    public synchronized Sender createSender(final String targetName, final SourceConfigurator
configurator)
+    public Sender createSender(final String targetName, final SourceConfigurator configurator)
             throws Sender.SenderCreationException, ConnectionClosedException
     {
 
@@ -90,7 +91,7 @@ public class Session
 
     }
 
-    public synchronized Sender createSender(final String targetName, int window)
+    public Sender createSender(final String targetName, int window)
             throws Sender.SenderCreationException, ConnectionClosedException
     {
          final String sourceName = UUID.randomUUID().toString();
@@ -113,6 +114,36 @@ public class Session
 
     }
 
+    public synchronized SendingLinkEndpoint createSendingLinkEndpoint(final String linkName,
+                                                                      final Target target,
+                                                                      final Source source,
+                                                                      AcknowledgeMode mode,
+                                                                      Map<Binary, Outcome>
unsettled,
+                                                                      final DeliveryStateHandler
deliveryStateHandler)
+    {
+        SendingLinkEndpoint link = this.getEndpoint().createSendingLinkEndpoint(linkName,
source, target,
+                                                                                unsettled,
deliveryStateHandler);
+
+        switch(mode)
+        {
+            case ALO:
+            	link.setSendingSettlementMode(SenderSettleMode.UNSETTLED);
+            	link.setReceivingSettlementMode(ReceiverSettleMode.FIRST);
+                break;
+            case AMO:
+            	link.setSendingSettlementMode(SenderSettleMode.SETTLED);
+                break;
+            case EO:
+            	link.setSendingSettlementMode(SenderSettleMode.UNSETTLED);
+            	link.setReceivingSettlementMode(ReceiverSettleMode.SECOND);
+                break;
+
+        }
+        
+        link.attach();
+        
+    	return link;
+    }
 
     public Receiver createReceiver(final String sourceAddr) throws ConnectionErrorException
     {

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java?rev=1539569&r1=1539568&r2=1539569&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
(original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
Thu Nov  7 09:09:02 2013
@@ -72,12 +72,17 @@ public abstract class LinkEndpoint<T ext
 
     LinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary, Outcome>
unsettled)
     {
+        this(sessionEndpoint, name, unsettled, null);
+    }
+
+    LinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary, Outcome>
unsettled, DeliveryStateHandler deliveryStateHandler)
+    {
         _name = name;
         _session = sessionEndpoint;
         _linkCredit = UnsignedInteger.valueOf(0);
         _drain = Boolean.FALSE;
         _localUnsettled = unsettled;
-
+        _deliveryStateHandler = deliveryStateHandler;
     }
 
     LinkEndpoint(final SessionEndpoint sessionEndpoint,final Attach attach)

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java?rev=1539569&r1=1539568&r2=1539569&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java
(original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java
Thu Nov  7 09:09:02 2013
@@ -49,6 +49,14 @@ public class SendingLinkEndpoint extends
         init();
     }
 
+
+    public SendingLinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary,
Outcome> unsettled,
+                               DeliveryStateHandler deliveryStateHandler)
+    {
+        super(sessionEndpoint, name, unsettled, deliveryStateHandler);
+        init();
+    }
+
     public SendingLinkEndpoint(final SessionEndpoint sessionEndpoint, final Attach attach)
     {
         super(sessionEndpoint, attach);

Modified: qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java?rev=1539569&r1=1539568&r2=1539569&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java
(original)
+++ qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java
Thu Nov  7 09:09:02 2013
@@ -507,7 +507,15 @@ public class SessionEndpoint
 
     public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final Source
source, final org.apache.qpid.amqp_1_0.type.Target target, Map<Binary, Outcome> unsettled)
     {
-        SendingLinkEndpoint endpoint = new SendingLinkEndpoint(this, name, unsettled);
+        return createSendingLinkEndpoint(name, source, target, unsettled, null);
+    }
+
+    public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final Source
source,
+                                                         final org.apache.qpid.amqp_1_0.type.Target
target,
+                                                         Map<Binary, Outcome> unsettled,
+                                                         DeliveryStateHandler deliveryStateHandler)
+    {
+        SendingLinkEndpoint endpoint = new SendingLinkEndpoint(this, name, unsettled, deliveryStateHandler);
         endpoint.setSource(source);
         endpoint.setTarget(target);
         UnsignedInteger handle = findNextAvailableHandle();



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


Mime
View raw message