mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Avoid 10 second delay on graceful termination with GFE 3.20.3.63
This commit is contained in:
parent
0cda408d3c
commit
2a02569c5c
@ -466,8 +466,6 @@ static void controlReceiveThreadFunc(void* context) {
|
||||
return;
|
||||
}
|
||||
|
||||
int terminationErrorCode = -1;
|
||||
|
||||
while (!PltIsThreadInterrupted(&controlReceiveThread)) {
|
||||
ENetEvent event;
|
||||
|
||||
@ -501,7 +499,7 @@ static void controlReceiveThreadFunc(void* context) {
|
||||
// assume the server died tragically, so go ahead and tear down.
|
||||
PltUnlockMutex(&enetMutex);
|
||||
Limelog("Disconnect event timeout expired\n");
|
||||
ListenerCallbacks.connectionTerminated(terminationErrorCode);
|
||||
ListenerCallbacks.connectionTerminated(-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -557,6 +555,7 @@ static void controlReceiveThreadFunc(void* context) {
|
||||
BbInitializeWrappedBuffer(&bb, (char*)event.packet->data, sizeof(*ctlHdr), event.packet->dataLength - sizeof(*ctlHdr), BYTE_ORDER_LITTLE);
|
||||
|
||||
unsigned short terminationReason;
|
||||
int terminationErrorCode;
|
||||
|
||||
BbGetShort(&bb, (short*)&terminationReason);
|
||||
|
||||
@ -572,15 +571,21 @@ static void controlReceiveThreadFunc(void* context) {
|
||||
terminationErrorCode = terminationReason;
|
||||
}
|
||||
|
||||
// We don't actually notify the connection listener until we receive
|
||||
// the disconnect event from the server that confirms the termination.
|
||||
// We used to wait for a ENET_EVENT_TYPE_DISCONNECT event, but since
|
||||
// GFE 3.20.3.63 we don't get one for 10 seconds after we first get
|
||||
// this termination message. The termination message should be reliable
|
||||
// enough to end the stream now, rather than waiting for an explicit
|
||||
// disconnect.
|
||||
ListenerCallbacks.connectionTerminated(terminationErrorCode);
|
||||
enet_packet_destroy(event.packet);
|
||||
return;
|
||||
}
|
||||
|
||||
enet_packet_destroy(event.packet);
|
||||
}
|
||||
else if (event.type == ENET_EVENT_TYPE_DISCONNECT) {
|
||||
Limelog("Control stream received disconnect event\n");
|
||||
ListenerCallbacks.connectionTerminated(terminationErrorCode);
|
||||
Limelog("Control stream received unexpected disconnect event\n");
|
||||
ListenerCallbacks.connectionTerminated(-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user