瀏覽代碼

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 9 年之前
父節點
當前提交
9dfbc39057
共有 1 個文件被更改,包括 6 次插入3 次删除
  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;