[jboss-cvs] JBoss Messaging SVN: r7350 - in trunk: src/main/org/jboss/messaging/core/remoting/impl and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 15 13:22:54 EDT 2009
Author: timfox
Date: 2009-06-15 13:22:54 -0400 (Mon, 15 Jun 2009)
New Revision: 7350
Modified:
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/Pinger.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
Log:
fixed deadlock, small leak and a few tweaks
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-06-15 17:19:11 UTC (rev 7349)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-06-15 17:22:54 UTC (rev 7350)
@@ -796,7 +796,7 @@
for (ConnectionManager connectionManager : connectionManagerMap.values())
{
- connectionManager.close();
+ connectionManager.causeExit();
}
connectionManagerMap.clear();
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java 2009-06-15 17:19:11 UTC (rev 7349)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java 2009-06-15 17:22:54 UTC (rev 7350)
@@ -60,7 +60,9 @@
int numSessions();
- void close();
+ void causeExit();
RemotingConnection getConnection(final int initialRefCount);
+
+ void close();
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-06-15 17:19:11 UTC (rev 7349)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-06-15 17:22:54 UTC (rev 7350)
@@ -453,8 +453,23 @@
return sessions.size();
}
+ public void causeExit()
+ {
+ closed = true;
+ }
+
public void close()
{
+ synchronized (failoverLock)
+ {
+ synchronized (createSessionLock)
+ {
+ refCount = 0;
+
+ checkCloseConnections();
+ }
+ }
+
closed = true;
}
@@ -472,7 +487,7 @@
protected void finalize() throws Throwable
{
// In case user forgets to close it explicitly
- close();
+ causeExit();
super.finalize();
}
@@ -492,7 +507,7 @@
}
private boolean failoverOrReconnect(final MessagingException me, final Object connectionID)
- {
+ {
// To prevent recursion
if (inFailoverOrReconnect)
{
@@ -539,7 +554,7 @@
boolean attemptFailover = (backupConnectorFactory) != null && (failoverOnServerShutdown || me.getCode() != MessagingException.DISCONNECTED);
boolean done = false;
-
+
if (attemptFailover || reconnectAttempts != 0)
{
lockAllChannel1s();
@@ -588,7 +603,7 @@
{
oldConnections.add(entry.connection);
}
-
+
closePingers();
connections.clear();
@@ -639,7 +654,7 @@
else
{
// Fail the old connections so their listeners get called
-
+
for (RemotingConnection connection : oldConnections)
{
connection.fail(me);
@@ -649,9 +664,9 @@
else
{
// Just fail the connections
-
+
closePingers();
-
+
failConnection(me);
}
@@ -663,14 +678,14 @@
private void closePingers()
{
- for (Pinger pinger: pingers.values())
+ for (Pinger pinger : pingers.values())
{
- pinger.close();
+ pinger.close();
}
-
+
pingers.clear();
}
-
+
/*
* Re-attach sessions all pre-existing sessions to new remoting connections
*/
@@ -938,10 +953,14 @@
// Send the initial ping, we always do this it contains connectionTTL and clientFailureInterval -
// the server needs this in order to do pinging and failure checking
- Pinger pinger = new Pinger(conn, clientFailureCheckPeriod, new Channel0Handler(conn), new FailedConnectionAction(conn), 0);
-
+ Pinger pinger = new Pinger(conn,
+ clientFailureCheckPeriod,
+ new Channel0Handler(conn),
+ new FailedConnectionAction(conn),
+ 0);
+
pingers.put(conn.getID(), pinger);
-
+
Ping ping = new Ping(clientFailureCheckPeriod, connectionTTL);
Channel channel0 = conn.getChannel(0, -1, false);
@@ -955,7 +974,7 @@
clientFailureCheckPeriod,
TimeUnit.MILLISECONDS);
- pinger.setFuture(pingerFuture);
+ pinger.setFuture(pingerFuture);
}
if (debug)
@@ -1065,7 +1084,7 @@
}
private void failConnection(final Object connectionID, final MessagingException me)
- {
+ {
ConnectionEntry entry = connections.get(connectionID);
if (entry != null)
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/Pinger.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/Pinger.java 2009-06-15 17:19:11 UTC (rev 7349)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/Pinger.java 2009-06-15 17:22:54 UTC (rev 7350)
@@ -44,10 +44,8 @@
{
private static final Logger log = Logger.getLogger(Pinger.class);
- private boolean closed;
+ private volatile boolean closed;
- private RemotingConnection conn;
-
private Future<?> future;
private long lastPingReceived;
@@ -61,12 +59,12 @@
private final Channel channel0;
private boolean first = true;
-
+
+ private boolean stopPinging;
+
public Pinger(final RemotingConnection conn, final long expiryPeriod, final ChannelHandler extraHandler,
final Runnable connectionFailedAction, final long lastPingReceived)
{
- this.conn = conn;
-
this.expiryPeriod = expiryPeriod;
this.extraHandler = extraHandler;
@@ -125,18 +123,16 @@
first = false;
}
- public synchronized void close()
+ public void close()
{
if (future != null)
- {
+ {
future.cancel(false);
}
closed = true;
}
- private boolean stopPinging;
-
public synchronized void stopPinging()
{
this.stopPinging = true;
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-06-15 17:19:11 UTC (rev 7349)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-06-15 17:22:54 UTC (rev 7350)
@@ -40,6 +40,7 @@
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.impl.Pinger;
import org.jboss.messaging.core.remoting.impl.invm.InVMRegistry;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.jms.client.JBossBytesMessage;
@@ -1310,7 +1311,7 @@
{
backupServer.stop();
}
-
+
super.tearDown();
}
More information about the jboss-cvs-commits
mailing list