From cc91d165c566e1e296bcb50c4430b9b1c6a1129a Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 25 Sep 2014 12:33:53 +0200 Subject: [PATCH] emulator/hciemu: Fix not handling failed read correctly If read failed due to signal or blocking watch was removed resulting in closing /dev/vhci and emulated adapter being removed. This was affecting android-tester since premature removal of adapter is considered error on android daemon. --- emulator/hciemu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/emulator/hciemu.c b/emulator/hciemu.c index 50285e4f5..fcaeb7092 100644 --- a/emulator/hciemu.c +++ b/emulator/hciemu.c @@ -179,6 +179,13 @@ static gboolean receive_btdev(GIOChannel *channel, GIOCondition condition, fd = g_io_channel_unix_get_fd(channel); len = read(fd, buf, sizeof(buf)); + if (len < 0) { + if (errno == EAGAIN || errno == EINTR) + return TRUE; + + return FALSE; + } + if (len < 1) return FALSE; -- 2.11.0