Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Joao Paulo Rechi Vita <jprvita@openbossa.org>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
Date: Sat, 22 Dec 2012 11:56:00 -0800	[thread overview]
Message-ID: <1356206160.29264.17.camel@aeonflux> (raw)
In-Reply-To: <CAAngNMbS0oDkxe0TQEu2mrxrf7dyViYcHZFeKgtREDd1jtp-yA@mail.gmail.com>

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.
> >
> 
> What's the problem with remove()? From the manpage it's part of
> stdio.h and calls unlink() for files, and rmdir() for directories.
> From my understanding if someone else created a directory on the FIFO
> path, unlink() will return with EISDIR and we would need to handle
> this error as well.

if it accidentally has been a directory with that name, then I want to
see a big fat error. Not some magic to make it work.

Regards

Marcel



  parent reply	other threads:[~2012-12-22 19:56 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
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 [this message]
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=1356206160.29264.17.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