Explorar o código

Merge pull request #7704 from jakesmith/hpcc-14093

HPCC-14093 Fix regression causing corrupt dafilesrv commands

Reviewed-By: Mark Kelly <mark.kelly@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman %!s(int64=9) %!d(string=hai) anos
pai
achega
27ab57f649
Modificáronse 3 ficheiros con 16 adicións e 5 borrados
  1. 10 5
      common/remote/sockfile.cpp
  2. 4 0
      dali/dafilesrv/CMakeLists.txt
  3. 2 0
      dali/dafilesrv/dafilesrv.cpp

+ 10 - 5
common/remote/sockfile.cpp

@@ -3092,6 +3092,7 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer
         Owned<ISocket> socket;
         StringAttr peerName;
         Owned<IAuthenticatedUser> user;
+        MemoryBuffer msg;
         bool selecthandled;
         size32_t left;
         IArrayOf<IFileIO>   openfiles;      // kept in sync with handles
@@ -3136,6 +3137,7 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer
             }
             parent = _parent;
             left = 0;
+            msg.setEndian(__BIG_ENDIAN);
             selecthandled = false;
             touch();
         }
@@ -3166,8 +3168,6 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer
             size32_t avail = (size32_t)socket->avail_read();
             if (avail)
                 touch();
-            MemoryBuffer msg;
-            msg.setEndian(__BIG_ENDIAN);
             if (left==0)
             {
                 try
@@ -3226,19 +3226,22 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer
                     EXCLOG(e,"notifySelected(3)");
                     e->Release();
                     toread = left;
+                    msg.clear();
                 }
             }
             if (TF_TRACE_FULL)
                 PROGLOG("notifySelected %d,%d",toread,left);
-            if ((left!=0)&&(avail==0)) {
+            if ((left!=0)&&(avail==0))
+            {
                 WARNLOG("notifySelected: Closing mid packet, %d remaining", left);
                 toread = left;
+                msg.clear();
             }
             left -= toread;
             if (left==0)
             {
                 // DEBUG
-                parent->notify(this, msg);
+                parent->notify(this, msg); // consumes msg
             }
             return false;
         }
@@ -3755,6 +3758,7 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer
 
         struct cCommandProcessorParams
         {
+            cCommandProcessorParams() { msg.setEndian(__BIG_ENDIAN); }
             CRemoteClientHandler *client;
             MemoryBuffer msg;
         };
@@ -5167,7 +5171,8 @@ public:
             PROGLOG("notify %d", msg.length());
         if (msg.length())
         {
-            PROGLOG("notify CRemoteClientHandler(%p), msg length=%u", _client, msg.length());
+            if (TF_TRACE_FULL)
+                PROGLOG("notify CRemoteClientHandler(%p), msg length=%u", _client, msg.length());
             cCommandProcessor::cCommandProcessorParams params;
             params.client = client.getClear();
             params.msg.swapWith(msg);

+ 4 - 0
dali/dafilesrv/CMakeLists.txt

@@ -20,3 +20,7 @@ include (dafilesrv.cmake)
 if ( PLATFORM )
     include (dafscontrol.cmake)
 endif()
+
+include_directories ( 
+         ${CMAKE_BINARY_DIR}
+    )

+ 2 - 0
dali/dafilesrv/dafilesrv.cpp

@@ -18,6 +18,7 @@
 #include "platform.h"
 #include "portlist.h"
 
+#include "build-config.h"
 #include "jlib.hpp"
 #include "jiface.hpp"
 #include "jutil.hpp"
@@ -657,6 +658,7 @@ int main(int argc,char **argv)
         lf->beginLogging();
     }
 
+    PROGLOG("Dafilesrv starting - Build %s", BUILD_TAG);
     PROGLOG("Parallel request limit = %d, throttleDelayMs = %d, throttleCPULimit = %d", parallelRequestLimit, throttleDelayMs, throttleCPULimit);
 
     const char * verstring = remoteServerVersionString();