From c3e2cc27738ae17f511c9814329bdaeecd703c2d Mon Sep 17 00:00:00 2001 From: jboner Date: Wed, 11 Nov 2009 23:12:22 +0100 Subject: [PATCH] fixed potential memory leak with temporary actors --- akka-actors/src/main/scala/actor/Actor.scala | 36 +++++++++----------- akka.iws | 27 ++------------- 2 files changed, 19 insertions(+), 44 deletions(-) diff --git a/akka-actors/src/main/scala/actor/Actor.scala b/akka-actors/src/main/scala/actor/Actor.scala index 6b201a6d33..ba87036c8c 100644 --- a/akka-actors/src/main/scala/actor/Actor.scala +++ b/akka-actors/src/main/scala/actor/Actor.scala @@ -642,30 +642,28 @@ trait Actor extends Logging with TransactionManagement { } private[this] def restartLinkedActors(reason: AnyRef) = { - - // FIXME remove all Temporary actors from _linkedActors, move restart code from restart(..) to this method - - _linkedActors.toArray.toList.asInstanceOf[List[Actor]].foreach(_.restart(reason)) - } - - private[Actor] def restart(reason: AnyRef) = synchronized { - lifeCycle match { - case None => throw new IllegalStateException("Actor [" + id + "] does not have a life-cycle defined.") - - // FIXME implement support for shutdown time - case Some(LifeCycle(scope, _)) => { - scope match { - case Permanent => - preRestart(reason, _config) - log.info("Restarting actor [%s] configured as PERMANENT.", id) - postRestart(reason, _config) - case Temporary => - log.info("Actor [%s] configured as TEMPORARY will not be restarted.", id) + _linkedActors.toArray.toList.asInstanceOf[List[Actor]].foreach { actor => + actor.lifeCycle match { + case None => throw new IllegalStateException("Actor [" + actor.id + "] does not have a life-cycle defined.") + case Some(LifeCycle(scope, _)) => { + scope match { + case Permanent => + actor.restart(reason) + case Temporary => + log.info("Actor [%s] configured as TEMPORARY will not be restarted.", actor.id) + _linkedActors.remove(actor) // remove the temporary actor + } } } } } + private[Actor] def restart(reason: AnyRef) = synchronized { + preRestart(reason, _config) + log.info("Restarting actor [%s] configured as PERMANENT.", id) + postRestart(reason, _config) + } + private[akka] def registerSupervisorAsRemoteActor: Option[String] = synchronized { if (_supervisor.isDefined) { RemoteClient.clientFor(_remoteAddress.get).registerSupervisorForActor(this) diff --git a/akka.iws b/akka.iws index 4b9d942599..f930b8f264 100644 --- a/akka.iws +++ b/akka.iws @@ -6,30 +6,7 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -169,7 +146,7 @@ - + @@ -1670,7 +1647,7 @@ - +