media: check status of dmxdev->exit in poll functions of demux&dvr
Quoted 22 lines
Actually,
poll()may return an error as well (frompoll()manpage):"RETURN VALUE
On success, a positive number is returned; this is the number of struc‐ tures which have nonzero revents fields (in other words, those descrip‐ tors with events or errors reported). A value of 0 indicates that the
call timed out and no file descriptors were ready. On error, -1 is
returned, and errno is set appropriately."So, if the Kernel returns
-ENODEV, the glibcpoll()wrapper would return -1 and errno will be ENODEV. Never actually tested if this works onpoll()though.Actually,
poll()may return an error as well (frompoll()manpage):"RETURN VALUE
On success, a positive number is returned; this is the number of struc‐ tures which have nonzero revents fields (in other words, those descrip‐ tors with events or errors reported). A value of 0 indicates that the
call timed out and no file descriptors were ready. On error, -1 is
returned, and errno is set appropriately."
Quoted 3 lines
So, if the Kernel returns
-ENODEV, the glibcpoll()wrapper would return -1 and errno will be ENODEV. Never actually tested if this works onpoll()though.
maybe the poll() manpage is wrong.
The standard system call poll() can not get -ENODEV from errno.
My experiment has proved that I was right(return -ENODEV directly in dvb_dvr_poll).
and you can also check code of do_poll() and do_sys_poll() in select.c file, it also shows that -ENODEV is invalid.
please also check that.
thanks!
Xiong changbing
------- Original Message -------
Sender : Mauro Carvalho Chehab<[email protected]> Director/SRBR-Open Source/삼성전자 Date : 九月 02, 2014 15:00 (GMT+09:00)
Title : Re: [PATCH 3/3] media: check status of dmxdev->exit in poll functions of demux&dvr
Em Tue, 02 Sep 2014 03:16:00 +0000 (GMT)
Changbing Xiong escreveu:
Quoted 11 lines
Quoted 10 lines
Well, we may start returning
-ENODEVwhen such event happens.At the frontend, we could use
fe->exit=DVB_FE_DEVICE_REMOVEDto signalize it. I don't think that the demod frontend has something similar.Yet, it should be up to the userspace application to properly handle the error codes and close the devices on fatal non-recovery errors like ENODEV.
Quoted 5 lines
Quoted 3 lines
So, what we can do, at Kernel level, is to always return
-ENODEVwhen the device is known to be removed, and double check libdvbv5 if it handles such error properly.well, we do not use libdvbv5,
The upstream stuff I maintain, related to it, are the media subsystems and libdvbv5. Of course, other apps will need to be patched as well.
Quoted 2 lines
and
-ENODEVcan be returned by read syscall,
but for poll syscall,
Actually, poll() may return an error as well (from poll() manpage):
"RETURN VALUE
On success, a positive number is returned; this is the number of struc‐ tures which have nonzero revents fields (in other words, those descrip‐ tors with events or errors reported). A value of 0 indicates that the
call timed out and no file descriptors were ready. On error, -1 is
returned, and errno is set appropriately."
So, if the Kernel returns -ENODEV, the glibc poll() wrapper would return -1 and errno will be ENODEV. Never actually tested if this works on poll() though.
Quoted 7 lines
-ENODEVcan never be returned to user, as negative number
is invalid type for poll returned value. please refer to my second patch.and in our usage, whether to read the device is up to the poll result. if tuner is plugged out, and there is no data in dvr ringbuffer. then user code will still go on polling the dvr device and never stop. if POLLERR is returned, then user will perform read dvr, and then
-ENODEVcan be got, and user will stop polling dvr device.
Your app should be also be handling poll() errors, as there are already other errors that poll() can return.
Quoted 3 lines
the first patch is enough to fix the deadlock issue.
the second patch is used to correct the wrong type of returned value. the third patch is used to provide user a better controlling logic.
I'll take a deeper look and do some tests on your patches likely tomorrow.
Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Em Tue, 02 Sep 2014 06:42:42 +0000 (GMT)
Changbing Xiong <[email protected]> escreveu:
Quoted 22 lines
Quoted 21 lines
Actually,
poll()may return an error as well (frompoll()manpage):"RETURN VALUE
On success, a positive number is returned; this is the number of struc‐ tures which have nonzero revents fields (in other words, those descrip‐ tors with events or errors reported). A value of 0 indicates that the
call timed out and no file descriptors were ready. On error, -1 is
returned, and errno is set appropriately."So, if the Kernel returns
-ENODEV, the glibcpoll()wrapper would return -1 and errno will be ENODEV. Never actually tested if this works onpoll()though.Actually,
poll()may return an error as well (frompoll()manpage):"RETURN VALUE
On success, a positive number is returned; this is the number of struc‐ tures which have nonzero revents fields (in other words, those descrip‐ tors with events or errors reported). A value of 0 indicates that the
call timed out and no file descriptors were ready. On error, -1 is
returned, and errno is set appropriately."
Quoted 6 lines
Quoted 3 lines
So, if the Kernel returns
-ENODEV, the glibcpoll()wrapper would return -1 and errno will be ENODEV. Never actually tested if this works onpoll()though.maybe the
poll()manpage is wrong.
The standard system callpoll()can not get-ENODEVfrom errno.
Well, it would likely put ENODEV at errno (and not -ENODEV).
Quoted 2 lines
My experiment has proved that I was
right(return -ENODEV directly in dvb_dvr_poll).
and you can also check code ofdo_poll()anddo_sys_poll()inselect.cfile, it also shows that-ENODEVis invalid.
Yeah, I'll check it there. Poll have some different handling, so it is possible that it only accepts a subset of error codes.
Btw, I'm not against returning POLLERR there. Just not sure at this point what would be the best approach. Anyway, read and all other syscalls should return -ENODEV.
Quoted 1 line
please also check that.
Sure I will.
Quoted 72 lines
thanks!
Xiong changbing------- Original Message -------
Sender : Mauro Carvalho Chehab<[email protected]> Director/SRBR-Open Source/삼성전자 Date : 九月 02, 2014 15:00 (GMT+09:00)
Title : Re: [PATCH 3/3] media: check status ofdmxdev->exitin poll functions of demux&dvrEm Tue, 02 Sep 2014 03:16:00 +0000 (GMT)
Changbing Xiong escreveu:Quoted 11 lines
Quoted 10 lines
Well, we may start returning
-ENODEVwhen such event happens.At the frontend, we could use
fe->exit=DVB_FE_DEVICE_REMOVEDto signalize it. I don't think that the demod frontend has something similar.Yet, it should be up to the userspace application to properly handle the error codes and close the devices on fatal non-recovery errors like ENODEV.
Quoted 5 lines
Quoted 3 lines
So, what we can do, at Kernel level, is to always return
-ENODEVwhen the device is known to be removed, and double check libdvbv5 if it handles such error properly.well, we do not use libdvbv5,
The upstream stuff I maintain, related to it, are the media subsystems and libdvbv5. Of course, other apps will need to be patched as well.
Quoted 2 lines
and
-ENODEVcan be returned by read syscall,
but for poll syscall,Actually,
poll()may return an error as well (frompoll()manpage):"RETURN VALUE
On success, a positive number is returned; this is the number of struc‐ tures which have nonzero revents fields (in other words, those descrip‐ tors with events or errors reported). A value of 0 indicates that the
call timed out and no file descriptors were ready. On error, -1 is
returned, and errno is set appropriately."So, if the Kernel returns
-ENODEV, the glibcpoll()wrapper would return -1 and errno will be ENODEV. Never actually tested if this works onpoll()though.Quoted 7 lines
-ENODEVcan never be returned to user, as negative number
is invalid type for poll returned value. please refer to my second patch.and in our usage, whether to read the device is up to the poll result. if tuner is plugged out, and there is no data in dvr ringbuffer. then user code will still go on polling the dvr device and never stop. if POLLERR is returned, then user will perform read dvr, and then
-ENODEVcan be got, and user will stop polling dvr device.Your app should be also be handling
poll()errors, as there are already other errors thatpoll()can return.Quoted 3 lines
the first patch is enough to fix the deadlock issue.
the second patch is used to correct the wrong type of returned value. the third patch is used to provide user a better controlling logic.I'll take a deeper look and do some tests on your patches likely tomorrow.
Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html