Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) last bugfix part. Seems to work now for the stackCrawler
theli0fcd113c42e0
diff --git a/source/de/anomic/plasma/plasmaCrawlLoader.java b/source/de/anomic/plasma/plasmaCrawlLoader.javaindex 45b2c1c29..75fcc2205 100644--- a/source/de/anomic/plasma/plasmaCrawlLoader.java+++ b/source/de/anomic/plasma/plasmaCrawlLoader.java@@ -435,10 +435,12 @@ final class CrawlerFactory implements org.apache.commons.pool.PoolableObjectFactif (obj == null) return;if (obj instanceof plasmaCrawlWorker) {plasmaCrawlWorker theWorker = (plasmaCrawlWorker) obj;- theWorker.destroyed = true;- theWorker.setName(plasmaCrawlWorker.threadBaseName + "_destroyed");- theWorker.setStopped(true);- theWorker.interrupt();+ synchronized(theWorker) {+ theWorker.destroyed = true;+ theWorker.setName(plasmaCrawlWorker.threadBaseName + "_destroyed");+ theWorker.setStopped(true);+ theWorker.interrupt();+ }}}@@ -446,13 +448,6 @@ final class CrawlerFactory implements org.apache.commons.pool.PoolableObjectFact* @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)*/public boolean validateObject(Object obj) {- if (obj == null) return false;- if (obj instanceof plasmaCrawlWorker) {- plasmaCrawlWorker theWorker = (plasmaCrawlWorker) obj;- if (!theWorker.isAlive() || theWorker.isInterrupted()) return false;- if (theWorker.isRunning()) return true;- return false;- }return true;}diff --git a/source/de/anomic/plasma/plasmaCrawlWorker.java b/source/de/anomic/plasma/plasmaCrawlWorker.javaindex 35f370844..950102f5c 100644--- a/source/de/anomic/plasma/plasmaCrawlWorker.java+++ b/source/de/anomic/plasma/plasmaCrawlWorker.java@@ -169,12 +169,16 @@ public final class plasmaCrawlWorker extends Thread {try {// The thread keeps running.while (!this.stopped && !this.isInterrupted() && !this.myPool.isClosed) {- if (this.done) {- // return thread back into pool- this.myPool.returnObject(this);-- // We are waiting for a new task now.- synchronized (this) { this.wait(); }+ if (this.done) {+ synchronized (this) {+ // return thread back into pool+ this.myPool.returnObject(this);++ // We are waiting for a new task now.+ if (!this.stopped && !this.destroyed && !this.isInterrupted()) {+ this.wait();+ }+ }} else {try {// executing the new taskdiff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex 3780fbd39..d1a69b6d6 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -716,10 +716,12 @@ public final class serverCore extends serverAbstractThread implements serverThrepublic void destroyObject(Object obj) {if (obj instanceof Session) {Session theSession = (Session) obj;- theSession.destroyed = true;- theSession.setName("Session_destroyed");- theSession.setStopped(true);- theSession.interrupt();+ synchronized(theSession) {+ theSession.destroyed = true;+ theSession.setName("Session_destroyed");+ theSession.setStopped(true);+ theSession.interrupt();+ }}}@@ -727,12 +729,6 @@ public final class serverCore extends serverAbstractThread implements serverThre* @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)*/public boolean validateObject(Object obj) {- if (obj instanceof Session) {- Session theSession = (Session) obj;- if (!theSession.isAlive() || theSession.isInterrupted()) return false;- if (theSession.isRunning()) return true;- return false;- }return true;}@@ -934,11 +930,15 @@ public final class serverCore extends serverAbstractThread implements serverThre// The thread keeps running.while (!this.stopped && !this.isInterrupted() && !serverCore.this.theSessionPool.isClosed) {if (this.done) {- // return thread back into pool- serverCore.this.theSessionPool.returnObject(this);-- // We are waiting for a new task now.- synchronized (this) {this.wait();}+ synchronized (this) {+ // return thread back into pool+ serverCore.this.theSessionPool.returnObject(this);++ // We are waiting for a new task now.+ if (!this.stopped && !this.destroyed && !this.isInterrupted()) {+ this.wait();+ }+ }} else {try {// executing the new task