fix historic bug whene socket closes

This commit is contained in:
fduncanh
2022-03-12 03:14:09 -05:00
parent 3401427e00
commit 5efcf019bd

View File

@@ -177,6 +177,7 @@ raop_rtp_mirror_thread(void *arg)
bool conn_reset = false;
uint64_t ntp_timestamp_nal = 0;
uint64_t ntp_timestamp_raw = 0;
bool conn_started = false;
#ifdef DUMP_H264
// C decrypted
@@ -269,10 +270,15 @@ raop_rtp_mirror_thread(void *arg)
}
if (payload == NULL && ret == 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror tcp socket is closed, got %d bytes of 128 byte header",readstart);
FD_CLR(stream_fd, &rfds);
stream_fd = -1;
continue;
if (conn_started) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror tcp socket is closed, connection ended");
break;
} else {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror tcp socket is closed, got %d bytes of 128 byte header",readstart);
FD_CLR(stream_fd, &rfds);
stream_fd = -1;
continue;
}
} else if (payload == NULL && ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) continue; // Timeouts can happen even if the connection is fine
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror error in header recv: %d %s", errno, strerror(errno));
@@ -280,6 +286,7 @@ raop_rtp_mirror_thread(void *arg)
break;
}
conn_started = true;
int payload_size = byteutils_get_int(packet, 0);
//unsigned short payload_type = byteutils_get_short(packet, 4) & 0xff;
//unsigned short payload_option = byteutils_get_short(packet, 6);