Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thread limit #152

Merged
merged 1 commit into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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