Skip to content

Commit

Permalink
don't panic when canceling server sessions
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5641 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Feb 23, 2009
1 parent 1df1fd9 commit b8c3803
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/de/anomic/server/serverCore.java
Expand Up @@ -141,10 +141,11 @@ public final void terminateOldSessions(long minage) {
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) &&
Expand All @@ -153,8 +154,9 @@ public final void terminateOldSessions(long minage) {
(((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
Expand Down

0 comments on commit b8c3803

Please sign in to comment.