From 03d759b2499a726fbfe9b83bd5ef888ed8621958 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Mon, 9 Aug 2021 16:06:45 +0200 Subject: [PATCH] Fix TcpConnection error handling `resumeReading` can fail, and in that case will `become(unregistering)`. Previously `become(connected(info))` would interfere with that. Likely fixes #30509 and #30474. #30435 looks similar but might be something different. --- akka-actor/src/main/scala/akka/io/TcpConnection.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/akka-actor/src/main/scala/akka/io/TcpConnection.scala b/akka-actor/src/main/scala/akka/io/TcpConnection.scala index 38d5491733..bf50a2b2c4 100644 --- a/akka-actor/src/main/scala/akka/io/TcpConnection.scala +++ b/akka-actor/src/main/scala/akka/io/TcpConnection.scala @@ -74,11 +74,12 @@ private[io] abstract class TcpConnection(val tcp: TcpExt, val channel: SocketCha val info = ConnectionInfo(registration, handler, keepOpenOnPeerClosed, useResumeWriting) + context.setReceiveTimeout(Duration.Undefined) + context.become(connected(info)) + // if we are in push mode or already have resumed reading in pullMode while waiting for Register // then register OP_READ interest if (!pullMode || (/*pullMode && */ !readingSuspended)) resumeReading(info, None) - context.setReceiveTimeout(Duration.Undefined) - context.become(connected(info)) case ResumeReading => readingSuspended = false