don't panic when canceling server sessions

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5641 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 1df1fd91b0
commit b8c3803bfc

@ -141,10 +141,11 @@ public final class serverCore extends serverAbstractBusyThread implements server
if (System.currentTimeMillis() - lastAutoTermination < 30000) return;
this.lastAutoTermination = System.currentTimeMillis();
int threadCount = serverCore.sessionThreadGroup.activeCount();
int threadCount = serverCore.sessionThreadGroup.activeCount();
if (threadCount < maxBusySessions - 10) return; // don't panic
final Thread[] threadList = new Thread[this.getJobCount()];
threadCount = serverCore.sessionThreadGroup.enumerate(threadList);
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
for (int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
final Thread currentThread = threadList[currentThreadIdx];
if (
(currentThread != null) &&
@ -153,8 +154,9 @@ public final class serverCore extends serverAbstractBusyThread implements server
(((Session) currentThread).getTime() > minage)
) {
this.log.logInfo("check for " + currentThread.getName() + ": " + ((Session) currentThread).getTime() + " ms alive, stopping thread");
Session session = (Session) currentThread;
// trying to stop session
((Session)currentThread).setStopped(true);
session.setStopped(true);
try { Thread.sleep(100); } catch (final InterruptedException ex) {}
// trying to interrupt session

Loading…
Cancel
Save