Skip to content

Commit

Permalink
Remove second thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Aug 28, 2024
1 parent 93b0802 commit f6430c7
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,26 @@ import android.net.Network
import android.os.Build
import android.os.CancellationSignal
import com.github.shadowsocks.Core
import kotlinx.coroutines.*
import org.xbill.DNS.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Runnable
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withContext
import org.xbill.DNS.AAAARecord
import org.xbill.DNS.ARecord
import org.xbill.DNS.DClass
import org.xbill.DNS.Flags
import org.xbill.DNS.Message
import org.xbill.DNS.Name
import org.xbill.DNS.Opcode
import org.xbill.DNS.PTRRecord
import org.xbill.DNS.ReverseMap
import org.xbill.DNS.Section
import org.xbill.DNS.Type
import java.io.IOException
import java.net.Inet4Address
import java.net.Inet6Address
import java.net.InetAddress
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

Expand Down Expand Up @@ -80,8 +92,7 @@ sealed class DnsResolverCompat {
* See also: https://issuetracker.google.com/issues/133874590
*/
private val unboundedIO by lazy {
if (Core.activity.isLowRamDevice) Dispatchers.IO
else Executors.newCachedThreadPool().asCoroutineDispatcher()
if (Core.activity.isLowRamDevice) Dispatchers.IO else Dispatchers.IO.limitedParallelism(Int.MAX_VALUE)
}

override suspend fun resolve(network: Network, host: String) =
Expand Down

0 comments on commit f6430c7

Please sign in to comment.