[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/bisocket ...
Ron Sigal
ron_sigal at yahoo.com
Wed Nov 14 22:33:27 EST 2007
User: rsigal
Date: 07/11/14 22:33:26
Modified: src/main/org/jboss/remoting/transport/bisocket Tag:
remoting_2_x BisocketClientInvoker.java
Log:
JBREM-822, JBREM-845: In createSocket(), put synchronized block inside loop.
Revision Changes Path
No revision
No revision
1.1.2.21 +38 -27 JBossRemoting/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BisocketClientInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.java,v
retrieving revision 1.1.2.20
retrieving revision 1.1.2.21
diff -u -b -r1.1.2.20 -r1.1.2.21
--- BisocketClientInvoker.java 29 Aug 2007 07:16:01 -0000 1.1.2.20
+++ BisocketClientInvoker.java 15 Nov 2007 03:33:26 -0000 1.1.2.21
@@ -446,35 +446,34 @@
synchronized (sockets)
{
- if (sockets.isEmpty())
+ if (!sockets.isEmpty())
{
- long wait = timeout;
+ Iterator it = sockets.iterator();
+ Socket socket = (Socket) it.next();
+ it.remove();
+ log.debug(this + " found socket (" + listenerId + "): " + socket);
+ return socket;
+ }
+ }
+
+ long timeRemaining = timeout;
long start = System.currentTimeMillis();
- while (timeout == 0 || wait > 0)
+ while (isConnected() && (timeout == 0 || timeRemaining > 0))
+ {
+ synchronized (sockets)
{
try
{
- sockets.wait(wait);
- break;
+ sockets.wait(1000);
}
catch (InterruptedException e)
{
log.debug("unexpected interrupt");
- if (timeout > 0)
- wait = timeout - (System.currentTimeMillis() - start);
- }
- }
}
- if (sockets.isEmpty())
+ if (!sockets.isEmpty())
{
- if (!isConnected())
- throw new IOException("Unable to create socket: invoker is disconnected");
- else
- throw new IOException("Timed out trying to create socket");
- }
-
Iterator it = sockets.iterator();
Socket socket = (Socket) it.next();
it.remove();
@@ -483,6 +482,18 @@
}
}
+ if (timeout > 0)
+ timeRemaining = timeout - (System.currentTimeMillis() - start);
+ }
+
+ if (!isConnected())
+ {
+ throw new IOException("Connection is closed");
+ }
+
+ throw new IOException("Timed out trying to create socket");
+ }
+
void replaceControlSocket(Socket socket) throws IOException
{
More information about the jboss-cvs-commits
mailing list