mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int terminationErrorCode = -1;
|
|
||||||
|
|
||||||
while (!PltIsThreadInterrupted(&controlReceiveThread)) {
|
while (!PltIsThreadInterrupted(&controlReceiveThread)) {
|
||||||
ENetEvent event;
|
ENetEvent event;
|
||||||
|
|
||||||
@ -501,7 +499,7 @@ static void controlReceiveThreadFunc(void* context) {
|
|||||||
// assume the server died tragically, so go ahead and tear down.
|
// assume the server died tragically, so go ahead and tear down.
|
||||||
PltUnlockMutex(&enetMutex);
|
PltUnlockMutex(&enetMutex);
|
||||||
Limelog("Disconnect event timeout expired\n");
|
Limelog("Disconnect event timeout expired\n");
|
||||||
ListenerCallbacks.connectionTerminated(terminationErrorCode);
|
ListenerCallbacks.connectionTerminated(-1);
|
||||||
return;
|
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);
|
BbInitializeWrappedBuffer(&bb, (char*)event.packet->data, sizeof(*ctlHdr), event.packet->dataLength - sizeof(*ctlHdr), BYTE_ORDER_LITTLE);
|
||||||
|
|
||||||
unsigned short terminationReason;
|
unsigned short terminationReason;
|
||||||
|
int terminationErrorCode;
|
||||||
|
|
||||||
BbGetShort(&bb, (short*)&terminationReason);
|
BbGetShort(&bb, (short*)&terminationReason);
|
||||||
|
|
||||||
@ -572,15 +571,21 @@ static void controlReceiveThreadFunc(void* context) {
|
|||||||
terminationErrorCode = terminationReason;
|
terminationErrorCode = terminationReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't actually notify the connection listener until we receive
|
// We used to wait for a ENET_EVENT_TYPE_DISCONNECT event, but since
|
||||||
// the disconnect event from the server that confirms the termination.
|
// 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);
|
enet_packet_destroy(event.packet);
|
||||||
}
|
}
|
||||||
else if (event.type == ENET_EVENT_TYPE_DISCONNECT) {
|
else if (event.type == ENET_EVENT_TYPE_DISCONNECT) {
|
||||||
Limelog("Control stream received disconnect event\n");
|
Limelog("Control stream received unexpected disconnect event\n");
|
||||||
ListenerCallbacks.connectionTerminated(terminationErrorCode);
|
ListenerCallbacks.connectionTerminated(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user