public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3] android/hal-health: Clear NONBLOCK flag from fd
Date: Thu, 03 Jul 2014 13:38:49 +0200	[thread overview]
Message-ID: <2947534.RfCRlR0Nul@uw000953> (raw)
In-Reply-To: <1404386233-27863-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Thursday 03 of July 2014 14:17:13 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Java expects file descriptor passed with channel_state_cb() to be
> blocking.
> ---
>  android/hal-health.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/android/hal-health.c b/android/hal-health.c
> index 20ba459..1ed9fb1 100644
> --- a/android/hal-health.c
> +++ b/android/hal-health.c
> @@ -19,6 +19,9 @@
>  #include <stddef.h>
>  #include <string.h>
>  #include <stdlib.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +#include <errno.h>
>  
>  #include "hal-log.h"
>  #include "hal.h"
> @@ -44,6 +47,19 @@ static void handle_app_registration_state(void *buf, uint16_t len, int fd)
>  static void handle_channel_state(void *buf, uint16_t len, int fd)
>  {
>  	struct hal_ev_health_channel_state *ev = buf;
> +	int flags;
> +
> +	flags = fcntl(fd, F_GETFL, 0);
> +	if (flags < 0) {
> +		error("health: fcntl GETFL error: %s", strerror(errno));
> +		return;
> +	}
> +
> +	/* Clean O_NONBLOCK fd flag as Android Java layer expects */
> +	if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) < 0) {
> +		error("health: fcntl SETFL error: %s", strerror(errno));
> +		return;
> +	}
>  
>  	if (cbacks->channel_state_cb)
>  		cbacks->channel_state_cb(ev->app_id, (bt_bdaddr_t *) ev->bdaddr,
> 

Patch applied, thanks.

-- 
Best regards, 
Szymon Janc

      reply	other threads:[~2014-07-03 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-03 11:17 [PATCHv3] android/hal-health: Clear NONBLOCK flag from fd Andrei Emeltchenko
2014-07-03 11:38 ` Szymon Janc [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2947534.RfCRlR0Nul@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=Andrei.Emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox