You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/11/10 04:40:33 UTC
svn commit: r332217 - in /directory/network:
branches/0.8/src/java/org/apache/mina/util/BaseThreadPool.java
trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
Author: trustin
Date: Wed Nov 9 19:40:26 2005
New Revision: 332217
URL: http://svn.apache.org/viewcvs?rev=332217&view=rev
Log:
Fixed that some threads are not interrupted in ThreadPoolFilter.
Modified:
directory/network/branches/0.8/src/java/org/apache/mina/util/BaseThreadPool.java
directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
Modified: directory/network/branches/0.8/src/java/org/apache/mina/util/BaseThreadPool.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/java/org/apache/mina/util/BaseThreadPool.java?rev=332217&r1=332216&r2=332217&view=diff
==============================================================================
--- directory/network/branches/0.8/src/java/org/apache/mina/util/BaseThreadPool.java (original)
+++ directory/network/branches/0.8/src/java/org/apache/mina/util/BaseThreadPool.java Wed Nov 9 19:40:26 2005
@@ -189,7 +189,9 @@
worker.interrupt();
try
{
- worker.join();
+ // This timeout will help us from
+ // infinite lock-up and interrupt workers again.
+ worker.join( 100 );
}
catch( InterruptedException e )
{
@@ -380,7 +382,7 @@
BlockingQueue unfetchedSessionBuffers = BaseThreadPool.this.unfetchedSessionBuffers;
synchronized( unfetchedSessionBuffers )
{
- for( ;; )
+ while( !shuttingDown )
{
try
{
@@ -388,19 +390,14 @@
}
catch( InterruptedException e )
{
- if( shuttingDown )
- {
- return null;
- }
- else
- {
- continue;
- }
+ continue;
}
return BaseThreadPool.this.fetchSessionBuffer( unfetchedSessionBuffers );
}
}
+
+ return null;
}
private void processEvents( SessionBuffer buf )
@@ -466,7 +463,7 @@
synchronized( promotionLock )
{
- while( this != leader )
+ while( this != leader && !shuttingDown )
{
// Calculate remaining keep-alive time
int keepAliveTime = getKeepAliveTime();
@@ -492,10 +489,6 @@
}
catch( InterruptedException e )
{
- if( shuttingDown )
- {
- break;
- }
}
// Update currentTime for the next iteration
Modified: directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java?rev=332217&r1=332216&r2=332217&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java Wed Nov 9 19:40:26 2005
@@ -337,7 +337,7 @@
BlockingQueue unfetchedSessionBuffers = ThreadPoolFilter.this.unfetchedSessionBuffers;
synchronized( unfetchedSessionBuffers )
{
- for( ;; )
+ while( !shuttingDown )
{
try
{
@@ -345,19 +345,14 @@
}
catch( InterruptedException e )
{
- if( shuttingDown )
- {
- return null;
- }
- else
- {
- continue;
- }
+ continue;
}
return ThreadPoolFilter.this.fetchSessionBuffer( unfetchedSessionBuffers );
}
}
+
+ return null;
}
private void processEvents( SessionBuffer buf )
@@ -423,7 +418,7 @@
synchronized( promotionLock )
{
- while( this != leader )
+ while( this != leader && !shuttingDown )
{
// Calculate remaining keep-alive time
int keepAliveTime = getKeepAliveTime();
@@ -449,10 +444,6 @@
}
catch( InterruptedException e )
{
- if( shuttingDown )
- {
- break;
- }
}
// Update currentTime for the next iteration
@@ -697,10 +688,9 @@
worker.interrupt();
try
{
- // This timeout (100) will help us from
+ // This timeout will help us from
// infinite lock-up and interrupt workers again.
- // (Or we could acquire a monitor for unfetchedSessionBuffers.)
- worker.join();
+ worker.join( 100 );
}
catch( InterruptedException e )
{
Modified: directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java?rev=332217&r1=332216&r2=332217&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java Wed Nov 9 19:40:26 2005
@@ -106,9 +106,9 @@
final int end = sessions.length - 1;
final NextFilter nextFilter = new DummyNextFilter();
- for( int i = 0; i < 10000; i ++ )
+ for( int i = 0; i < 100000; i ++ )
{
- if( i % 100 == 0 )
+ if( i % 1000 == 0 )
{
System.out.println( "Shutdown: " + i );
}