User: pkendall
Date: 01/07/31 18:18:32
Modified: src/main/org/jbossmq/il/oil OILServerILService.java
OILClientILService.java
Log:
Make the sockets fully blocking and close the socket when stopping. This is to work
around a bug in Sun's JDK sockets i.e. they don't throw InterruptedException on
timeout, you get a EOFException and the socket is then stuffed.
Revision Changes Path
1.6 +8 -9 jbossmq/src/main/org/jbossmq/il/oil/OILServerILService.java
Index: OILServerILService.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jbossmq/il/oil/OILServerILService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- OILServerILService.java 2001/07/31 21:36:23 1.5
+++ OILServerILService.java 2001/08/01 01:18:32 1.6
@@ -38,6 +38,7 @@
import javax.jms.TemporaryQueue;
import org.jbossmq.TransactionRequest;
import java.io.IOException;
+import java.io.EOFException;
import org.jbossmq.SpyDestination;
/**
@@ -45,7 +46,7 @@
* manage the JVM IL.
*
* @author Hiram Chirino ([EMAIL PROTECTED])
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class OILServerILService extends ServerILJMXService implements
OILServerILServiceMBean, Runnable {
@@ -158,6 +159,7 @@
if( !running )
return;
+ socket.setSoTimeout(0);
new Thread(this,"OIL Worker").start();
out = new ObjectOutputStream(new
BufferedOutputStream(socket.getOutputStream()));
@@ -174,17 +176,14 @@
while (!closed && running) {
try {
-
- //socket.setSoTimeout(SO_TIMEOUT);
code=in.readByte();
-
- } catch ( java.io.InterruptedIOException e ) {
- if( !closed && !running )
- continue;
- } catch (IOException e) {
+ }
+ catch ( EOFException e ) {
+ break;
+ }
+ catch ( IOException e ) {
if( closed || !running )
break;
-
category.warn("Connection failure (1).", e);
break;
}
1.3 +6 -9 jbossmq/src/main/org/jbossmq/il/oil/OILClientILService.java
Index: OILClientILService.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jbossmq/il/oil/OILClientILService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OILClientILService.java 2001/07/16 02:51:45 1.2
+++ OILClientILService.java 2001/08/01 01:18:32 1.3
@@ -30,7 +30,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class OILClientILService implements org.jbossmq.il.ClientILService, Runnable
{
//the client IL
@@ -58,7 +58,7 @@
public void start() throws java.lang.Exception {
running = true;
- worker = new Thread(connection.threadGroup, this,
"UILClientILService");
+ worker = new Thread(connection.threadGroup, this,
"OILClientILService");
worker.setDaemon(true);
worker.start();
@@ -70,6 +70,7 @@
public void stop() throws java.lang.Exception {
running = false;
worker.interrupt();
+ socket.close();
}
static org.apache.log4j.Category cat =
org.apache.log4j.Category.getInstance(OILClientILService.class);
@@ -85,12 +86,13 @@
private ServerSocket serverSocket;
//The thread that is doing the Socket reading work
Thread worker;
+ Socket socket=null;
public void run() {
- Socket socket=null;
int code = 0;
ObjectOutputStream out = null;
ObjectInputStream in = null;
+ socket = null;
try {
cat.debug("Waiting for the server to connect to me");
@@ -106,7 +108,7 @@
return;
}
serverSocket.close();
- socket.setSoTimeout(30*1000);
+ socket.setSoTimeout(0);
out = new ObjectOutputStream(new
BufferedOutputStream(socket.getOutputStream()));
out.flush();
in = new ObjectInputStream(new
BufferedInputStream(socket.getInputStream()));
@@ -124,12 +126,7 @@
} catch (java.io.InterruptedIOException e) {
continue;
} catch (IOException e) {
- if (!running)
- break;
-
- connection.asynchFailure("Connection failure", e);
- e.printStackTrace();
- return;
+ break;
}
try {
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development