mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
The cFile class has been partially deprecated
This commit is contained in:
parent
c8566fab77
commit
c02c081d91
7
HISTORY
7
HISTORY
@ -9663,7 +9663,7 @@ Video Disk Recorder Revision History
|
||||
- EXPIRELATENCY now only applies to VPS timers.
|
||||
- Deleting expired timers is now triggered immediately after the timers are modified.
|
||||
|
||||
2021-05-19:
|
||||
2021-05-20:
|
||||
|
||||
- Now using a separate fixed value for internal EPG linger time. This fixes problems with
|
||||
spawned timers jumping to the next event in case Setup.EPGLinger is very small. (reported
|
||||
@ -9683,3 +9683,8 @@ Video Disk Recorder Revision History
|
||||
plugin insists in using "using namespace std;" you can still define
|
||||
DISABLE_TEMPLATES_COLLIDING_WITH_STL before including any VDR header files.
|
||||
- Removed 'register' from libsi/util.c to avoid a warning with ISO-C++17.
|
||||
- The cFile class has been partially deprecated:
|
||||
+ The handling of file handles was not thread-safe.
|
||||
+ It was only actually used in svdrp.c.
|
||||
+ cFile::Ready() now processes only its own file descriptor by calling FileReady()
|
||||
instead of AnyFileReady().
|
||||
|
16
tools.c
16
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.3 2021/01/19 20:38:28 kls Exp $
|
||||
* $Id: tools.c 5.4 2021/05/20 10:13:43 kls Exp $
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
@ -1633,8 +1633,10 @@ bool cFileNameList::Load(const char *Directory, bool DirsOnly)
|
||||
|
||||
// --- cFile -----------------------------------------------------------------
|
||||
|
||||
#if DEPRECATED_CFILE
|
||||
bool cFile::files[FD_SETSIZE] = { false };
|
||||
int cFile::maxFiles = 0;
|
||||
#endif
|
||||
|
||||
cFile::cFile(void)
|
||||
{
|
||||
@ -1659,6 +1661,7 @@ bool cFile::Open(int FileDes)
|
||||
if (FileDes >= 0) {
|
||||
if (!IsOpen()) {
|
||||
f = FileDes;
|
||||
#if DEPRECATED_CFILE
|
||||
if (f >= 0) {
|
||||
if (f < FD_SETSIZE) {
|
||||
if (f >= maxFiles)
|
||||
@ -1672,27 +1675,31 @@ bool cFile::Open(int FileDes)
|
||||
else
|
||||
esyslog("ERROR: file descriptor %d is larger than FD_SETSIZE (%d)", f, FD_SETSIZE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
esyslog("ERROR: attempt to re-open file descriptor %d", FileDes);
|
||||
}
|
||||
return false;
|
||||
return IsOpen();
|
||||
}
|
||||
|
||||
void cFile::Close(void)
|
||||
{
|
||||
if (f >= 0) {
|
||||
close(f);
|
||||
#if DEPRECATED_CFILE
|
||||
files[f] = false;
|
||||
#endif
|
||||
f = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool cFile::Ready(bool Wait)
|
||||
{
|
||||
return f >= 0 && AnyFileReady(f, Wait ? 1000 : 0);
|
||||
return f >= 0 && FileReady(f, Wait ? 1000 : 0);
|
||||
}
|
||||
|
||||
#if DEPRECATED_CFILE
|
||||
bool cFile::AnyFileReady(int FileDes, int TimeoutMs)
|
||||
{
|
||||
fd_set set;
|
||||
@ -1710,6 +1717,7 @@ bool cFile::AnyFileReady(int FileDes, int TimeoutMs)
|
||||
timeout.tv_usec = (TimeoutMs % 1000) * 1000;
|
||||
return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && (FileDes < 0 || FD_ISSET(FileDes, &set));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool cFile::FileReady(int FileDes, int TimeoutMs)
|
||||
{
|
||||
@ -1726,6 +1734,7 @@ bool cFile::FileReady(int FileDes, int TimeoutMs)
|
||||
return select(FD_SETSIZE, &set, NULL, NULL, (TimeoutMs >= 0) ? &timeout : NULL) > 0 && FD_ISSET(FileDes, &set);
|
||||
}
|
||||
|
||||
#if DEPRECATED_CFILE
|
||||
bool cFile::FileReadyForWriting(int FileDes, int TimeoutMs)
|
||||
{
|
||||
fd_set set;
|
||||
@ -1738,6 +1747,7 @@ bool cFile::FileReadyForWriting(int FileDes, int TimeoutMs)
|
||||
timeout.tv_usec = TimeoutMs * 1000;
|
||||
return select(FD_SETSIZE, NULL, &set, NULL, &timeout) > 0 && FD_ISSET(FileDes, &set);
|
||||
}
|
||||
#endif
|
||||
|
||||
// --- cSafeFile -------------------------------------------------------------
|
||||
|
||||
|
11
tools.h
11
tools.h
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.h 5.4 2021/05/19 11:50:24 kls Exp $
|
||||
* $Id: tools.h 5.5 2021/05/20 10:13:43 kls Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TOOLS_H
|
||||
@ -451,10 +451,15 @@ public:
|
||||
struct dirent *Next(void);
|
||||
};
|
||||
|
||||
#ifndef DEPRECATED_CFILE
|
||||
#define DEPRECATED_CFILE 0
|
||||
#endif
|
||||
class cFile {
|
||||
private:
|
||||
#if DEPRECATED_CFILE
|
||||
static bool files[];
|
||||
static int maxFiles;
|
||||
#endif
|
||||
int f;
|
||||
public:
|
||||
cFile(void);
|
||||
@ -465,9 +470,13 @@ public:
|
||||
void Close(void);
|
||||
bool IsOpen(void) { return f >= 0; }
|
||||
bool Ready(bool Wait = true);
|
||||
#if DEPRECATED_CFILE
|
||||
static bool AnyFileReady(int FileDes = -1, int TimeoutMs = 1000);
|
||||
#endif
|
||||
static bool FileReady(int FileDes, int TimeoutMs = 1000);
|
||||
#if DEPRECATED_CFILE
|
||||
static bool FileReadyForWriting(int FileDes, int TimeoutMs = 1000);
|
||||
#endif
|
||||
};
|
||||
|
||||
class cSafeFile {
|
||||
|
Loading…
Reference in New Issue
Block a user