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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> > 
> > Signed-off-by: Lukáš Hrázký <lhrazky@xxxxxxxxxx>
> > ---
> >  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@xxxxxxxxxx>
> 

Still retaining the ack but maybe the commit message could be extended.
Is clear from the code that this patch is reusing code, what is maybe not
clear is that read_all also supports handling signals and partial reads.

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]