mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
azbox: add cDemux hack to avoid segfaults/corruption
Origin commit data
------------------
Branch: master
Commit: 2e20b8f2b6
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2013-09-22 (Sun, 22 Sep 2013)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -211,10 +211,11 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
#endif
|
||||
int rc;
|
||||
int to = timeout;
|
||||
struct pollfd ufds;
|
||||
ufds.fd = fd;
|
||||
ufds.events = POLLIN|POLLPRI|POLLERR;
|
||||
ufds.revents = 0;
|
||||
/* using a one-dimensional array seems to avoid strange segfaults / memory corruption?? */
|
||||
struct pollfd ufds[1];
|
||||
ufds[0].fd = fd;
|
||||
ufds[0].events = POLLIN|POLLPRI|POLLERR;
|
||||
ufds[0].revents = 0;
|
||||
|
||||
/* hack: if the frontend loses and regains lock, the demuxer often will not
|
||||
* return from read(), so as a "emergency exit" for e.g. NIT scan, set a (long)
|
||||
@@ -225,7 +226,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
if (to > 0)
|
||||
{
|
||||
retry:
|
||||
rc = ::poll(&ufds, 1, to);
|
||||
rc = ::poll(ufds, 1, to);
|
||||
if (!rc)
|
||||
{
|
||||
if (timeout == 0) /* we took the emergency exit */
|
||||
@@ -252,14 +253,14 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (ufds.revents & POLLHUP) /* we get POLLHUP if e.g. a too big DMX_BUFFER_SIZE was set */
|
||||
if (ufds[0].revents & POLLHUP) /* we get POLLHUP if e.g. a too big DMX_BUFFER_SIZE was set */
|
||||
{
|
||||
dmx_err("received %s,", "POLLHUP", ufds.revents);
|
||||
dmx_err("received %s,", "POLLHUP", ufds[0].revents);
|
||||
return -1;
|
||||
}
|
||||
if (!(ufds.revents & POLLIN)) /* we requested POLLIN but did not get it? */
|
||||
if (!(ufds[0].revents & POLLIN)) /* we requested POLLIN but did not get it? */
|
||||
{
|
||||
dmx_err("received %s, please report!", "POLLIN", ufds.revents);
|
||||
dmx_err("received %s, please report!", "POLLIN", ufds[0].revents);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user