[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-xorg
Subject: Re: [PATCH] xf86-input-synaptics: fix creation of repeater fifo
From: Peter Hutterer <peter.hutterer () who-t ! net>
Date: 2008-09-29 1:24:24
Message-ID: 20080929011224.GB8388 () who-t ! net
[Download RAW message or body]
On Sun, Sep 28, 2008 at 03:11:46PM +0100, Magnus Kessler wrote:
> Testing status against EEXIST is wrong and we should check errno instead if
> we want to allow the use of an existing file. However, since we pass a file
> name that in principle could be any existing file (not just fifos) is there
> any guarantee that we can later actually use the fifo?
Thanks. There is no guarantee that we can use it, but at the same time the
use-case where the pipe already exists is common.
In the simple case of a server restart, the first mkfifo command succeeds but
the second fails with EEXIST. So the pipe is still there and should be used.
Admittedly, it might be a good idea to clean up after ourselves and delete the
fifo if we have created it in the first place. What about the (compile-tested)
code below?
Cheers,
Peter
diff --git a/src/synaptics.c b/src/synaptics.c
index 18168e0..e5cb7f0 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -512,6 +512,9 @@ static void set_repeater_fifo(LocalDevicePtr local)
if (status && (errno != EEXIST)) {
xf86Msg(X_ERROR, "%s can't create repeater fifo\n", local->name);
} else {
+ if (!status)
+ priv->fifo_path = strdup(repeater); /* for unlinking later */
+
/* open the repeater fifo */
optList = xf86NewOption("Device", repeater);
if ((priv->fifofd = xf86OpenSerial(optList)) == -1) {
@@ -608,6 +611,7 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
DBG(9, XisbTrace(priv->comm.buffer, 1));
priv->fifofd = -1;
+ priv->fifo_path = NULL;
set_repeater_fifo(local);
if (!QueryHardware(local)) {
@@ -655,6 +659,13 @@ static void SynapticsUnInit(InputDriverPtr drv,
InputInfoPtr local,
int flags)
{
+ SynapticsPrivate *priv = (SynapticsPrivate *) (local->private);
+
+ if (priv->fifo_path)
+ {
+ unlink(priv->fifo_path);
+ xfree(priv->fifo_path);
+ }
xfree(local->private);
local->private = NULL;
xf86DeleteInput(local, 0);
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index e5202d1..d93e279 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -96,6 +96,7 @@ typedef struct _SynapticsPrivateRec
struct CommData comm;
int fifofd; /* fd for fifo */
+ char *fifo_path; /* path to fifo for unlinking */
SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */
int hist_index; /* Last added entry in move_hist[] */
_______________________________________________
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic