*) 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 == null) return;
if (obj instanceof plasmaCrawlWorker) { if (obj instanceof plasmaCrawlWorker) {
plasmaCrawlWorker theWorker = (plasmaCrawlWorker) obj; plasmaCrawlWorker theWorker = (plasmaCrawlWorker) obj;
theWorker.destroyed = true; synchronized(theWorker) {
theWorker.setName(plasmaCrawlWorker.threadBaseName + "_destroyed"); theWorker.destroyed = true;
theWorker.setStopped(true); theWorker.setName(plasmaCrawlWorker.threadBaseName + "_destroyed");
theWorker.interrupt(); 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) * @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)
*/ */
public boolean validateObject(Object obj) { 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; return true;
} }

@ -169,12 +169,16 @@ public final class plasmaCrawlWorker extends Thread {
try { try {
// The thread keeps running. // The thread keeps running.
while (!this.stopped && !this.isInterrupted() && !this.myPool.isClosed) { while (!this.stopped && !this.isInterrupted() && !this.myPool.isClosed) {
if (this.done) { if (this.done) {
// return thread back into pool synchronized (this) {
this.myPool.returnObject(this); // return thread back into pool
this.myPool.returnObject(this);
// We are waiting for a new task now.
synchronized (this) { this.wait(); } // We are waiting for a new task now.
if (!this.stopped && !this.destroyed && !this.isInterrupted()) {
this.wait();
}
}
} else { } else {
try { try {
// executing the new task // executing the new task

@ -716,10 +716,12 @@ public final class serverCore extends serverAbstractThread implements serverThre
public void destroyObject(Object obj) { public void destroyObject(Object obj) {
if (obj instanceof Session) { if (obj instanceof Session) {
Session theSession = (Session) obj; Session theSession = (Session) obj;
theSession.destroyed = true; synchronized(theSession) {
theSession.setName("Session_destroyed"); theSession.destroyed = true;
theSession.setStopped(true); theSession.setName("Session_destroyed");
theSession.interrupt(); 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) * @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)
*/ */
public boolean validateObject(Object obj) { 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; return true;
} }
@ -934,11 +930,15 @@ public final class serverCore extends serverAbstractThread implements serverThre
// The thread keeps running. // The thread keeps running.
while (!this.stopped && !this.isInterrupted() && !serverCore.this.theSessionPool.isClosed) { while (!this.stopped && !this.isInterrupted() && !serverCore.this.theSessionPool.isClosed) {
if (this.done) { if (this.done) {
// return thread back into pool synchronized (this) {
serverCore.this.theSessionPool.returnObject(this); // return thread back into pool
serverCore.this.theSessionPool.returnObject(this);
// We are waiting for a new task now.
synchronized (this) {this.wait();} // We are waiting for a new task now.
if (!this.stopped && !this.destroyed && !this.isInterrupted()) {
this.wait();
}
}
} else { } else {
try { try {
// executing the new task // executing the new task

Loading…
Cancel
Save