Relay shows Baton Connected after the plugin has gone, and never accepts it again

Open
#255 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
networking

Research direction

Start with the receive loop in relay/src/state.rs around line 745 and read the Windows behavior described in #254. Decide how the relay can detect a disconnected plugin when Ok(0) is ambiguous, considering the heartbeat or blocking-reader options in the issue. Done means the relay shows :( No Baton Connection after disconnection and accepts a reconnect without manual IPC controls.

Written by the indexing model from the issue text.

Description

area:relay bug needs-triage rust

Describe the bug

Once the relay has accepted the plugin, it never notices the plugin going away. The window keeps showing :) Baton Connected!, and a plugin that reconnects is never served, so the only recovery is Disconnect IPC then Connect IPC, or restarting the relay.

The receive loop in ipc_connect treats Ok(0) as "no data yet" and keeps polling (relay/src/state.rs:745). On Windows, interprocess returns Ok(0) both for an empty pipe and for one whose other end has closed (see #254), so the loop cannot tell the two apart and never exits. The BrokenPipe arm below it is unreachable on Windows for the same reason. accept() is only called again after that loop exits, so nothing new is accepted.

In the lab this followed directly from #254: the plugin dropped the connection after its failed handshake, but the relay still showed Baton Connected, which made the problem look like it was further down the line.

To Reproduce

  1. On Windows, start the relay, then X-Plane, so the plugin connects.
  2. Untick PilotDataSync in Plugin Admin, or quit X-Plane.
  3. The relay still shows :) Baton Connected!.
  4. Re-tick the plugin. Nothing reaches the relay until Disconnect IPC / Connect IPC is pressed.

Expected behavior

The relay notices the plugin has gone, shows :( No Baton Connection, and goes back to accepting, so the plugin can reconnect without anyone touching the relay.

Additional context

Because a read cannot distinguish "empty" from "closed" on Windows, this needs a signal other than the read result. Options include a heartbeat line from baton with a timeout on the relay side, or a blocking reader thread, where Ok(0) really does mean closed. baton already writes SHUTDOWN on a clean stop, but that does not cover X-Plane crashing or the handshake failing.

Dominant language
Python
Stars
4
Forks
9
Avg merge
4d 17h
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from oss-slu/PilotDataSynchronization

All issues in oss-slu/PilotDataSynchronization

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.