Fixed race condition when we reassemble streaming/chunked data.

This commit is contained in:
Robinson 2022-06-29 19:38:10 +02:00
parent 683abcbe59
commit 09f367963f
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 13 additions and 13 deletions

View File

@ -524,8 +524,7 @@ internal constructor(val type: Class<*>,
message.payload = rawInput.readBytes(dataLength)
// NOTE: This MUST be on a new co-routine
actionDispatch.launch {
// NOTE: This MUST NOT be on a new co-routine. It must be on the same thread!
try {
streamingManager.processDataMessage(message, this@EndPoint)
} catch (e: Exception) {
@ -533,7 +532,6 @@ internal constructor(val type: Class<*>,
listenerManager.notifyError(connection, e)
}
}
}
is Any -> {

View File

@ -110,7 +110,7 @@ internal class StreamingManager<CONNECTION : Connection>(private val logger: KLo
val errorMessage = "Error serializing message from received streaming content, stream $streamId"
// either client or server. No other choices. We create an exception, because it's more useful!
val exception = endPoint.newException(errorMessage)
val exception = endPoint.newException(errorMessage, e)
// +2 because we do not want to see the stack for the abstract `newException`
// +3 more because we do not need to see the "internals" for sending messages. The important part of the stack trace is
@ -174,6 +174,8 @@ internal class StreamingManager<CONNECTION : Connection>(private val logger: KLo
}
/**
* NOTE: MUST BE ON THE AERON THREAD!
*
* Reassemble/figure out the internal message pieces
*
* NOTE sending a huge file can prevent other other network traffic from arriving until it's done!