Skip to content

Fix PingPortListener reply on Python 3 (thread exits on first connection) - #4267

Open
DicksonWu654 wants to merge 1 commit into
apache:trunkfrom
DicksonWu654:fix-ping-port-listener-py3
Open

DicksonWu654 wants to merge 1 commit into
apache:trunkfrom
DicksonWu654:fix-ping-port-listener-py3

Conversation

@DicksonWu654

Copy link
Copy Markdown

What changes were proposed in this pull request?

PingPortListener.run calls conn.send("OK"). On Python 3 socket.send needs bytes, so it raises TypeError. The except branch logs "a bytes-like object is required, not 'str'" and calls sys.exit(1), which ends the listener thread. So the first connection to the ping port gets an empty reply, the thread exits, and every later connection hangs until it times out. The agent process itself keeps running.

This changes the reply to b"OK".

How was this patch tested?

I ran the real PingPortListener class from trunk (445e0bc) under Python 3.12 on 127.0.0.1, with ping_port=0 and the fuser check stubbed out, and opened three connections:

  • before: the first gets b'' and the thread is dead; the next two time out
  • after: all three get b"OK" and the thread stays alive

I haven't run the full agent test suite. I didn't open a JIRA for this - happy to if you'd like one for the title.

conn.send("OK") raises TypeError on Python 3, the handler logs it and
calls sys.exit(1), so the ping listener thread ends on its first
connection and the port stops answering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant