Fix EBADF error with proguard

This commit is contained in:
Max Lv
2017-12-05 23:16:29 -08:00
parent f4e5a958e0
commit f870093c94
2 changed files with 19 additions and 7 deletions
@@ -54,16 +54,26 @@ abstract class LocalSocketListener(private val tag: String) : Thread() {
while (true) {
val serverSocket = serverSocket.get() ?: return
try {
val socket = serverSocket.accept()
try {
serverSocket.accept()
} catch (e: IOException) {
Log.e(tag, "Error when accept socket", e)
accept(socket)
} catch (e: Exception) {
Log.e(tag, "Error when recv traffic stat", e)
app.track(e)
null
}?.use(this::accept)
} catch (e: Exception) {
Log.e(tag, "Error when recv traffic stat", e)
}
try {
socket.close()
} catch (e: IOException) {
Log.e(tag, "Error when closing the local socket", e)
app.track(e)
}
} catch (e: IOException) {
Log.e(tag, "Error when accept socket", e)
app.track(e)
return
}
}
}