Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
trying to avoid "exceeding limit" message of server
orbiteraac89bf8ca4f
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex 7d36b0bfc..7b8bd61c5 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -145,29 +145,24 @@ public final class serverCore extends serverAbstractBusyThread implements serverif (threadCount < maxBusySessions - 10) return; // don't panicfinal Thread[] threadList = new Thread[this.getJobCount()];threadCount = serverCore.sessionThreadGroup.enumerate(threadList);- for (int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {- final Thread currentThread = threadList[currentThreadIdx];- if (- (currentThread != null) &&- (currentThread instanceof Session) &&- (currentThread.isAlive()) &&- (((Session) currentThread).getTime() > minage)- ) {- this.log.logInfo("check for " + currentThread.getName() + ": " + ((Session) currentThread).getTime() + " ms alive, stopping thread");- Session session = (Session) currentThread;+ for (int threadIdx = 0; threadIdx < threadCount; threadIdx++ ) {+ final Thread t = threadList[threadIdx];+ if (t != null && t instanceof Session && t.isAlive() && ((Session) t).getTime() > minage) {+ this.log.logInfo("check for " + t.getName() + ": " + ((Session) t).getTime() + " ms alive, stopping thread");+// trying to stop session- session.setStopped(true);+ ((Session) t).setStopped(true);try { Thread.sleep(100); } catch (final InterruptedException ex) {}// trying to interrupt session- if (currentThread.isAlive()) {- currentThread.interrupt();- try { Thread.sleep(10); } catch (final InterruptedException ex) {}+ if (t.isAlive()) {+ t.interrupt();+ try {Thread.sleep(10);} catch (final InterruptedException ex) {}}// trying to close socket- if (currentThread.isAlive()) {- ((Session)currentThread).close();+ if (t.isAlive()) {+ ((Session) t).close();}}}@@ -332,8 +327,12 @@ public final class serverCore extends serverAbstractBusyThread implements serverannounceThreadBlockRelease();- if(this.busySessions.size() >= this.maxBusySessions)- {++ if (this.busySessions.size() >= this.maxBusySessions) {+ terminateOldSessions(30000);+ }++ if (this.busySessions.size() >= this.maxBusySessions) {// immediately close connection if too much sessions are still runningthis.log.logWarning("* connections (" + this.busySessions.size() + ") exceeding limit (" + this.maxBusySessions + "), closing new incoming connection from "+ controlSocket.getRemoteSocketAddress());controlSocket.close();