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