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

Ludvig Janiuk lujaniuk at openjdk.org
Tue May 21 08:41:16 UTC 2024


On Mon, 20 May 2024 13:55:17 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> src/share/classes/com/sun/javatest/regtest/agent/AgentServer.java line 248:
>> 
>>> 246:         final OutputStream os = s.getOutputStream();
>>> 247:         os.write(JTREG_AGENT_HANDSHAKE_MAGIC);
>>> 248:         os.flush();
>> 
>> Is this the point where the agent would break the connection if the magic bytes are wrong? I'm trying to more clearly see at which point the jtreg "server" knows that the jtreg agent has accepted the handshake.
>
>> Is this the point where the agent would break the connection if the magic bytes are wrong?
> 
> That happens in the `Agent` code in the newly introduced `acceptAndHandshake()` method  https://github.com/openjdk/jtreg/pull/195/files#diff-23190c9a688c97b3edf1b5605b78eefb8ebe4b5894737518072c6efb55705401R252. The `Agent` is the server side of the socket connection, listening for a connection, and the `AgentServer` is the client side of the socket connection sending a connection request. Yes, it's a bit confusing since the class is named `AgentServer`, but it does act as a server later on, serving test execution requests from the jtreg's `Agent`.

Right, that's confusing but thank you for explaining. 
When reading "handshake" I expected both sides to send each other some indication of having accepted the connection. Compare with e.g. the TCP three-way handshare https://en.wikipedia.org/wiki/Handshake_(computing)#TCP_three-way_handshake. This protocol seems to be a "one-way handshake" in that, the `AgentServer` acting as client connects and identifies itself with some magic bytes. The `Agent` acting as server can decline if the bytes don't match. The `AgentServer` however must simply assume that its magic bytes were accepted. Have I gotten that right? And if so, is the term "handshake" really appropriate or would a term such as "connection identification" or something else be more fitting?

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

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


More information about the jtreg-dev mailing list