RFR: 7903730: Enhance the agentvm to be tolerant to unexpected connection on the port the Agent listens on for handshake with the AgentServer [v3]

Jaikiran Pai jpai at openjdk.org
Fri Jun 7 15:51:26 UTC 2024


On Fri, 7 Jun 2024 15:42:00 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

>> Hello Mark, I read this a couple of times but didn't fully understand this suggestion. Right now the `host` variable gets default set to loopback address:
>> 
>> 
>> // by default use loopback address. if "-host" is specified, this will
>> // then be overridden by that value
>> InetAddress host = InetAddress.getLoopbackAddress();
>> 
>> 
>> but as the code comment states, if the `AgentServer` program was launched with a `-host <val>` then the `host` variable here is updated/set to the new value that is provided to value. So when the code does indeed reach the point of calling this `Socket` constructor, the `host` variable would have the correct host.
>> Did I misunderstand your suggestion?
>
> your recent change to the Agent to use the loopback address only
> 
>  ServerSocket ss = new ServerSocket();
>             // Ensure SO_REUSEADDR is false. (It is only needed if we're
>             // using a fixed port.) The default setting for SO_REUSEADDR
>             // is platform-specific, and Solaris has it on by default.
>             ss.setReuseAddress(false);
>             InetAddress loopbackAddr = InetAddress.getLoopbackAddress();
>             final int backlog = MAX_ACCEPT_ATTEMPTS;
>             ss.bind(new InetSocketAddress(loopbackAddr, /*port:*/ 0), backlog);
>             final int port = ss.getLocalPort();
> 
> so the -host argument is now redundant, if it were passed as an argument then an AgentServer couldn't connect to its peer Agent

Thank you for explaining that. I now understand what you meant. So, the fact that the `Agent` no longer launches the `AgentServer` with a `-host` program argument makes the `-host` an unnecessary option to keep around. The use of loopback address was done in a separate PR recently, which is where this option was made unnecessary. I would prefer to discuss the possibility of either retaining or dropping that option, with Jon and others and address it separately if that's OK with you.

-------------

PR Review Comment: https://git.openjdk.org/jtreg/pull/195#discussion_r1631405501


More information about the jtreg-dev mailing list