mirror of
https://github.com/tursom/TursomServer.git
synced 2025-02-08 02:30:36 +08:00
已经超时的套接字不应该有任何操作
This commit is contained in:
parent
acfe8fda0a
commit
2dd2e8c5fb
@ -86,6 +86,7 @@ class AsyncNioSocket(override val key: SelectionKey, override val nioThread: INi
|
||||
buffer,
|
||||
it,
|
||||
timer.exec(timeout) {
|
||||
key.attach(null)
|
||||
try {
|
||||
it.resumeWithException(TimeoutException())
|
||||
} catch (e: Exception) {
|
||||
@ -112,6 +113,7 @@ class AsyncNioSocket(override val key: SelectionKey, override val nioThread: INi
|
||||
buffer,
|
||||
it,
|
||||
timer.exec(timeout) {
|
||||
key.attach(null)
|
||||
try {
|
||||
it.resumeWithException(TimeoutException())
|
||||
} catch (e: Exception) {
|
||||
@ -138,6 +140,7 @@ class AsyncNioSocket(override val key: SelectionKey, override val nioThread: INi
|
||||
buffer,
|
||||
it,
|
||||
timer.exec(timeout) {
|
||||
key.attach(null)
|
||||
try {
|
||||
it.resumeWithException(TimeoutException())
|
||||
} catch (e: Exception) {
|
||||
@ -164,6 +167,7 @@ class AsyncNioSocket(override val key: SelectionKey, override val nioThread: INi
|
||||
buffer,
|
||||
it,
|
||||
timer.exec(timeout) {
|
||||
key.attach(null)
|
||||
try {
|
||||
it.resumeWithException(TimeoutException())
|
||||
} catch (e: Exception) {
|
||||
@ -210,7 +214,7 @@ class AsyncNioSocket(override val key: SelectionKey, override val nioThread: INi
|
||||
|
||||
override fun handleRead(key: SelectionKey, nioThread: INioThread) {
|
||||
key.interestOps(0)
|
||||
val context = key.attachment() as Context
|
||||
val context = key.attachment() as Context? ?: return
|
||||
context.timeoutTask?.cancel()
|
||||
if (context is SingleContext) {
|
||||
val channel = key.channel() as SocketChannel
|
||||
@ -226,7 +230,7 @@ class AsyncNioSocket(override val key: SelectionKey, override val nioThread: INi
|
||||
|
||||
override fun handleWrite(key: SelectionKey, nioThread: INioThread) {
|
||||
key.interestOps(0)
|
||||
val context = key.attachment() as Context
|
||||
val context = key.attachment() as Context? ?: return
|
||||
context.timeoutTask?.cancel()
|
||||
if (context is SingleContext) {
|
||||
val channel = key.channel() as SocketChannel
|
||||
|
Loading…
Reference in New Issue
Block a user