All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 5/5] handsfree-audio: Handle when .Connect() was already replied to
Date: Thu, 28 Mar 2013 09:41:01 -0500	[thread overview]
Message-ID: <5154567D.9040308@gmail.com> (raw)
In-Reply-To: <1364429582-12518-5-git-send-email-vinicius.gomes@openbossa.org>

[-- Attachment #1: Type: text/plain, Size: 2081 bytes --]

Hi Vinicius,

On 03/27/2013 07:13 PM, Vinicius Costa Gomes wrote:
> In some cases, it is possible that when sco_connect_cb() is called
> the .Connect() message (stored in card->msg) is not valid anymore.

Can you tell me what cases these are?

My thinking is that we will treat the connect callback specially.

If the driver calls the callback function, then it is assumed that no 
further action is necessary.  If the driver calls connect_sco(), then we 
assume that the callback function will never be called.

> ---
>   src/handsfree-audio.c | 24 ++++++++++++++++--------
>   1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
> index 3f24a2a..841cc3f 100644
> --- a/src/handsfree-audio.c
> +++ b/src/handsfree-audio.c
> @@ -242,16 +242,19 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond,
>   {
>   	struct ofono_handsfree_card *card = user_data;
>   	DBusMessage *reply;
> -	int sk;
> +	int sk, err;
>
>   	if (agent == NULL) {
>   		/* There's no agent, so there's no one to reply to */
> -		reply = NULL;
> +		if (card->msg)
> +			dbus_message_unref(card->msg);
> +
> +		card->msg = NULL;
>   		goto done;
>   	}
>
>   	if (cond&  (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
> -		reply = __ofono_error_failed(card->msg);
> +		err = -EIO;
>   		goto done;
>   	}
>
> @@ -261,14 +264,19 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond,
>
>   	close(sk);
>
> -	reply = dbus_message_new_method_return(card->msg);
> +	err = 0;
>
>   done:
> -	if (reply)
> -		g_dbus_send_message(ofono_dbus_get_connection(), reply);
> +	/* Or the msg was already replied to, or the agent exited */
> +	if (card->msg == NULL)
> +		return FALSE;
>
> -	dbus_message_unref(card->msg);
> -	card->msg = NULL;
> +	if (err<  0)
> +		reply = __ofono_error_failed(card->msg);
> +	else
> +		reply = dbus_message_new_method_return(card->msg);
> +
> +	__ofono_dbus_pending_reply(&card->msg, reply);
>
>   	return FALSE;
>   }

Regards,
-Denis

  reply	other threads:[~2013-03-28 14:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28  0:12 [PATCH 1/5] hfp_hf_bluez5: Add a card driver for HFP 1.6 Vinicius Costa Gomes
2013-03-28  0:12 ` [PATCH 2/5] include: Add ofono_handsfree_card_connect_sco() Vinicius Costa Gomes
2013-03-28 14:37   ` Denis Kenzior
2013-03-28  0:13 ` [PATCH 3/5] handsfree-audio: Add ofono_handsfree_card_connect_sco Vinicius Costa Gomes
2013-03-28 14:37   ` Denis Kenzior
2013-03-28  0:13 ` [PATCH 4/5] handsfree-audio: Add .Connect using the card driver Vinicius Costa Gomes
2013-03-28 14:38   ` Denis Kenzior
2013-03-28  0:13 ` [PATCH 5/5] handsfree-audio: Handle when .Connect() was already replied to Vinicius Costa Gomes
2013-03-28 14:41   ` Denis Kenzior [this message]
2013-04-02 21:11     ` Vinicius Costa Gomes
2013-03-28 14:37 ` [PATCH 1/5] hfp_hf_bluez5: Add a card driver for HFP 1.6 Denis Kenzior

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=5154567D.9040308@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.