mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
refactor(ios): drive device tunnel via io.Closer seam
Replace the tunnelChild *exec.Cmd and spawnTunnel seam with a tunnel io.Closer and startTunnel seam backed by the in-process usbmux forwarder.
This commit is contained in:
1 parent
956b114cba
commit
033b17a102
2 files changed
+28
-24
No files matched your search
@@ -127,12 +127,12 @@ type Driver struct {
|
||||
|
||||
// Device-mode fields. On the physical-device path d.companion is the runner
|
||||
// dialed over a usbmux tunnel, hybrid is false, and runnerClient is nil.
|
||||
// coreDeviceID feeds devicectl; tunnelChild is the iproxy process forwarding
|
||||
// the host loopback port to the runner's device-side port.
|
||||
// coreDeviceID feeds devicectl; tunnel is the in-process usbmux forwarder
|
||||
// bridging the host loopback port to the runner's device-side port.
|
||||
deviceMode bool
|
||||
coreDeviceID string
|
||||
tunnelChild *exec.Cmd
|
||||
spawnTunnel func(ctx context.Context, hardwareUDID, localPort, devicePort string) (*exec.Cmd, error)
|
||||
tunnel io.Closer
|
||||
startTunnel func(ctx context.Context, hardwareUDID, localAddress, devicePort string) (io.Closer, error)
|
||||
pickDeviceAddress func() (string, error)
|
||||
|
||||
// processContext owns the companion child's lifetime: it is derived from
|
||||
@@ -995,19 +995,21 @@ func (d *Driver) Close() {
|
||||
d.runnerClient = nil
|
||||
}
|
||||
d.stopRunnerChild()
|
||||
d.stopTunnelChild()
|
||||
d.stopTunnel()
|
||||
if d.processCancel != nil {
|
||||
d.processCancel()
|
||||
}
|
||||
}
|
||||
|
||||
// stopTunnelChild terminates the iproxy usbmux tunnel on the device path.
|
||||
// SIGTERM lets it close its forwarded sockets before exit; a nil child (the
|
||||
// simulator path) is a no-op.
|
||||
func (d *Driver) stopTunnelChild() {
|
||||
child := d.tunnelChild
|
||||
d.tunnelChild = nil
|
||||
stopProcess(child)
|
||||
// stopTunnel closes the in-process usbmux forwarder on the device path. Closing
|
||||
// its listener ends the accept loop and lets the open bridges drain; a nil
|
||||
// tunnel (the simulator path) is a no-op.
|
||||
func (d *Driver) stopTunnel() {
|
||||
tunnel := d.tunnel
|
||||
d.tunnel = nil
|
||||
if tunnel != nil {
|
||||
_ = tunnel.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// stopChild terminates the companion child gracefully (SIGTERM, grace window,
|
||||
|
||||
Reference in new issue
Block a user