From 12d99f8b4d22d9b8f0c3c2df1308c75d7222be98 Mon Sep 17 00:00:00 2001 From: wcrisman Date: Wed, 30 Jul 2014 23:21:05 -0700 Subject: [PATCH] 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). --- Common/src/com/common/thread/ThreadService.java | 8 ++++---- .../src/com/foundation/web/server/WebServer.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Common/src/com/common/thread/ThreadService.java b/Common/src/com/common/thread/ThreadService.java index 6c8fa67..555f5ca 100644 --- a/Common/src/com/common/thread/ThreadService.java +++ b/Common/src/com/common/thread/ThreadService.java @@ -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// diff --git a/Foundation Web Core/src/com/foundation/web/server/WebServer.java b/Foundation Web Core/src/com/foundation/web/server/WebServer.java index fbe20d1..3d6f1f3 100644 --- a/Foundation Web Core/src/com/foundation/web/server/WebServer.java +++ b/Foundation Web Core/src/com/foundation/web/server/WebServer.java @@ -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//