Re: [PATCH] shared/hciemu: Fix not handling failed read correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Szymon,

> 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.
> ---
> src/shared/hciemu.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
> index 3892fea..c0b1eae 100644
> --- a/src/shared/hciemu.c
> +++ b/src/shared/hciemu.c
> @@ -179,8 +179,12 @@ static gboolean receive_btdev(GIOChannel *channel, GIOCondition condition,
> 	fd = g_io_channel_unix_get_fd(channel);
> 
> 	len = read(fd, buf, sizeof(buf));
> -	if (len < 1)
> +	if (len < 1) {
> +		if (len < 0 && (errno == EAGAIN || errno == EINTR))
> +			return TRUE;
> +
> 		return FALSE;
> +	}

	len = read(fd, buf, sizeof(buf));
	if (len < 0) {
		if (errno == EGAIN || errno == EINTR)
			return TRUE;

		return FALSE;
	}

	if (len < 1)
		return FALSE;

I prefer that we do not intermix error handling with minimum length check.

> 
> 	switch (buf[0]) {
> 	case BT_H4_CMD_PKT:

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux