This series changes the mode for the stream virtio port to nonblocking,
adds a unit test for lowlevel IO on it and introduces some refactoring.
For the refactoring part, it starts with moving read_all() and
write_all() to a separate file and starting the trend of moving things
out of the main file. There is still a lot of unfinished work to do
though.

The main reason for the nonblocking mode is if the server iadvertedly
closes the port, streaming agent would block on a write() indefinitely.

Note I did not manage to reach my final goal in this series, which was,
in case of a notify_error message from the server and closing the port,
to report the error on the streaming agent side. With this series, the
agent will not block, but will error out with "port closed error"
instead of "received notify error XY from the server" one. Hence the
last couple of patches of refactor in preparation, after which I found
out I'd need much more and decided to send this and not grow it larger.

Note also the series includes exceptions hierarchy based on c3d's
earlier patches, but with a simple and ugly std::string based
formatting. I hope it won't cause too much controversy :)

As a last point, I think there is still a theoretical race possibility
with the poll()s with timeout -1. If the agent receives a SIGTERM right
before the poll(), the poll() will block and until something happens on
the port and until then the agent will not quit.

Lukáš Hrázký (9):
  Use read_all() to read headers of received messages
  Move out {read,write}_all() to a separate module
  Implement an exception hierarchy for ReadError
  Introduce a WriteError exception for write_all()
  Unify the structure of write_all() and read_all()
  Add a unit test for the stream port
  Change the mode to NONBLOCK for the virtio port
  Encapsulate the stream port fd and locking
  Refactor and simplify polling for messages to read

 src/Makefile.am                    |   4 +
 src/error.cpp                      |  36 +++++++
 src/error.hpp                      |  61 +++++++++++
 src/spice-streaming-agent.cpp      | 211 +++++++++++--------------------------
 src/stream-port.cpp                | 120 +++++++++++++++++++++
 src/stream-port.hpp                |  35 ++++++
 src/unittests/.gitignore           |   1 +
 src/unittests/Makefile.am          |   9 +-
 src/unittests/test-stream-port.cpp |  81 ++++++++++++++
 9 files changed, 407 insertions(+), 151 deletions(-)
 create mode 100644 src/error.cpp
 create mode 100644 src/error.hpp
 create mode 100644 src/stream-port.cpp
 create mode 100644 src/stream-port.hpp
 create mode 100644 src/unittests/test-stream-port.cpp

-- 
2.16.2

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to