eliminate excessive journal errors
When the USB gadget is shut down, the application needs to avoid writes
to it in order to avoid lots of errors in the kernel log. Close the file
handle and re-open it when timings are detected again. Also, prevent
logging the failed timings query more than once.
Change-Id: Ic126828fe26ef44ebb0a5cb65cc47b23bb84f7f3
Signed-off-by: Eddie James <eajames@linux.ibm.com>
diff --git a/ikvm_input.cpp b/ikvm_input.cpp
index 202b761..30deea6 100644
--- a/ikvm_input.cpp
+++ b/ikvm_input.cpp
@@ -156,6 +156,36 @@
rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
}
+void Input::restart()
+{
+ if (!keyboardPath.empty() && keyboardFd < 0)
+ {
+ keyboardFd = open(keyboardPath.c_str(), O_RDWR | O_CLOEXEC);
+ if (keyboardFd < 0)
+ {
+ log<level::ERR>("Failed to open input device",
+ entry("PATH=%s", keyboardPath.c_str()),
+ entry("ERROR=%s", strerror(errno)));
+ }
+
+ sendKeyboard = false;
+ }
+
+ if (!pointerPath.empty() && pointerFd < 0)
+ {
+ pointerFd = open(pointerPath.c_str(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
+ if (pointerFd < 0)
+ {
+ log<level::ERR>("Failed to open input device",
+ entry("PATH=%s", pointerPath.c_str()),
+ entry("ERROR=%s", strerror(errno)));
+ }
+
+ pointerError = false;
+ sendPointer = false;
+ }
+}
+
void Input::sendWakeupPacket()
{
uint8_t wakeupReport[KEY_REPORT_LENGTH] = {0};
@@ -209,6 +239,12 @@
{
log<level::ERR>("Failed to write keyboard report",
entry("ERROR=%s", strerror(errno)));
+
+ if (errno == ESHUTDOWN)
+ {
+ close(keyboardFd);
+ keyboardFd = -1;
+ }
}
sendKeyboard = false;
@@ -225,6 +261,16 @@
entry("ERROR=%s", strerror(errno)));
pointerError = true;
}
+
+ if (errno == ESHUTDOWN)
+ {
+ close(pointerFd);
+ pointerFd = -1;
+ }
+ }
+ else
+ {
+ pointerError = false;
}
sendPointer = false;