Browse Source

Merge remote-tracking branch 'origin/candidate-4.2.6' into closedown-4.2.x

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 years ago
parent
commit
5dcad8a517
4 changed files with 60 additions and 3 deletions
  1. 1 1
      common/dllserver/dllserver.cpp
  2. 15 1
      roxie/ccd/ccddali.cpp
  3. 40 1
      system/jlib/jutil.cpp
  4. 4 0
      system/jlib/jutil.hpp

+ 1 - 1
common/dllserver/dllserver.cpp

@@ -498,7 +498,7 @@ void DllServer::copyFileLocally(RemoteFilename & targetName, RemoteFilename & so
 
     OwnedIFile source = createIFile(sourceName);
     OwnedIFile target = createIFile(targetName);
-    copyFile(target, source);
+    source->copyTo(target, 0, NULL, true);
 }
 
 IIterator * DllServer::createDllIterator()

+ 15 - 1
roxie/ccd/ccddali.cpp

@@ -784,7 +784,21 @@ public:
             StringBuffer localName(queryDirectory);
             localName.append(name);
             if (checkFileExists(localName.str()))
-                return createDllEntry(localName.str(), false, NULL);
+            {
+                try
+                {
+                    return createDllEntry(localName.str(), false, NULL);
+                }
+                catch (ICorruptDllException *E)
+                {
+                    remove(localName.str());
+                    E->Release();
+                }
+                catch (...)
+                {
+                    throw;
+                }
+            }
         }
         CriticalBlock b(crit);
         Owned<IRoxieDaliHelper> daliHelper = connectToDali();

+ 40 - 1
system/jlib/jutil.cpp

@@ -280,7 +280,41 @@ void unpackNumber(char * target, const char * source, unsigned tlen)
     }
 }
 
+//-----------------------------------------------------------------------
+
+class jlib_thrown_decl CorruptDllException : public CInterfaceOf<ICorruptDllException>
+{
+public:
+    CorruptDllException(int code, const char *_dllName, const char *_dlError)
+    : errcode(code)
+    {
+        VStringBuffer s("Error loading %s: %s", _dllName, _dlError);
+        msg.set(s.str());
+    };
+    int  errorCode() const { return errcode; }
+    StringBuffer &  errorMessage(StringBuffer &str) const
+    {
+        return str.append(msg.get());
+    }
+    MessageAudience errorAudience() const
+    {
+        return MSGAUD_operator;
+    }
+private:
+    int errcode;
+    StringAttr msg;
+};
 
+static bool isCorruptDll(const char *errorMessage)
+{
+    // yuk.
+    // Add other error strings for corrupt .so files as/when we encounter them
+    if (strstr(errorMessage, "file too short") ||
+        strstr(errorMessage, "ELF load command past end of file"))
+        return true;
+    return false;
+
+}
 //-----------------------------------------------------------------------
 HINSTANCE LoadSharedObject(const char *name, bool isGlobal, bool raiseOnError)
 {
@@ -348,7 +382,12 @@ HINSTANCE LoadSharedObject(const char *name, bool isGlobal, bool raiseOnError)
             StringBuffer dlErrorMsg(dlerror());
             DBGLOG("Error loading %s: %s", name, dlErrorMsg.str());
             if (raiseOnError)
-                throw MakeStringException(0, "Error loading %s: %s", name, dlErrorMsg.str());
+            {
+                if (isCorruptDll(dlErrorMsg.str()))
+                    throw new CorruptDllException(errno, name, dlErrorMsg.str());
+                else
+                    throw MakeStringException(0, "Error loading %s: %s", name, dlErrorMsg.str());
+            }
         }
     }
 

+ 4 - 0
system/jlib/jutil.hpp

@@ -286,5 +286,9 @@ extern jlib_decl bool safe_ecvt(size_t len, char * buffer, double value, int num
 extern jlib_decl bool safe_fcvt(size_t len, char * buffer, double value, int numPlaces, int * decimal, int * sign);
 extern jlib_decl StringBuffer &getTempFilePath(StringBuffer & target, const char * component, IPropertyTree * pTree);
 
+interface jlib_thrown_decl ICorruptDllException: extends IException
+{
+};
+
 #endif