*) last bugfix part. Seems to work now for the stackCrawler

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1478 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent b9c9eaeb44
commit 0fcd113c42

@ -435,10 +435,12 @@ final class CrawlerFactory implements org.apache.commons.pool.PoolableObjectFact
if (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;
}

@ -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 task

@ -716,10 +716,12 @@ public final class serverCore extends serverAbstractThread implements serverThre
public 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

Loading…
Cancel
Save