[Spice-devel] usbredirparser: fix EAGAIN error in *_do_write()
Dmitriy Samborskiy
samborsky_d at yahoo.com
Fri Oct 14 14:57:41 UTC 2016
Hello,
I'd like to propose a bugfix for usbredirparser.c usbredirparser_do_write()
procedure, see below.
Issue description:
usbredirparser_do_write() does not handle EAGAIN properly.
In case of large write parser->callb.write_func() returns 0 with errno=EAGAIN.
Then usbredirparser_do_write() code returns an error and, consequently,
usbredirserver disconnects the client.This commit introduces some delay (100ms)
and then retries the write.
How to reproduce:
Trigger some I/O which causes massive read from the USB device.
For example, this error was initially observed when Windows 7 invoke
filesystem check on a 8Gb FAT USB flashdrive. There was a call to
usbredirparser_do_write() that tried to write ~70Kb of data which
caused the return value=0 and errno=EAGAIN from write(2).
Apparently, socket write buffer was full.
Observed behavior:
usbredirparser_do_write() returned error and consequently TCP connection
to the client was closed by usbredirserver.
Expected behavior:
usbredirserver should wait for the data to be written, TCP connection
with the client should not be closed.
Suggested patch:
See attached *.patch file.
Best regards,
Dmitriy Samborskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-parser-write.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161014/6718fc9d/attachment-0001.bin>
More information about the Spice-devel
mailing list