session-matrix: learn() persists only when a new machine is learned
QA finding 2. AddToMachinePool returns inside the TryFindMachineByName branch (MachineStuff.cs:737), before the UpdateMachinePoolStringSetting() at :755 — which is reachable only from the fall-through "new machine" path. Switcher.learn was returning [.persistMachinePool] from the known branch too, asking the app to write MachinePool to disk on every heartbeat cadence tick from every already-known peer. It now returns []. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
0e6ee77dc7
commit
e0638de0b9
2 files changed
+15
-8
No files matched your search
@@ -241,10 +241,13 @@ public final class Switcher {
|
||||
/// Learns the sender of a `Heartbeat`, `Awake` or `Hello`
|
||||
/// (`AddToMachinePool`, `MachineStuff.cs:712-777`).
|
||||
///
|
||||
/// A known name just has its id and timestamp refreshed. A new name is
|
||||
/// learned, the matrix is rebuilt from the pool so control is bidirectional
|
||||
/// straight away (`:758-772`), and the caller is asked to persist, reconnect
|
||||
/// and replicate.
|
||||
/// A known name just has its id and timestamp refreshed — no actions at
|
||||
/// all: the known-machine branch `return`s at `MachineStuff.cs:737`, before
|
||||
/// the `UpdateMachinePoolStringSetting()` at `:755`, so Windows does not
|
||||
/// write the pool to disk on every heartbeat from a peer it already knows.
|
||||
/// A new name is learned, the matrix is rebuilt from the pool so control is
|
||||
/// bidirectional straight away (`:758-772`), and only then is the caller
|
||||
/// asked to persist, reconnect and replicate.
|
||||
public func learn(from packet: Packet, now: TimeInterval) -> [SwitchAction] {
|
||||
guard let name = packet.machineName, !name.isEmpty else { return [] }
|
||||
|
||||
@@ -254,7 +257,7 @@ public final class Switcher {
|
||||
newDesMachineID = packet.src // MachineStuff.cs:731-735
|
||||
setDesMachine(packet.src)
|
||||
}
|
||||
return [.persistMachinePool]
|
||||
return [] // MachineStuff.cs:737
|
||||
}
|
||||
|
||||
guard pool.learn(name, keeping: matrix) else { return [] } // "The 5th machine"
|
||||
|
||||
@@ -80,9 +80,13 @@ the Windows source again.
|
||||
(`MachineStuff.cs:712-777`) adds to the pool and, when the name is new,
|
||||
rebuilds the matrix from the pool slot-for-slot so control is
|
||||
bidirectional at once, then queues the four `Matrix` packets — reported
|
||||
as `SwitchAction`s, the app decides to persist and reconnect. This lives
|
||||
on `Switcher`, not on `Session`: the pool and matrix are app-wide and a
|
||||
session is per-connection.
|
||||
as `SwitchAction`s, the app decides to persist and reconnect. A peer that
|
||||
is **already** known produces **no actions**: Windows returns from that
|
||||
branch at `MachineStuff.cs:737`, before the
|
||||
`UpdateMachinePoolStringSetting()` at `:755`, so a heartbeat from a known
|
||||
machine refreshes the in-memory id and timestamp and writes nothing.
|
||||
This lives on `Switcher`, not on `Session`: the pool and matrix are
|
||||
app-wide and a session is per-connection.
|
||||
- **Geometry uses `CGRect`/`CGPoint` from Foundation** (no CoreGraphics
|
||||
import) in the Windows convention: top-left origin, y down, integer
|
||||
pixels. The `input-capture` lane converts from CoreGraphics display
|
||||
|
||||
Reference in new issue
Block a user