[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...
Ron Sigal
ron_sigal at yahoo.com
Tue Nov 13 03:57:12 EST 2007
User: rsigal
Date: 07/11/13 03:57:12
Modified: src/main/org/jboss/remoting/transport/socket Tag:
remoting_2_x ServerThread.java
Log:
JBREM-807, JBREM-821: (1) Moved processNewSocket() from constructor and startup() to run(); (2) moved notifyAll() in run(); (3) moved body of shutdown() to evict(), so that shutdown() calls evict(); (4) removed unblock().
Revision Changes Path
No revision
No revision
1.29.2.26 +33 -52 JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerThread.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java,v
retrieving revision 1.29.2.25
retrieving revision 1.29.2.26
diff -u -b -r1.29.2.25 -r1.29.2.26
--- ServerThread.java 12 Nov 2007 06:48:39 -0000 1.29.2.25
+++ ServerThread.java 13 Nov 2007 08:57:12 -0000 1.29.2.26
@@ -68,7 +68,7 @@
* @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
*
- * @version $Revision: 1.29.2.25 $
+ * @version $Revision: 1.29.2.26 $
*/
public class ServerThread extends Thread
{
@@ -139,7 +139,7 @@
this.invoker = invoker;
this.clientpool = clientpool;
this.threadpool = threadpool;
- processNewSocket();
+// processNewSocket();
if (invoker != null)
{
@@ -162,6 +162,8 @@
{
try
{
+ processNewSocket();
+
while (true)
{
dorun();
@@ -186,7 +188,6 @@
{
if(trace) { log.trace(this + " removing itself from clientpool"); }
clientpool.remove(this);
- clientpool.notifyAll();
if (shutdown)
{
@@ -198,6 +199,7 @@
{
if(trace) { log.trace(this + " returning itself to threadpool"); }
threadpool.add(this);
+ clientpool.notifyAll();
Thread.interrupted(); // clear any interruption so that we can be pooled.
}
}
@@ -256,7 +258,7 @@
running = true;
handlingResponse = true;
- processNewSocket();
+// processNewSocket();
notify();
if(trace) { log.trace(this + " has notified on mutex"); }
@@ -269,34 +271,9 @@
public synchronized void shutdown()
{
+ if (trace) log.trace("attempting to shut down " + this);
shutdown = true;
- running = false;
-
- // This is a race and there is a chance that a invocation is going on at the time of the
- // interrupt. But I see no way right now to protect for this.
-
- // NOTE ALSO!: Shutdown should never be synchronized. We don't want to hold up accept()
- // thread! (via LRUpool)
-
- synchronized (this)
- {
- try
- {
- if (socketWrapper != null)
- {
- log.debug(this + " closing socketWrapper: " + socketWrapper);
- socketWrapper.close();
- }
- }
- catch (Exception ex)
- {
- log.debug("failed to close socket wrapper", ex);
- }
- socketWrapper = null;
- }
-
- if (trace) log.trace(this + " shutting down");
- notifyAll();
+ evict();
}
/**
@@ -317,45 +294,49 @@
return this.shouldCheckConnection;
}
- public void evict()
+ public synchronized void evict()
{
running = false;
// This is a race and there is a chance that a invocation is going on at the time of the
- // interrupt. But I see no way right now to protect for this. There may not be a problem
- // because interrupt only effects threads blocking on IO.
+ // interrupt. But I see no way right now to protect for this.
// NOTE ALSO!: Shutdown should never be synchronized. We don't want to hold up accept()
// thread! (via LRUpool)
- if (!handlingResponse)
- {
try
{
- this.interrupt();
- Thread.interrupted(); // clear
- }
- catch (Exception ignored)
+ if (socketWrapper != null)
{
+ log.debug(this + " closing socketWrapper: " + socketWrapper);
+ socketWrapper.close();
}
}
+ catch (Exception ex)
+ {
+ log.debug("failed to close socket wrapper", ex);
+ }
+ socketWrapper = null;
+
+ if (trace) log.trace(this + " shutting down");
+ notifyAll();
}
/**
* This method is intended to be used when need to unblock I/O read, which the thread will
* automatically loop back to do after processing a request.
*/
- public void unblock()
- {
- try
- {
- socket.close();
- }
- catch (IOException e)
- {
- log.warn("Error closing socket when attempting to unblock I/O", e);
- }
- }
+// public synchronized void unblock()
+// {
+// try
+// {
+// socketWrapper.close();
+// }
+// catch (IOException e)
+// {
+// log.warn("Error closing socket when attempting to unblock I/O", e);
+// }
+// }
public String toString()
{
More information about the jboss-cvs-commits
mailing list