Skip to content

Commit

Permalink
Merge pull request #152 from Jigsaw-Code/bemasc-threads
Browse files Browse the repository at this point in the history
Fix thread limit
  • Loading branch information
bemasc authored Jan 17, 2019
2 parents 203e6fc + 95f8668 commit 735e9ef
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.util.concurrent.Executors;
import sockslib.server.BasicSocksProxyServer;
import sockslib.server.SocksHandler;

Expand All @@ -42,7 +43,12 @@ class SocksServer extends BasicSocksProxyServer {
private final Context context;

SocksServer(Context context, InetSocketAddress fakeDns, InetSocketAddress trueDns) {
super(OverrideSocksHandler.class);
// BasicSocksProxyServer uses a default thread pool of size 100, resulting in a limit of 100
// active sockets, including DNS queries. Once the limit is reached, subsequent new sockets
// are queued until an existing socket decides to close. To avoid imposing long delays on
// pending network requests, we replace the default thread pool with one that does not have a
// size limit.
super(OverrideSocksHandler.class, Executors.newCachedThreadPool());
this.fakeDns = fakeDns;
this.trueDns = trueDns;
this.context = context;
Expand Down

0 comments on commit 735e9ef

Please sign in to comment.