make control message ingress buffer bounded

This commit is contained in:
Patrik Nordwall 2016-05-12 13:19:57 +02:00
parent 5e3eb4bd8c
commit 1296f9986f

View file

@ -155,6 +155,7 @@ private[akka] class OutboundControlJunction(outboundContext: OutboundContext)
import OutboundControlJunction._
private val sendControlMessageCallback = getAsyncCallback[ControlMessage](internalSendControlMessage)
private val maxControlMessageBufferSize: Int = 1024 // FIXME config
private val buffer = new ArrayDeque[Send]
override def preStart(): Unit = {
@ -180,8 +181,13 @@ private[akka] class OutboundControlJunction(outboundContext: OutboundContext)
private def internalSendControlMessage(message: ControlMessage): Unit = {
if (buffer.isEmpty && isAvailable(out))
push(out, wrap(message))
else
else if (buffer.size < maxControlMessageBufferSize)
buffer.offer(wrap(message))
else {
// it's alright to drop control messages
// FIXME we need that stage logging support
println(s"dropping control message ${message.getClass.getName} due to full buffer")
}
}
private def wrap(message: ControlMessage): Send =