Skip to content

Commit

Permalink
fruity: Expect networked device to respond quickly
Browse files Browse the repository at this point in the history
When connecting to its pairing service, it should be reasonable to
assume that the TCP connection set up completes within two seconds.

This improves the UX when a device has gone to sleep, and its mDNS
records haven't yet timed out.
  • Loading branch information
oleavr committed Nov 13, 2024
1 parent e0524ad commit 848f4b5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/fruity/device-monitor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,8 @@ namespace Frida.Fruity {
private TunnelConnection? tunnel_connection;
private DiscoveryService? _discovery_service;

private const uint PAIRING_CONNECTION_TIMEOUT = 2000;

public PortableNetworkTunnel (InetSocketAddress endpoint, InetSocketAddress interface_address, PairingStore store) {
Object (
endpoint: endpoint,
Expand All @@ -1819,7 +1821,8 @@ namespace Frida.Fruity {
public async void open (Cancellable? cancellable) throws Error, IOError {
var netstack = new SystemNetworkStack (interface_address.get_address (), interface_address.scope_id);

var pairing_connection = yield netstack.open_tcp_connection (endpoint, cancellable);
var pairing_connection = yield netstack.open_tcp_connection_with_timeout (endpoint, PAIRING_CONNECTION_TIMEOUT,
cancellable);
var pairing_transport = new PlainPairingTransport (pairing_connection);
var pairing_service = yield PairingService.open (pairing_transport, pairing_store, cancellable);

Expand Down

0 comments on commit 848f4b5

Please sign in to comment.