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:
Stefan Seyfried
2013-09-22 14:44:29 +02:00
parent fafdfbf884
commit 980c5c2f92

View File

@@ -211,10 +211,11 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
#endif #endif
int rc; int rc;
int to = timeout; int to = timeout;
struct pollfd ufds; /* using a one-dimensional array seems to avoid strange segfaults / memory corruption?? */
ufds.fd = fd; struct pollfd ufds[1];
ufds.events = POLLIN|POLLPRI|POLLERR; ufds[0].fd = fd;
ufds.revents = 0; ufds[0].events = POLLIN|POLLPRI|POLLERR;
ufds[0].revents = 0;
/* hack: if the frontend loses and regains lock, the demuxer often will not /* 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) * 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) if (to > 0)
{ {
retry: retry:
rc = ::poll(&ufds, 1, to); rc = ::poll(ufds, 1, to);
if (!rc) if (!rc)
{ {
if (timeout == 0) /* we took the emergency exit */ if (timeout == 0) /* we took the emergency exit */
@@ -252,14 +253,14 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
return 0; return 0;
} }
#endif #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; 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; return 0;
} }
} }