Commit b622545c authored by Mygod's avatar Mygod

Remove the useless sleep

parent c124e1e8
...@@ -41,25 +41,22 @@ abstract class LocalSocketListener(protected val tag: String) : Thread() { ...@@ -41,25 +41,22 @@ abstract class LocalSocketListener(protected val tag: String) : Thread() {
* Inherited class do not need to close input/output streams as they will be closed automatically. * Inherited class do not need to close input/output streams as they will be closed automatically.
*/ */
protected abstract fun accept(socket: LocalSocket) protected abstract fun accept(socket: LocalSocket)
override final fun run() { override final fun run() = LocalSocket().use { localSocket ->
Thread.sleep(500) val serverSocket = try {
LocalSocket().use { localSocket -> localSocket.bind(LocalSocketAddress(socketFile.absolutePath, LocalSocketAddress.Namespace.FILESYSTEM))
val serverSocket = try { LocalServerSocket(localSocket.fileDescriptor)
localSocket.bind(LocalSocketAddress(socketFile.absolutePath, LocalSocketAddress.Namespace.FILESYSTEM)) } catch (e: IOException) {
LocalServerSocket(localSocket.fileDescriptor) Log.e(tag, "unable to bind", e)
return
}
while (running) {
try {
serverSocket.accept()
} catch (e: IOException) { } catch (e: IOException) {
Log.e(tag, "unable to bind", e) Log.e(tag, "Error when accept socket", e)
return app.track(e)
} null
while (running) { }?.use(this::accept)
try {
serverSocket.accept()
} catch (e: IOException) {
Log.e(tag, "Error when accept socket", e)
app.track(e)
null
}?.use(this::accept)
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment