Fix server-side log spam caused by sending unused command 0x0201

This commit is contained in:
Cameron Gutman 2020-08-09 11:46:49 -07:00
parent ae00c09cb6
commit b59007cdea

View File

@ -26,6 +26,7 @@ static SOCKET ctlSock = INVALID_SOCKET;
static ENetHost* client;
static ENetPeer* peer;
static PLT_MUTEX enetMutex;
static int usePeriodicPing;
static PLT_THREAD lossStatsThread;
static PLT_THREAD invalidateRefFramesThread;
@ -167,6 +168,7 @@ static short* payloadLengths;
static char**preconstructedPayloads;
#define LOSS_REPORT_INTERVAL_MS 50
#define PERIODIC_PING_INTERVAL_MS 250
// Initializes the control stream
int initializeControlStream(void) {
@ -206,6 +208,9 @@ int initializeControlStream(void) {
intervalStartTimeMs = 0;
lastIntervalLossPercentage = 0;
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;
}
@ -592,9 +597,30 @@ static void controlReceiveThreadFunc(void* context) {
}
static void lossStatsThreadFunc(void* context) {
char*lossStatsPayload;
BYTE_BUFFER byteBuffer;
if (usePeriodicPing) {
char periodicPingPayload[8];
BbInitializeWrappedBuffer(&byteBuffer, periodicPingPayload, 0, sizeof(periodicPingPayload), BYTE_ORDER_LITTLE);
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;
lossStatsPayload = malloc(payloadLengths[IDX_LOSS_STATS]);
if (lossStatsPayload == NULL) {
Limelog("Loss Stats: malloc() failed\n");
@ -631,6 +657,7 @@ static void lossStatsThreadFunc(void* context) {
free(lossStatsPayload);
}
}
static void requestIdrFrame(void) {
long long payload[3];