Don't check for errors from sendto() in the ping threads

This commit is contained in:
Cameron Gutman 2021-04-28 17:04:44 -05:00
parent 83b1b17f87
commit fe205d838d
2 changed files with 10 additions and 14 deletions

View File

@ -44,19 +44,17 @@ static void UdpPingThreadProc(void* context) {
// Ping in ASCII
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
LC_SOCKADDR saddr;
SOCK_RET err;
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
SET_PORT(&saddr, RTP_PORT);
// Send PING every 500 milliseconds
while (!PltIsThreadInterrupted(&udpPingThread)) {
err = sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
if (err != sizeof(pingData)) {
Limelog("Audio Ping: sendto() failed: %d\n", (int)LastSocketError());
ListenerCallbacks.connectionTerminated(LastSocketFail());
return;
}
// We do not check for errors here. Socket errors will be handled
// on the read-side in ReceiveThreadProc(). This avoids potential
// issues related to receiving ICMP port unreachable messages due
// to sending a packet prior to the host PC binding to that port.
sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
if (firstReceiveTime == 0 && isSocketReadable(rtpSocket)) {
// Remember the time when we got our first incoming audio packet.

View File

@ -49,18 +49,16 @@ void destroyVideoStream(void) {
static void UdpPingThreadProc(void* context) {
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
LC_SOCKADDR saddr;
SOCK_RET err;
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
SET_PORT(&saddr, RTP_PORT);
while (!PltIsThreadInterrupted(&udpPingThread)) {
err = sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
if (err != sizeof(pingData)) {
Limelog("Video Ping: send() failed: %d\n", (int)LastSocketError());
ListenerCallbacks.connectionTerminated(LastSocketFail());
return;
}
// We do not check for errors here. Socket errors will be handled
// on the read-side in ReceiveThreadProc(). This avoids potential
// issues related to receiving ICMP port unreachable messages due
// to sending a packet prior to the host PC binding to that port.
sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
PltSleepMsInterruptible(&udpPingThread, 500);
}