mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Fix server-side log spam caused by sending unused command 0x0201
This commit is contained in:
parent
ae00c09cb6
commit
b59007cdea
@ -26,6 +26,7 @@ static SOCKET ctlSock = INVALID_SOCKET;
|
|||||||
static ENetHost* client;
|
static ENetHost* client;
|
||||||
static ENetPeer* peer;
|
static ENetPeer* peer;
|
||||||
static PLT_MUTEX enetMutex;
|
static PLT_MUTEX enetMutex;
|
||||||
|
static int usePeriodicPing;
|
||||||
|
|
||||||
static PLT_THREAD lossStatsThread;
|
static PLT_THREAD lossStatsThread;
|
||||||
static PLT_THREAD invalidateRefFramesThread;
|
static PLT_THREAD invalidateRefFramesThread;
|
||||||
@ -167,6 +168,7 @@ static short* payloadLengths;
|
|||||||
static char**preconstructedPayloads;
|
static char**preconstructedPayloads;
|
||||||
|
|
||||||
#define LOSS_REPORT_INTERVAL_MS 50
|
#define LOSS_REPORT_INTERVAL_MS 50
|
||||||
|
#define PERIODIC_PING_INTERVAL_MS 250
|
||||||
|
|
||||||
// Initializes the control stream
|
// Initializes the control stream
|
||||||
int initializeControlStream(void) {
|
int initializeControlStream(void) {
|
||||||
@ -206,6 +208,9 @@ int initializeControlStream(void) {
|
|||||||
intervalStartTimeMs = 0;
|
intervalStartTimeMs = 0;
|
||||||
lastIntervalLossPercentage = 0;
|
lastIntervalLossPercentage = 0;
|
||||||
lastConnectionStatusUpdate = CONN_STATUS_OKAY;
|
lastConnectionStatusUpdate = CONN_STATUS_OKAY;
|
||||||
|
usePeriodicPing = (AppVersionQuad[0] > 7) ||
|
||||||
|
(AppVersionQuad[0] == 7 && AppVersionQuad[1] > 1) ||
|
||||||
|
(AppVersionQuad[0] == 7 && AppVersionQuad[1] == 1 && AppVersionQuad[2] >= 415);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -592,44 +597,66 @@ static void controlReceiveThreadFunc(void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void lossStatsThreadFunc(void* context) {
|
static void lossStatsThreadFunc(void* context) {
|
||||||
char*lossStatsPayload;
|
|
||||||
BYTE_BUFFER byteBuffer;
|
BYTE_BUFFER byteBuffer;
|
||||||
|
|
||||||
lossStatsPayload = malloc(payloadLengths[IDX_LOSS_STATS]);
|
if (usePeriodicPing) {
|
||||||
if (lossStatsPayload == NULL) {
|
char periodicPingPayload[8];
|
||||||
Limelog("Loss Stats: malloc() failed\n");
|
|
||||||
ListenerCallbacks.connectionTerminated(-1);
|
BbInitializeWrappedBuffer(&byteBuffer, periodicPingPayload, 0, sizeof(periodicPingPayload), BYTE_ORDER_LITTLE);
|
||||||
return;
|
BbPutShort(&byteBuffer, 4); // Length of payload
|
||||||
|
BbPutInt(&byteBuffer, 0); // Timestamp?
|
||||||
|
|
||||||
|
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
||||||
|
// Send the message (and don't expect a response)
|
||||||
|
if (!sendMessageAndForget(0x0200, sizeof(periodicPingPayload), periodicPingPayload)) {
|
||||||
|
Limelog("Loss Stats: Transaction failed: %d\n", (int)LastSocketError());
|
||||||
|
ListenerCallbacks.connectionTerminated(LastSocketFail());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait a bit
|
||||||
|
PltSleepMsInterruptible(&lossStatsThread, PERIODIC_PING_INTERVAL_MS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
char* lossStatsPayload;
|
||||||
|
|
||||||
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
lossStatsPayload = malloc(payloadLengths[IDX_LOSS_STATS]);
|
||||||
// Construct the payload
|
if (lossStatsPayload == NULL) {
|
||||||
BbInitializeWrappedBuffer(&byteBuffer, lossStatsPayload, 0, payloadLengths[IDX_LOSS_STATS], BYTE_ORDER_LITTLE);
|
Limelog("Loss Stats: malloc() failed\n");
|
||||||
BbPutInt(&byteBuffer, lossCountSinceLastReport);
|
ListenerCallbacks.connectionTerminated(-1);
|
||||||
BbPutInt(&byteBuffer, LOSS_REPORT_INTERVAL_MS);
|
|
||||||
BbPutInt(&byteBuffer, 1000);
|
|
||||||
BbPutLong(&byteBuffer, lastGoodFrame);
|
|
||||||
BbPutInt(&byteBuffer, 0);
|
|
||||||
BbPutInt(&byteBuffer, 0);
|
|
||||||
BbPutInt(&byteBuffer, 0x14);
|
|
||||||
|
|
||||||
// Send the message (and don't expect a response)
|
|
||||||
if (!sendMessageAndForget(packetTypes[IDX_LOSS_STATS],
|
|
||||||
payloadLengths[IDX_LOSS_STATS], lossStatsPayload)) {
|
|
||||||
free(lossStatsPayload);
|
|
||||||
Limelog("Loss Stats: Transaction failed: %d\n", (int)LastSocketError());
|
|
||||||
ListenerCallbacks.connectionTerminated(LastSocketFail());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the transient state
|
while (!PltIsThreadInterrupted(&lossStatsThread)) {
|
||||||
lossCountSinceLastReport = 0;
|
// Construct the payload
|
||||||
|
BbInitializeWrappedBuffer(&byteBuffer, lossStatsPayload, 0, payloadLengths[IDX_LOSS_STATS], BYTE_ORDER_LITTLE);
|
||||||
|
BbPutInt(&byteBuffer, lossCountSinceLastReport);
|
||||||
|
BbPutInt(&byteBuffer, LOSS_REPORT_INTERVAL_MS);
|
||||||
|
BbPutInt(&byteBuffer, 1000);
|
||||||
|
BbPutLong(&byteBuffer, lastGoodFrame);
|
||||||
|
BbPutInt(&byteBuffer, 0);
|
||||||
|
BbPutInt(&byteBuffer, 0);
|
||||||
|
BbPutInt(&byteBuffer, 0x14);
|
||||||
|
|
||||||
// Wait a bit
|
// Send the message (and don't expect a response)
|
||||||
PltSleepMsInterruptible(&lossStatsThread, LOSS_REPORT_INTERVAL_MS);
|
if (!sendMessageAndForget(packetTypes[IDX_LOSS_STATS],
|
||||||
|
payloadLengths[IDX_LOSS_STATS], lossStatsPayload)) {
|
||||||
|
free(lossStatsPayload);
|
||||||
|
Limelog("Loss Stats: Transaction failed: %d\n", (int)LastSocketError());
|
||||||
|
ListenerCallbacks.connectionTerminated(LastSocketFail());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the transient state
|
||||||
|
lossCountSinceLastReport = 0;
|
||||||
|
|
||||||
|
// Wait a bit
|
||||||
|
PltSleepMsInterruptible(&lossStatsThread, LOSS_REPORT_INTERVAL_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(lossStatsPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(lossStatsPayload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void requestIdrFrame(void) {
|
static void requestIdrFrame(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user