Skip to content

Commit ab6225c

Browse files
committed
Add some extra diagnostics to investigate a read of zero bytes.
1 parent 50d5199 commit ab6225c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

rtsp.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,19 +1179,29 @@ ssize_t timed_read_from_rtsp_connection(rtsp_conn_info *conn, uint64_t wait_time
11791179
read_encrypted(conn->fd, &conn->ap2_pairing_context.control_cipher_bundle, buf, count);
11801180
} else {
11811181
result = read(conn->fd, buf, count);
1182-
if (result == 0)
1183-
debug(1, "AP2 read result 0, for a request count of %u.", count);
1182+
if (result == 0) {
1183+
debug(1, "AP2 read result 0, for a request count of %u.", count);
1184+
}
11841185
}
11851186
#else
11861187
result = read(conn->fd, buf, count);
1187-
if (result == 0)
1188+
if (result == 0) {
11881189
debug(1, "AP1 read result 0, for a request count of %u.", count);
1190+
1191+
}
11891192
#endif
1193+
if ((result == 0) && (errno != 0)) {
1194+
char errorstring[1024];
1195+
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
1196+
debug(1, "Connection %d: read result 0, error %d: \"%s\".",
1197+
conn->connection_number, errno, (char *)errorstring);
1198+
}
1199+
11901200
if (wait_time != 0)
11911201
remaining_time = time_to_wait_to - get_absolute_time_in_ns();
1192-
if (((result == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) && (remaining_time > 0))
1202+
if ((((result == -1) || (result == 0)) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) && (remaining_time > 0))
11931203
debug(1, "remaining time on a timed read is %" PRId64 " ns.", remaining_time);
1194-
} while (((result == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) &&
1204+
} while ((((result == -1) || (result == 0)) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) &&
11951205
(remaining_time > 0));
11961206

11971207
} else {

0 commit comments

Comments
 (0)