Blame SOURCES/0001-Remove-the-device-s-fd-from-the-select-set-when-we-g.patch

1dc13b
From 84e81636b29cca6dc1a5423e76ac2ab2c636eb86 Mon Sep 17 00:00:00 2001
1dc13b
From: Peter Hutterer <peter.hutterer@who-t.net>
1dc13b
Date: Tue, 18 Jul 2017 08:41:37 +1000
1dc13b
Subject: [PATCH] Remove the device's fd from the select() set when we get
1dc13b
 ENODEV
1dc13b
1dc13b
If the device is unplugged, the fd triggers in select/poll/... but comes back
1dc13b
with ENODEV. This triggers a lot of error messages in the log until finally
1dc13b
the udev code catches up with us and the device is removed properly.
1dc13b
1dc13b
Catch that case by removing the fd from the select() set so we don't get
1dc13b
triggered to call read_input on it anymore.
1dc13b
1dc13b
https://sourceforge.net/p/linuxwacom/bugs/337/
1dc13b
1dc13b
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
1dc13b
Tested-by: crocket <crockabiscuit@gmail.com>
1dc13b
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
1dc13b
(cherry picked from commit 912611608b3ba892a7c26d1be81209f4e5b009d5)
1dc13b
---
1dc13b
 src/xf86Wacom.c | 12 +++++++++---
1dc13b
 src/xf86Wacom.h |  2 +-
1dc13b
 2 files changed, 10 insertions(+), 4 deletions(-)
1dc13b
1dc13b
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
1dc13b
index 90ce793..896a8c1 100644
1dc13b
--- a/src/xf86Wacom.c
1dc13b
+++ b/src/xf86Wacom.c
1dc13b
@@ -632,7 +632,8 @@ static void wcmDevReadInput(InputInfoPtr pInfo)
1dc13b
 		if (!wcmReady(pInfo)) break;
1dc13b
 
1dc13b
 		/* dispatch */
1dc13b
-		wcmReadPacket(pInfo);
1dc13b
+		if (!wcmReadPacket(pInfo))
1dc13b
+			break;
1dc13b
 	}
1dc13b
 
1dc13b
 #ifdef DEBUG
1dc13b
@@ -649,7 +650,7 @@ static void wcmDevReadInput(InputInfoPtr pInfo)
1dc13b
 #endif
1dc13b
 }
1dc13b
 
1dc13b
-void wcmReadPacket(InputInfoPtr pInfo)
1dc13b
+Bool wcmReadPacket(InputInfoPtr pInfo)
1dc13b
 {
1dc13b
 	WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
1dc13b
 	WacomCommonPtr common = priv->common;
1dc13b
@@ -672,7 +673,10 @@ void wcmReadPacket(InputInfoPtr pInfo)
1dc13b
 		if (errno != EAGAIN && errno != EINTR)
1dc13b
 			LogMessageVerbSigSafe(X_ERROR, 0,
1dc13b
 					      "%s: Error reading wacom device : %s\n", pInfo->name, strerror(errno));
1dc13b
-		return;
1dc13b
+		if (errno == ENODEV)
1dc13b
+			xf86RemoveEnabledDevice(pInfo);
1dc13b
+
1dc13b
+		return FALSE;
1dc13b
 	}
1dc13b
 
1dc13b
 	/* account for new data */
1dc13b
@@ -704,6 +708,8 @@ void wcmReadPacket(InputInfoPtr pInfo)
1dc13b
 	}
1dc13b
 
1dc13b
 	common->bufpos = len;
1dc13b
+
1dc13b
+	return TRUE;
1dc13b
 }
1dc13b
 
1dc13b
 int wcmDevChangeControl(InputInfoPtr pInfo, xDeviceCtl * control)
1dc13b
diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h
1dc13b
index afb4e9e..ccc2d56 100644
1dc13b
--- a/src/xf86Wacom.h
1dc13b
+++ b/src/xf86Wacom.h
1dc13b
@@ -120,7 +120,7 @@ char *wcmEventAutoDevProbe (InputInfoPtr pInfo);
1dc13b
 int wcmInitTablet(InputInfoPtr pInfo, const char* id, float version);
1dc13b
 
1dc13b
 /* standard packet handler */
1dc13b
-void wcmReadPacket(InputInfoPtr pInfo);
1dc13b
+Bool wcmReadPacket(InputInfoPtr pInfo);
1dc13b
 
1dc13b
 /* handles suppression, filtering, and dispatch. */
1dc13b
 void wcmEvent(WacomCommonPtr common, unsigned int channel, const WacomDeviceState* ds);
1dc13b
-- 
1dc13b
2.13.6
1dc13b