RFR(s): 8228580: DnsClient TCP socket timeout

Pavel Rappo pavel.rappo at oracle.com
Wed Sep 4 17:52:20 UTC 2019


> On 4 Sep 2019, at 18:38, Florian Weimer <fweimer at redhat.com> wrote:
> 
> <snip>
> 
> Maybe I'm mistaken, but I think this:
> 
> 692     Tcp(InetAddress server, int port, int timeout) throws IOException {
> 693         sock = new Socket(server, port);
> 694         sock.setTcpNoDelay(true);
> 695         out = new java.io.BufferedOutputStream(sock.getOutputStream());
> 696         in = new java.io.BufferedInputStream(sock.getInputStream());
> 697         timeoutLeft = timeout;
> 698     }
> 
> creates the TCP socket and connects it.  This is a potentially blocking
> operation as well.  

You are right, it definitely is a blocking operation. I missed it. I was focused on

    712         sock.setSoTimeout(timeoutLeft);

So I'd suggest we use explicit connect with timeout

    java.net.Socket#connect(java.net.SocketAddress, int)

Are you okay with that?



More information about the core-libs-dev mailing list