mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 02:42:35 +00:00
Bluetooth: Sleep instead of dying on EOF
am: 0d63f8af7c
Change-Id: I8f86685ba2000817dcfbdf566449826b121936dd
This commit is contained in:
@@ -71,8 +71,10 @@ void H4Protocol::OnDataReady(int fd) {
|
|||||||
ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
|
ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
|
||||||
if (bytes_read != 1) {
|
if (bytes_read != 1) {
|
||||||
if (bytes_read == 0) {
|
if (bytes_read == 0) {
|
||||||
LOG_ALWAYS_FATAL("%s: Unexpected EOF reading the packet type!",
|
// This is only expected if the UART got closed when shutting down.
|
||||||
__func__);
|
ALOGE("%s: Unexpected EOF reading the packet type!", __func__);
|
||||||
|
sleep(5); // Expect to be shut down within 5 seconds.
|
||||||
|
return;
|
||||||
} else if (bytes_read < 0) {
|
} else if (bytes_read < 0) {
|
||||||
LOG_ALWAYS_FATAL("%s: Read packet type error: %s", __func__,
|
LOG_ALWAYS_FATAL("%s: Read packet type error: %s", __func__,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|||||||
@@ -56,9 +56,13 @@ void HciPacketizer::OnDataReady(int fd, HciPacketType packet_type) {
|
|||||||
ssize_t bytes_read = TEMP_FAILURE_RETRY(
|
ssize_t bytes_read = TEMP_FAILURE_RETRY(
|
||||||
read(fd, preamble_ + bytes_read_,
|
read(fd, preamble_ + bytes_read_,
|
||||||
preamble_size_for_type[packet_type] - bytes_read_));
|
preamble_size_for_type[packet_type] - bytes_read_));
|
||||||
if (bytes_read <= 0) {
|
if (bytes_read == 0) {
|
||||||
LOG_ALWAYS_FATAL_IF((bytes_read == 0),
|
// This is only expected if the UART got closed when shutting down.
|
||||||
"%s: Unexpected EOF reading the header!", __func__);
|
ALOGE("%s: Unexpected EOF reading the header!", __func__);
|
||||||
|
sleep(5); // Expect to be shut down within 5 seconds.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (bytes_read < 0) {
|
||||||
LOG_ALWAYS_FATAL("%s: Read header error: %s", __func__,
|
LOG_ALWAYS_FATAL("%s: Read header error: %s", __func__,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
@@ -80,10 +84,13 @@ void HciPacketizer::OnDataReady(int fd, HciPacketType packet_type) {
|
|||||||
fd,
|
fd,
|
||||||
packet_.data() + preamble_size_for_type[packet_type] + bytes_read_,
|
packet_.data() + preamble_size_for_type[packet_type] + bytes_read_,
|
||||||
bytes_remaining_));
|
bytes_remaining_));
|
||||||
if (bytes_read <= 0) {
|
if (bytes_read == 0) {
|
||||||
LOG_ALWAYS_FATAL_IF((bytes_read == 0),
|
// This is only expected if the UART got closed when shutting down.
|
||||||
"%s: Unexpected EOF reading the payload!",
|
ALOGE("%s: Unexpected EOF reading the payload!", __func__);
|
||||||
__func__);
|
sleep(5); // Expect to be shut down within 5 seconds.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (bytes_read < 0) {
|
||||||
LOG_ALWAYS_FATAL("%s: Read payload error: %s", __func__,
|
LOG_ALWAYS_FATAL("%s: Read payload error: %s", __func__,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user