Explorar o código

HPCC-15487 Fileservices functions not threadsafe if ESP URL not supplied

This can affect Roxie in particular where sinks are executed in parallel.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman %!s(int64=9) %!d(string=hai) anos
pai
achega
9dfbc39057
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      plugins/fileservices/fileservices.cpp

+ 6 - 3
plugins/fileservices/fileservices.cpp

@@ -198,14 +198,17 @@ static IPropertyTree *getEnvironmentTree(IConstEnvironment * daliEnv)
     return getHPCCEnvironment();
 }
 
+static StringAttr espurl;           // Default ESP url if none specified
+static CriticalSection espURLcrit;
+
 static const char *getEspServerURL(const char *param)
 {
     if (param&&*param)
         return param;
 
-    //MORE: Not thread safe, although not very likely to cause problems.
-    static StringAttr espurl;
-    if (espurl.isEmpty()) {
+    CriticalBlock b(espURLcrit);
+    if (espurl.isEmpty())
+    {
         Owned<IConstEnvironment> daliEnv = openDaliEnvironment();
         Owned<IPropertyTree> env = getEnvironmentTree(daliEnv);
         StringBuffer tmp;