Fix keyboard and mouse input events dropping issue
Restarting of HID input devices causes input events dropping issue
which is critical for BMC KVM uses. For an example, user can't enter
to BIOS by doing keep pressing 'F2' or 'Del' key because of this issue.
To fix the issue, this commit removes the input device restarting
logic and refines error log journaling logic using errno checking.
Tested:
1. Open BMCweb -> Server control -> KVM.
2. Make a host reset and keep pressing 'F2' key.
3. Was able to enter to BIOS using the key press.
Change-Id: Iec1bfad1d9e5825858844cab658bbfa3e6bc24f6
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/ikvm_input.cpp b/ikvm_input.cpp
index d95e631..df12f27 100644
--- a/ikvm_input.cpp
+++ b/ikvm_input.cpp
@@ -23,9 +23,9 @@
using namespace sdbusplus::xyz::openbmc_project::Common::File::Error;
Input::Input(const std::string& kbdPath, const std::string& ptrPath) :
- pointerError(false), sendKeyboard(false), sendPointer(false),
- keyboardFd(-1), pointerFd(-1), keyboardReport{0}, pointerReport{0},
- keyboardPath(kbdPath), pointerPath(ptrPath)
+ sendKeyboard(false), sendPointer(false), keyboardFd(-1), pointerFd(-1),
+ keyboardReport{0}, pointerReport{0}, keyboardPath(kbdPath),
+ pointerPath(ptrPath)
{
if (!keyboardPath.empty())
{
@@ -156,36 +156,6 @@
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};
@@ -459,13 +429,10 @@
{
if (write(keyboardFd, report, KEY_REPORT_LENGTH) != KEY_REPORT_LENGTH)
{
- log<level::ERR>("Failed to write keyboard report",
- entry("ERROR=%s", strerror(errno)));
-
- if (errno == ESHUTDOWN)
+ if (errno != ESHUTDOWN && errno != EAGAIN)
{
- close(keyboardFd);
- keyboardFd = -1;
+ log<level::ERR>("Failed to write keyboard report",
+ entry("ERROR=%s", strerror(errno)));
}
return false;
@@ -478,22 +445,11 @@
{
if (write(pointerFd, report, PTR_REPORT_LENGTH) != PTR_REPORT_LENGTH)
{
- if (!pointerError)
+ if (errno != ESHUTDOWN && errno != EAGAIN)
{
log<level::ERR>("Failed to write pointer report",
entry("ERROR=%s", strerror(errno)));
- pointerError = true;
}
-
- if (errno == ESHUTDOWN)
- {
- close(pointerFd);
- pointerFd = -1;
- }
- }
- else
- {
- pointerError = false;
}
}