Wait for ENet socket readability rather than just sleeping 10 ms

This commit is contained in:
Cameron Gutman 2021-05-15 00:15:16 -05:00
parent 43eb36e17a
commit 97216e1704

View File

@ -683,12 +683,15 @@ static void controlReceiveThreadFunc(void* context) {
} }
} }
else { else {
// No events ready - sleep for a short time // No events ready - wait for readability.
// //
// NOTE: This sleep *directly* impacts the lowest possible retransmission // NOTE: This wait *directly* impacts the lowest possible retransmission
// time for packets after a loss event. If we're busy sleeping here, we can't // time for packets after a loss event. If we're busy sleeping here, we can't
// retransmit a dropped packet, so we keep the sleep time to a minimum. // retransmit a dropped packet, so we keep the sleep time to a minimum.
PltSleepMsInterruptible(&controlReceiveThread, 10); //
// TODO: Dynamically sleep until next RTO rather than waking every 10 ms
enet_uint32 condition = ENET_SOCKET_WAIT_RECEIVE;
enet_socket_wait(client->socket, &condition, 10);
continue; continue;
} }
} }