Mailing List archive

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

[linux-dvb] Re: Poll problem with multiple PIDs



On Mon, Jun 17, 2002 at 11:18:53PM +0200, Klaus Schmidinger wrote:
> --- dmxdev.c    Mon Apr  1 10:59:46 2002
> +++ dmxdev.c    Sun Jun 16 11:02:38 2002
> @@ -1048,6 +1048,9 @@
>                 if (dmxdev->dvr_buffer.pread!=dmxdev->dvr_buffer.pwrite)
>                         return (POLLIN | POLLRDNORM | POLLPRI);
> 
> +                if (dmxdev->dvr_buffer.error)
> +                       return (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
> +
>                 return 0;
>         } else
>                 return (POLLOUT | POLLWRNORM | POLLPRI);
> 
> Apparently it also has been adopted in the CVS driver today.

While this code looks right, your error handling in x2.c is incomplete,
since you don't check the result code / errno of read().

The result from the poll() system call (including errno) will
*not* tell you whether the driver has signaled POLLERR.
You could check pollfd.revents for that, but irgnoring POLLERR
and just processing POLLIN is also OK, because
the next call to read() (or write() for POLLOUT) will then
return -1 and set errno.

When poll() signals a file descrptor as readable (or writable),
the next call to read() (or write()) is guaranteed to be
non-blocking, regardless of O_NONBLOCK.

O_NONBLOCK is also irrelevant for the poll() call itself.

Also, in general it is *not* an error if a read() returns less
data than requested. Possibly the driver API guarantees that
data from the DVR device will always come in full TS packets,
but then it's a feature of the driver API, not of the read()
system call.

See also:
http://www.opengroup.org/onlinepubs/007908799/xsh/poll.html
http://www.xml.com/ldd/chapter/book/ch05.html#t3


Regards,
Johannes



-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index