Fix bufferedReaders not closed
This commit is contained in:
@@ -206,9 +206,7 @@ class RootServer {
|
|||||||
}
|
}
|
||||||
val errorReader = async(Dispatchers.IO) {
|
val errorReader = async(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
process.errorStream.bufferedReader().useLines { seq ->
|
process.errorStream.bufferedReader().forEachLine(Logger.me::w)
|
||||||
for (line in seq) Logger.me.w(line)
|
|
||||||
}
|
|
||||||
} catch (_: IOException) { }
|
} catch (_: IOException) { }
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: MacAddr
|
|||||||
.toList()
|
.toList()
|
||||||
private fun arp(): List<List<String>> {
|
private fun arp(): List<List<String>> {
|
||||||
if (System.nanoTime() - arpCacheTime >= ARP_CACHE_EXPIRE) try {
|
if (System.nanoTime() - arpCacheTime >= ARP_CACHE_EXPIRE) try {
|
||||||
arpCache = File("/proc/net/arp").bufferedReader().lineSequence().makeArp()
|
arpCache = File("/proc/net/arp").bufferedReader().useLines { it.makeArp() }
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
if (e is FileNotFoundException && Build.VERSION.SDK_INT >= 29 &&
|
if (e is FileNotFoundException && Build.VERSION.SDK_INT >= 29 &&
|
||||||
(e.cause as? ErrnoException)?.errno == OsConstants.EACCES) try {
|
(e.cause as? ErrnoException)?.errno == OsConstants.EACCES) try {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class ProcessListener(private val terminateRegex: Regex,
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
class ReadArp : RootCommand<ParcelableString> {
|
class ReadArp : RootCommand<ParcelableString> {
|
||||||
override suspend fun execute() = withContext(Dispatchers.IO) {
|
override suspend fun execute() = withContext(Dispatchers.IO) {
|
||||||
ParcelableString(File("/proc/net/arp").bufferedReader().readText())
|
ParcelableString(File("/proc/net/arp").readText())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ object RepeaterCommands {
|
|||||||
File(if (legacy) CONF_PATH_LEGACY else CONF_PATH_TREBLE).writeText(data)
|
File(if (legacy) CONF_PATH_LEGACY else CONF_PATH_TREBLE).writeText(data)
|
||||||
for (process in File("/proc").listFiles { _, name -> TextUtils.isDigitsOnly(name) }!!) {
|
for (process in File("/proc").listFiles { _, name -> TextUtils.isDigitsOnly(name) }!!) {
|
||||||
val cmdline = try {
|
val cmdline = try {
|
||||||
File(process, "cmdline").inputStream().bufferedReader().readText()
|
File(process, "cmdline").inputStream().bufferedReader().use { it.readText() }
|
||||||
} catch (_: IOException) {
|
} catch (_: IOException) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user