=rem #3633 Fix race between EndpointWriter Terminated and TakeOver

This commit is contained in:
Björn Antonsson 2013-11-15 08:59:46 +01:00
parent e104e2a92c
commit 838e8ffbc1
5 changed files with 43 additions and 10 deletions

View file

@ -528,6 +528,8 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
case InboundAssociation(handle: AkkaProtocolHandle) endpoints.readOnlyEndpointFor(handle.remoteAddress) match {
case Some(endpoint)
pendingReadHandoffs.get(endpoint) foreach (_.disassociate())
pendingReadHandoffs += endpoint -> handle
endpoint ! EndpointWriter.TakeOver(handle)
case None
if (endpoints.isQuarantined(handle.remoteAddress, handle.handshakeInfo.uid))
@ -566,6 +568,8 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
case Terminated(endpoint)
acceptPendingReader(takingOverFrom = endpoint)
endpoints.unregisterEndpoint(endpoint)
case EndpointWriter.TookOver(endpoint, handle)
removePendingReader(takingOverFrom = endpoint, withHandle = handle)
case Prune
endpoints.prune()
case ShutdownAndFlush
@ -659,6 +663,11 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
}
}
private def removePendingReader(takingOverFrom: ActorRef, withHandle: AkkaProtocolHandle): Unit = {
if (pendingReadHandoffs.get(takingOverFrom).exists(handle handle == withHandle))
pendingReadHandoffs -= takingOverFrom
}
private def createEndpoint(remoteAddress: Address,
localAddress: Address,
transport: Transport,