Removed dead code.
Change to WebServer's listener code to ensure that there is always a thread listening (we somehow ended up with no thread listening in some cases).
This commit is contained in:
@@ -164,11 +164,11 @@ public class ThreadService {
|
||||
singleThreadedContext = null;
|
||||
target.run();
|
||||
}//if//
|
||||
else {
|
||||
Debug.log("A target must be provided in order to run a reusable thread.");
|
||||
}//else//
|
||||
// else {
|
||||
// Debug.log("A target must be provided in order to run a reusable thread.");
|
||||
// }//else//
|
||||
}//try//
|
||||
catch(Exception e) {
|
||||
catch(Throwable e) {
|
||||
if(e instanceof InterruptedException) {
|
||||
return;
|
||||
}//if//
|
||||
|
||||
@@ -1723,13 +1723,14 @@ public class WebServer {
|
||||
*/
|
||||
private class NetworkListener implements Runnable {
|
||||
private Selector selector = null;
|
||||
private int maxThreadCount = 0;
|
||||
private int activeThreadCount = 0;
|
||||
private Iterator selectedKeys = null;
|
||||
// private boolean hasListener = false;
|
||||
private volatile boolean stop = true;
|
||||
private volatile boolean hasRunnables = false;
|
||||
private LiteList runnables = new LiteList(10, 20);
|
||||
private int maxThreadCount = 0;
|
||||
private int activeThreadCount = 0;
|
||||
private int threadId = 1;
|
||||
|
||||
public NetworkListener(Selector selector, int maxThreadCount) {
|
||||
this.selector = selector;
|
||||
@@ -1752,6 +1753,9 @@ public class WebServer {
|
||||
if(stop) {
|
||||
stop = false;
|
||||
ThreadService.run(this);
|
||||
// Thread t = new Thread(this);
|
||||
// t.setName("Network Listener 1");
|
||||
// t.start();
|
||||
}//if//
|
||||
}//start()//
|
||||
/**
|
||||
@@ -1901,10 +1905,10 @@ public class WebServer {
|
||||
try {
|
||||
if(((SocketChannel) channel).isOpen()) {
|
||||
synchronized(this) {
|
||||
if(++activeThreadCount != maxThreadCount) {
|
||||
// if(++activeThreadCount != maxThreadCount) {
|
||||
//Start another thread to take this thread's place.//
|
||||
ThreadService.run(this);
|
||||
}//if//
|
||||
// }//if//
|
||||
}//synchronized//
|
||||
|
||||
if(isWrite) {
|
||||
@@ -1958,13 +1962,13 @@ public class WebServer {
|
||||
|
||||
//Loop if the last thread to wait for a message couldn't start another thread due to the max number of threads allowed.//
|
||||
synchronized(this) {
|
||||
if(activeThreadCount-- != maxThreadCount) {
|
||||
// if(activeThreadCount-- != maxThreadCount) {
|
||||
loop = false;
|
||||
|
||||
if(requiresWakeup) {
|
||||
selector.wakeup();
|
||||
}//if//
|
||||
}//if//
|
||||
// }//if//
|
||||
}//synchronized//
|
||||
}//finally//
|
||||
}//else if//
|
||||
|
||||
Reference in New Issue
Block a user