-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hidapi/linux: retry hid_send_feature_report() if the ioctl() fails with EPIPE (e.g. the device stalled) #579
base: master
Are you sure you want to change the base?
Conversation
…th EPIPE (e.g. the device stalled) Signed-off-by: Sam Lantinga <[email protected]>
Just wondering what is the device which has this issue. Thanks. Retry count of 50 seems to be quite high. |
I don't remember offhand, this fix is several years old, but it's 50 retries without any delay, so I believe this was a very fast loop. |
50 is definitely too much (that is a lot of flood on the driver/bus in some cases when And this workaround is too specific - why only And if we're to handle the return codes of In one of my projects I use: template <typename ...ARGS>
inline int xioctl(int fd, unsigned long int request, ARGS&&... args) {
int result = 0;
int fails = 5;
do {
result = ::ioctl(fd, request, std::forward<ARGS>(args)...);
if (result < 0) {
const auto err = errno;
if (err == EINTR // interruptions, like debugger attachments, etc.
|| err == EPIPE) {
if (fails-- > 0) {
continue;
}
}
}
break;
}
while(true);
return result;
}
} I suggest we adapt it (make a C macro instead of C++ template) for our case, and use in all report related functions. And 5 attempts should be enough, unless you have specific measurements where 50 is justified. |
5 was definitely not enough. I ran into this on the Steam Link hardware, which is fairly slow, and I think the actual number in that case was the low 20s and I doubled it for safety. My goal was to provide the lowest latency possible while still handling EPIPE conditions. This happens only rarely, so my assumption was that leaving the number high was fine. In any case, I just wanted to share in case this was helpful. If you go with a different approach, no worries. |
In that case maybe make the number of retries configurable. Make it small (5?) by default and give some means to configure it for projects like SDL.
The thing is that I encounter |
…eport-if-the-io.patch
Making a draft for now, until we have a better implementation. |
No description provided.