mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-12-26 23:06:44 +01:00
Limiting timeouts to a minimum of 3ms to avoid problems with polls and waits if timeout is 0
This commit is contained in:
3
HISTORY
3
HISTORY
@@ -10119,7 +10119,7 @@ Video Disk Recorder Revision History
|
||||
- Now deleting old recording info before reading modified info file (suggested by
|
||||
Stefan Hofmann).
|
||||
|
||||
2025-04-18:
|
||||
2025-06-17:
|
||||
|
||||
- Fixed some misplaced 'override' keywords in the 'hello' and 'skincurses' plugins.
|
||||
- cRecording now fetches priority, lifetime and framesPerSecond from cRecordingInfo.
|
||||
@@ -10128,3 +10128,4 @@ Video Disk Recorder Revision History
|
||||
Haubrich).
|
||||
- Updated the Italian OSD texts (thanks to Diego Pierotto).
|
||||
- Enabled manually turning subtitles on/off in 'after rewind' mode.
|
||||
- Limiting timeouts to a minimum of 3ms to avoid problems with polls and waits if timeout is 0.
|
||||
|
||||
5
thread.c
5
thread.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: thread.c 5.3 2025/01/15 08:43:12 kls Exp $
|
||||
* $Id: thread.c 5.4 2025/06/17 20:32:06 kls Exp $
|
||||
*/
|
||||
|
||||
#include "thread.h"
|
||||
@@ -40,6 +40,7 @@ static bool GetAbsTime(struct timespec *Abstime, int MillisecondsFromNow)
|
||||
{
|
||||
struct timeval now;
|
||||
if (gettimeofday(&now, NULL) == 0) { // get current time
|
||||
MillisecondsFromNow = max(MillisecondsFromNow, 3); // // making sure the time is >2ms to avoid possible busy waits
|
||||
now.tv_sec += MillisecondsFromNow / 1000; // add full seconds
|
||||
now.tv_usec += (MillisecondsFromNow % 1000) * 1000; // add microseconds
|
||||
if (now.tv_usec >= 1000000) { // take care of an overflow
|
||||
@@ -72,7 +73,7 @@ cCondWait::~cCondWait()
|
||||
void cCondWait::SleepMs(int TimeoutMs)
|
||||
{
|
||||
cCondWait w;
|
||||
w.Wait(max(TimeoutMs, 3)); // making sure the time is >2ms to avoid a possible busy wait
|
||||
w.Wait(TimeoutMs);
|
||||
}
|
||||
|
||||
bool cCondWait::Wait(int TimeoutMs)
|
||||
|
||||
4
tools.c
4
tools.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.c 5.15 2025/01/15 08:57:45 kls Exp $
|
||||
* $Id: tools.c 5.16 2025/06/17 20:32:06 kls Exp $
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
@@ -1585,7 +1585,7 @@ void cPoller::Del(int FileHandle, bool Out)
|
||||
bool cPoller::Poll(int TimeoutMs)
|
||||
{
|
||||
if (numFileHandles) {
|
||||
if (poll(pfd, numFileHandles, TimeoutMs) != 0)
|
||||
if (poll(pfd, numFileHandles, max(TimeoutMs, 3)) != 0) // can't let it be 0, otherwise poll() returns immediately, even if no file descriptors are ready
|
||||
return true; // returns true even in case of an error, to let the caller
|
||||
// access the file and thus see the error code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user