Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO

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

 



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


--
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