[client] spice: add fail-fast connection option

This commit is contained in:
Geoffrey McRae
2026-08-16 22:29:20 +10:00
parent 209ac4d749
commit 056be1242a
9 changed files with 54 additions and 16 deletions

View File

@@ -325,10 +325,7 @@ int spiceSession_thread(void * opaque)
PSStatus status = PS_STATUS_SHUTDOWN;
if (!purespice_connect(&config))
{
DEBUG_ERROR("Failed to connect to SPICE server");
goto done;
}
transport->connected = true;
status = PS_STATUS_RUN;

View File

@@ -62,6 +62,13 @@ static void spiceSetup(void)
.type = OPTION_TYPE_INT,
.value.x_int = 5900
},
{
.module = "spice",
.name = "waitForServer",
.description = "Wait for the SPICE server to become available",
.type = OPTION_TYPE_BOOL,
.value.x_bool = true
},
{
.module = "spice",
.name = "input",
@@ -127,6 +134,7 @@ static bool spiceCreate(LG_Transport ** result)
transport->usbAudioEnabled =
option_get_bool("spice", "usbAudio");
transport->audioDebug = option_get_bool("audio", "debug");
transport->waitForServer = option_get_bool("spice", "waitForServer");
#if !ENABLE_USB_AUDIO
if (transport->audioEnabled && transport->usbAudioEnabled)
@@ -265,9 +273,12 @@ static LG_TransportStatus spiceConnectCancellable(LG_Transport * transport,
if (transport->connectStatus != LG_TRANSPORT_OK)
{
const LG_TransportStatus status = transport->connectStatus;
lgJoinThread(transport->thread, NULL);
transport->thread = NULL;
return transport->connectStatus;
if (status == LG_TRANSPORT_ERROR && transport->waitForServer)
return LG_TRANSPORT_UNAVAILABLE;
return status;
}
*session = transport->session;

View File

@@ -51,6 +51,7 @@ struct LG_Transport
bool playbackEnabled;
bool recordEnabled;
bool audioDebug;
bool waitForServer;
SpiceInput * input;
SpiceClipboard * clipboard;