Коммит 2b56035c создал по автору Leonid Stashevsky's avatar Leonid Stashevsky
Просмотр файлов

Fix race in websocket close

владелец c2d53b39
...@@ -116,8 +116,11 @@ private fun Route.webSocketProtocol(protocol: String?, block: Route.() -> Unit) ...@@ -116,8 +116,11 @@ private fun Route.webSocketProtocol(protocol: String?, block: Route.() -> Unit)
private suspend fun WebSocketServerSession.proceedWebSocket(handler: suspend DefaultWebSocketServerSession.() -> Unit) { private suspend fun WebSocketServerSession.proceedWebSocket(handler: suspend DefaultWebSocketServerSession.() -> Unit) {
val webSockets = application.feature(WebSockets) val webSockets = application.feature(WebSockets)
val session = val session = DefaultWebSocketSessionImpl(
DefaultWebSocketSessionImpl(this, webSockets.pingInterval?.toMillis() ?: -1L, webSockets.timeout.toMillis()) this,
webSockets.pingInterval?.toMillis() ?: -1L,
webSockets.timeout.toMillis()
)
session.run { session.run {
try { try {
toServerSession(call).handler() toServerSession(call).handler()
......
...@@ -245,7 +245,7 @@ abstract class WebSocketEngineSuite<TEngine : ApplicationEngine, TConfiguration ...@@ -245,7 +245,7 @@ abstract class WebSocketEngineSuite<TEngine : ApplicationEngine, TConfiguration
@Test @Test
fun testProduceMessages() { fun testProduceMessages() {
val count = 125 val count = 125
val template = (1..count).map { (it and 0x0f).toString(16) }.joinToString("") val template = (1..count).joinToString("") { (it and 0x0f).toString(16) }
createAndStartServer { createAndStartServer {
webSocket("/") { webSocket("/") {
......
...@@ -64,7 +64,7 @@ class DefaultWebSocketSessionImpl( ...@@ -64,7 +64,7 @@ class DefaultWebSocketSessionImpl(
else -> CloseReason(CloseReason.Codes.UNEXPECTED_CONDITION, cause.message ?: cause.javaClass.name) else -> CloseReason(CloseReason.Codes.UNEXPECTED_CONDITION, cause.message ?: cause.javaClass.name)
} }
sendCloseSequence(reason) reason?.let { send(Frame.Close(it)) }
} }
@UseExperimental(ExperimentalCoroutinesApi::class, ObsoleteCoroutinesApi::class) @UseExperimental(ExperimentalCoroutinesApi::class, ObsoleteCoroutinesApi::class)
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать