Hallo,
das Problem wird wohl bei dem ein oder anderen VDR Projekt auftauchen, da "readdir_r" ab glibc 2.24 von 2016 als deprecated markiert wurde.
- https://lwn.net/Articles/696474/
- https://linux.die.net/man/3/readdir_r
So weit so gut, habe ich das nach lesen verschiedener Quellen in text2skin korrigiert:
void cText2SkinLoader::Start(void) {
DIR *d = opendir(SkinPath().c_str());
if (d) {
struct dirent ent;
struct dirent *result;
while ((readdir_r(d, &ent, &result)) == 0 && result != NULL) {
struct stat buf;
if (strcmp(result->d_name, ".") == 0 || strcmp(result->d_name, "..") == 0)
continue;
if (stat((SkinPath() + "/" + result->d_name).c_str(), &buf) == 0
&& S_ISDIR(buf.st_mode))
Load(result->d_name);
}
closedir(d);
}
}
Display More
void cText2SkinLoader::Start(void) {
DIR *d = opendir(SkinPath().c_str());
struct dirent *result;
if (d) {
while ((result = readdir(d)) != NULL) {
struct stat buf;
if (strcmp(result->d_name, ".") == 0 || strcmp(result->d_name, "..") == 0)
continue;
if (stat((SkinPath() + "/" + result->d_name).c_str(), &buf) == 0
&& S_ISDIR(buf.st_mode))
Load(result->d_name);
}
closedir(d);
}
}
Display More
Nun kam die Frage auf wie weit zurück gibt es damit kein Problem?
Nach meinem Verständnis galt "readdir_r" als "thread safe" und "readdir" nicht, wobei das wohl eine zu einfache Erklärung war. "readdir" war scheinbar keine "reentrant function" und damit mittelbar per Definition nicht "thread safe".
Lt. dieser Diskussion von 2011:
- https://stackoverflow.com/ques…-the-static-allocated-res
wurde der Missstand schon vor langer Zeit behoben, Posix 2008, daher habe ich für mich mitgenommen, kein Problem, auch wenn die verwendete glibc etwas älter ist.
Was meinen die C/C++ Profis dazu?
Gruß
Frank