[Spice-devel] [PATCH spice-streaming-agent 1/9] Use read_all() to read headers of received messages

Frediano Ziglio fziglio at redhat.com
Fri May 4 14:18:52 UTC 2018


> 
> Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
> ---
>  src/spice-streaming-agent.cpp | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 8b3f833..5dd41a9 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -166,14 +166,11 @@ static void handle_stream_error(size_t len)
>  static void read_command_from_device(void)
>  {
>      StreamDevHeader hdr;
> -    int n;
>  
>      std::lock_guard<std::mutex> stream_guard(stream_mtx);
> -    n = read(streamfd, &hdr, sizeof(hdr));
> -    if (n != sizeof(hdr)) {
> -        throw std::runtime_error("read command from device FAILED -- read "
> + std::to_string(n) +
> -                                 " expected " +
> std::to_string(sizeof(hdr)));
> -    }
> +
> +    read_all(&hdr, sizeof(hdr));
> +
>      if (hdr.protocol_version != STREAM_DEVICE_PROTOCOL) {
>          throw std::runtime_error("BAD VERSION " +
>          std::to_string(hdr.protocol_version) +
>                                   " (expected is " +
>                                   std::to_string(STREAM_DEVICE_PROTOCOL) +
>                                   ")");

Acked-by: Frediano Ziglio <fziglio at redhat.com>

Frediano


More information about the Spice-devel mailing list