Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: "João Paulo Rechi Vita" <jprvita@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
Date: Sat, 22 Dec 2012 08:36:11 -0800	[thread overview]
Message-ID: <1356194171.29264.14.camel@aeonflux> (raw)
In-Reply-To: <1356189162-11584-4-git-send-email-jprvita@openbossa.org>

Hi Joao Paulo,

> If bluetoothd crashes the exit routine of the suspend plugin will not be
> executed, leaving the suspend FIFO behind and preventing the plugin load
> on subsequent executions. This commit checks for pre-existence of the
> suspend FIFO and tries to remove and re-create it.
> ---
>  profiles/input/suspend-dummy.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
> index 33b790a..43384c0 100644
> --- a/profiles/input/suspend-dummy.c
> +++ b/profiles/input/suspend-dummy.c
> @@ -119,6 +119,22 @@ int suspend_init(suspend_event suspend, resume_event resume)
>  
>  	if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
>  		int err = -errno;
> +
> +		if (err == -EEXIST) {
> +			DBG("FIFO (%s) already exists, trying to remove",
> +							HOG_SUSPEND_FIFO);
> +
> +			/* remove pre-existing FIFO and retry */
> +			if (remove(HOG_SUSPEND_FIFO) < 0) {

you are looking for unlink() to use here.

> +				err = -errno;
> +				error("Failed to remove FIFO (%s): %s (%d)",
> +					HOG_SUSPEND_FIFO, strerror(-err), -err);
> +				return err;
> +			}
> +
> +			return suspend_init(suspend, resume);
> +		}
> +
>  		error("Can't create FIFO (%s): %s (%d)", HOG_SUSPEND_FIFO,
>  							strerror(-err), -err);
>  		return err;

Regards

Marcel



  reply	other threads:[~2012-12-22 16:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-22 15:12 [PATCH BlueZ 1/4] hog: Fix message text and level when failing to load suspend plugin João Paulo Rechi Vita
2012-12-22 15:12 ` [PATCH BlueZ 2/4] hog: Add debug info when initializing the " João Paulo Rechi Vita
2012-12-22 15:12 ` [PATCH BlueZ 3/4] hog: Fix error message formating João Paulo Rechi Vita
2012-12-22 15:12 ` [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO João Paulo Rechi Vita
2012-12-22 16:36   ` Marcel Holtmann [this message]
2012-12-22 16:51     ` Johan Hedberg
2012-12-22 18:39     ` Joao Paulo Rechi Vita
2012-12-22 18:41       ` Joao Paulo Rechi Vita
2012-12-22 19:56       ` Marcel Holtmann
2012-12-22 16:35 ` [PATCH BlueZ 1/4] hog: Fix message text and level when failing to load suspend plugin Johan Hedberg

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=1356194171.29264.14.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=jprvita@openbossa.org \
    --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