[PATCH weston v5 03/14] libweston: add weston_debug API and implementation

Pekka Paalanen ppaalanen at gmail.com
Tue Aug 28 14:30:14 UTC 2018


On Mon, 27 Aug 2018 16:15:23 +0100
Daniel Stone <daniel at fooishbar.org> wrote:

> Hi Pekka,
> 
> On Mon, 6 Aug 2018 at 14:05, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> > On Fri, 20 Jul 2018 20:03:24 +0100 Daniel Stone <daniels at collabora.com> wrote:  
> > > +     while (len_ > 0) {
> > > +             ret = write(stream->fd, data, len_);
> > > +             e = errno;
> > > +             if (ret < 0) {
> > > +                     if (e == EINTR)
> > > +                             continue;
> > > +
> > > +                     stream_close_on_failure(stream,
> > > +                                     "Error writing %zd bytes: %s (%d)",
> > > +                                     len_, strerror(e), e);
> > > +                     break;
> > > +             }
> > > +
> > > +             len_ -= ret;
> > > +             data += ret;  
> >
> > If write() starts returning zero, we might be in for a very long loop.  
> 
> I don't think there's much we can do about that to be honest. I guess
> we could post an error to the owning client and disconnect it? Else
> we're just throwing away data, potentially corrupting the debug
> stream, which seems suboptimal.
> 
> Currently we just block, and document that your debug client _must_
> keep up with the incoming stream.

Hi Daniel,

yes, so if write() returns zero, something is really wrong, since the
blocking behaviour is supposed to prevent that, right?

I think disconnecting the client is better than spinning forever or
losing bits of data, but is there a case where we should spin at least
a little? Implementing a timeout seems overkill and bad for other
reasons, so if occasional zero returns are normal, then the code is ok
as is.

There is also 'failure' event we could use if disconnecting is too much.

I'm also ok with not caring about this issue until someone hits it.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180828/b924c610/attachment.sig>


More information about the wayland-devel mailing list