[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/bisocket ...
Ron Sigal
ron_sigal at yahoo.com
Tue Nov 27 13:28:36 EST 2007
User: rsigal
Date: 07/11/27 13:28:36
Modified: src/main/org/jboss/remoting/transport/bisocket Tag:
remoting_2_2_2_GA_CP BisocketClientInvoker.java
Log:
JBREM-845: Changed createSocket() so that wait() periodically wakes up and tests isConnected().
Revision Changes Path
No revision
No revision
1.1.2.13.2.13.4.1 +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.13.2.13
retrieving revision 1.1.2.13.2.13.4.1
diff -u -b -r1.1.2.13.2.13 -r1.1.2.13.2.13.4.1
--- BisocketClientInvoker.java 9 Aug 2007 03:43:07 -0000 1.1.2.13.2.13
+++ BisocketClientInvoker.java 27 Nov 2007 18:28:36 -0000 1.1.2.13.2.13.4.1
@@ -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