Browse Source

HPCC-16598 Removal of readdir_r for CriticalBlocked readdir() call

Signed-off-by: Michael Gardner <michael.gardner@lexisnexis.com>
Michael Gardner 8 years ago
parent
commit
a77f0d5b3f
3 changed files with 8 additions and 7 deletions
  1. 3 4
      system/jlib/jdebug.cpp
  2. 3 2
      system/jlib/jfile.cpp
  3. 2 1
      system/jlib/jregexp.cpp

+ 3 - 4
system/jlib/jdebug.cpp

@@ -1454,7 +1454,7 @@ class CProcessMonitor
     CIArrayOf<CProcInfo> processes;
     unsigned tot_time;
     bool busy;
-
+    CriticalSection sect;
 
     static int compare(CInterface * const *i1, CInterface * const *i2)
     {
@@ -1475,9 +1475,8 @@ public:
             processes.item(i1).active = false;
         DIR *dir = opendir("/proc");
         loop {
-            struct dirent *ent;
-            struct dirent entryMem;
-            readdir_r(dir, &entryMem, &ent);
+            CriticalBlock b(sect);
+            struct dirent *ent = readdir(dir);
             if (!ent)
                 break;
             if ((ent->d_name[0]>='0')&&(ent->d_name[0]<='9')) {

+ 3 - 2
system/jlib/jfile.cpp

@@ -3566,6 +3566,7 @@ class CLinuxDirectoryIterator : public CDirectoryIterator
     DIR *           handle;
     struct stat     st;
     bool            gotst;
+    CriticalSection sect;
 
     bool loadst()
     {
@@ -3626,11 +3627,11 @@ public:
     bool next()
     {
         loop {
-            struct dirent dirEntry;
             struct dirent *entry;
             loop {
                 gotst = false;
-                readdir_r(handle, &dirEntry, &entry);
+                CriticalBlock b(sect);
+                entry = readdir(handle);
                 // need better checking here?
                 if (!entry)
                     break;

+ 2 - 1
system/jlib/jregexp.cpp

@@ -1344,10 +1344,11 @@ static bool WildMatchNreplace ( const char *src, int srclen, int srcidx,
                     (toupper(src[srcidx])!=toupper(next_char)))
                     goto Fail;
             }
-            else
+            else {
                 if ((srcidx == srclen) || (src[srcidx]!=next_char))
                     goto Fail;
                 srcidx++;
+            }
         }
         else {
             loop {