mirror of
https://github.com/tursom/TursomServer.git
synced 2025-02-01 23:30:24 +08:00
update
This commit is contained in:
parent
c401579426
commit
cfbeeabf98
@ -16,7 +16,7 @@ class ThreadPoolNioThread(
|
||||
override lateinit var thread: Thread
|
||||
val threadPool: ExecutorService = ThreadPoolExecutor(1, 1,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
LinkedBlockingQueue<Runnable>(),
|
||||
LinkedBlockingQueue(),
|
||||
ThreadFactory {
|
||||
val thread = Thread(it)
|
||||
this.thread = thread
|
||||
@ -35,7 +35,13 @@ class ThreadPoolNioThread(
|
||||
while (keyIter.hasNext()) {
|
||||
val key = keyIter.next()
|
||||
keyIter.remove()
|
||||
workLoop(this@ThreadPoolNioThread, key)
|
||||
try {
|
||||
workLoop(this@ThreadPoolNioThread, key)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
key.cancel()
|
||||
key.channel().close()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!threadPool.isShutdown) threadPool.execute(this)
|
||||
|
@ -25,7 +25,13 @@ class WorkerLoopNioThread(
|
||||
while (keyIter.hasNext()) {
|
||||
val key = keyIter.next()
|
||||
keyIter.remove()
|
||||
workLoop(this, key)
|
||||
try {
|
||||
workLoop(this, key)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
key.cancel()
|
||||
key.channel().close()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@ -115,6 +121,4 @@ class WorkerLoopNioThread(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -29,14 +29,7 @@ open class BossLoopHandler(
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
try {
|
||||
protocol.exceptionCause(key, nioThread, e)
|
||||
} catch (e1: Throwable) {
|
||||
e.printStackTrace()
|
||||
e1.printStackTrace()
|
||||
key.cancel()
|
||||
key.channel().close()
|
||||
}
|
||||
protocol.exceptionCause(key, nioThread, e)
|
||||
}
|
||||
}
|
||||
}
|
@ -19,14 +19,7 @@ class WorkerLoopHandler(private val protocol: NioProtocol) : (NioThread, Selecti
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
try {
|
||||
protocol.exceptionCause(key, nioThread, e)
|
||||
} catch (e1: Throwable) {
|
||||
e.printStackTrace()
|
||||
e1.printStackTrace()
|
||||
key.cancel()
|
||||
key.channel().close()
|
||||
}
|
||||
protocol.exceptionCause(key, nioThread, e)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user