Skip to content

Commit

Permalink
linux: make hid_write() be truly blocking
Browse files Browse the repository at this point in the history
If write() fails due to timeout, loop around and try again.  This
makes the linux/hid_write() exhibit the same blocking behavior as the
other hid_write() implementations.
  • Loading branch information
jsquyres committed Nov 12, 2014
1 parent 8102346 commit 53d85c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,15 @@ int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t
{
int bytes_written;

bytes_written = write(dev->device_handle, data, length);
while (1) {
bytes_written = write(dev->device_handle, data, length);
if (bytes_written < 0 &&
(errno == ETIMEDOUT || errno == EINTR)) {
continue;
}

return bytes_written;
return bytes_written;
}
}


Expand Down

0 comments on commit 53d85c5

Please sign in to comment.