浏览代码

Merge remote-tracking branch 'origin/candidate-6.4.12'

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 年之前
父节点
当前提交
f8e4ba220e

+ 10 - 2
esp/bindings/http/platform/httpservice.cpp

@@ -204,7 +204,10 @@ void checkSetCORSAllowOrigin(CHttpRequest *req, CHttpResponse *resp)
     StringBuffer origin;
     req->getHeader("Origin", origin);
     if (origin.length())
-        resp->setHeader("Access-Control-Allow-Origin", "*");
+    {
+        resp->setHeader("Access-Control-Allow-Origin", origin);
+        resp->setHeader("Access-Control-Allow-Credentials", "true");
+    }
 }
 
 int CEspHttpServer::processRequest()
@@ -806,7 +809,12 @@ int CEspHttpServer::onOptions()
     m_request->getHeader("Access-Control-Request-Headers", allowHeaders);
     if (allowHeaders.length())
         m_response->setHeader("Access-Control-Allow-Headers", allowHeaders);
-    m_response->setHeader("Access-Control-Allow-Origin", "*");
+
+    StringBuffer origin;
+    m_request->getHeader("Origin", origin);
+
+    m_response->setHeader("Access-Control-Allow-Origin", origin.length() ? origin.str() : "*");
+    m_response->setHeader("Access-Control-Allow-Credentials", "true");
     m_response->setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
     m_response->setHeader("Access-Control-Max-Age", "86400"); //arbitrary 24 hours
     m_response->setContentType("text/plain");

+ 9 - 6
esp/services/common/jsonhelpers.hpp

@@ -324,12 +324,15 @@ namespace JsonHelpers
             {
                 if (flags & REQSF_ROOT)
                 {
-                    bool log = reqTree->getPropBool("@log", false); //not in schema
-                    if (log)
-                        appendJSONValue(out, "@log", true);
-                    int tracelevel = reqTree->getPropInt("@traceLevel", -1);
-                    if (tracelevel>=0)
-                        appendJSONValue(out, "@traceLevel", tracelevel);
+                    if (reqTree)
+                    {
+                        bool log = reqTree->getPropBool("@log", false); //not in schema
+                        if (log)
+                            appendJSONValue(out, "@log", true);
+                        int tracelevel = reqTree->getPropInt("@traceLevel", -1);
+                        if (tracelevel>=0)
+                            appendJSONValue(out, "@traceLevel", tracelevel);
+                    }
                 }
                 int flds = type->getFieldCount();
                 for (int idx=0; idx<flds; idx++)

+ 8 - 0
esp/services/esdl_svc_engine/esdl_binding.cpp

@@ -1159,6 +1159,14 @@ EsdlBindingImpl::EsdlBindingImpl(IPropertyTree* cfg, const char *binding,  const
     }
 }
 
+EsdlBindingImpl::~EsdlBindingImpl()
+{
+    if(m_pBindingSubscription != nullptr)
+        m_pBindingSubscription->unsubscribe();
+    if(m_pDefinitionSubscription != nullptr)
+        m_pDefinitionSubscription->unsubscribe();
+}
+
 void EsdlBindingImpl::saveDESDLState()
 {
     try

+ 1 - 4
esp/services/esdl_svc_engine/esdl_binding.hpp

@@ -211,7 +211,6 @@ private:
 
         virtual ~CESDLBindingSubscription()
         {
-            unsubscribe();
         }
 
         void unsubscribe()
@@ -264,7 +263,6 @@ private:
 
         virtual ~CESDLDefinitionSubscription()
         {
-            unsubscribe();
         }
 
         void unsubscribe()
@@ -326,8 +324,7 @@ public:
 
     EsdlBindingImpl();
     EsdlBindingImpl(IPropertyTree* cfg, const char *bindname=NULL, const char *procname=NULL);
-
-    virtual ~EsdlBindingImpl(){}
+    virtual ~EsdlBindingImpl();
 
     virtual int onGet(CHttpRequest* request, CHttpResponse* response);
 

+ 27 - 24
initfiles/etc/DIR_NAME/CMakeLists.txt

@@ -19,8 +19,8 @@ configure_file("version.in" "version")
 configure_file("environment.conf.in" "environment.conf" IMMEDIATE)
 configure_file("environment.xml.in" "environment.xml" IMMEDIATE)
 foreach(iFILES
-    ${CMAKE_CURRENT_BINARY_DIR}/environment.conf
-    ${CMAKE_CURRENT_BINARY_DIR}/version)
+        ${CMAKE_CURRENT_BINARY_DIR}/environment.conf
+        ${CMAKE_CURRENT_BINARY_DIR}/version)
     install(FILES ${iFILES}  DESTINATION etc/${DIR_NAME} COMPONENT Runtime)
 endforeach(iFILES)
 
@@ -44,43 +44,46 @@ if(NOT "${DESTDIR}" STREQUAL "")
     add_custom_target(configure_directories
         DEPENDS ${dirlist})
 
-    add_custom_command(OUTPUT ${CONFIG_DIR}/${ENV_XML_FILE}
-        COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ENV_XML_FILE} ${CONFIG_DIR}
-        DEPENDS configure_directories ${CMAKE_CURRENT_BINARY_DIR}/environment.xml)
-    add_custom_target(configure_environment_xml
-        DEPENDS ${CONFIG_DIR}/${ENV_XML_FILE})
-
-    add_custom_command(OUTPUT ${CONFIG_DIR}/${ENV_CONF_FILE}
-        COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ENV_CONF_FILE} ${CONFIG_DIR}
-        DEPENDS configure_directories ${CMAKE_CURRENT_BINARY_DIR}/environment.conf)
-    add_custom_target(configure_environment_conf
-        DEPENDS ${CONFIG_DIR}/${ENV_CONF_FILE})
-    
     add_custom_command(OUTPUT ${CONFIG_DIR}/genenvrules.conf
         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/genenvrules.conf ${CONFIG_DIR}
         DEPENDS configure_directories ${CMAKE_CURRENT_SOURCE_DIR}/genenvrules.conf)
     add_custom_target(configure_genenvrules_conf
         DEPENDS ${CONFIG_DIR}/genenvrules.conf)
-   
+
     add_custom_command(OUTPUT ${INIT_PATH}/dafilesrv
         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/dafilesrv ${INIT_PATH}/dafilesrv
         DEPENDS configure_directories
-                ProcessFiles-initfiles-bash-etc-init.d
-                ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/dafilesrv)
+        ProcessFiles-initfiles-bash-etc-init.d
+        ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/dafilesrv)
     add_custom_command(OUTPUT ${INIT_PATH}/hpcc-init
         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/hpcc-init ${INIT_PATH}/hpcc-init
         DEPENDS configure_directories
-                ProcessFiles-initfiles-bash-etc-init.d
-                ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/hpcc-init)
+        ProcessFiles-initfiles-bash-etc-init.d
+        ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/hpcc-init)
     add_custom_target(configure_service_files
         DEPENDS ${INIT_PATH}/hpcc-init
-                ${INIT_PATH}/dafilesrv)
+        ${INIT_PATH}/dafilesrv)
+
+
+    install(CODE "
+    if(NOT EXISTS ${CONFIG_DIR}/${ENV_XML_FILE})
+        execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ENV_XML_FILE} ${CONFIG_DIR})
+        message(STATUS \"Copying ${ENV_XML_FILE} to ${CONFIG_DIR}\")
+    else()
+        message(STATUS \"Copy of ${ENV_XML_FILE} already exists at ${CONFIG_DIR}\")
+    endif()
+    if(NOT EXISTS ${CONFIG_DIR}/${ENV_CONF_FILE})
+        execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ENV_CONF_FILE} ${CONFIG_DIR})
+        message(STATUS \"Copying ${ENV_CONF_FILE} to ${CONFIG_DIR}\")
+    else()
+        message(STATUS \"Copy of ${ENV_CONF_FILE} already exists at ${CONFIG_DIR}\")
+    endif()
+    " COMPONENT Runtime)
 
     add_custom_target(configure ALL
         DEPENDS configure_directories
-                configure_environment_xml
-                configure_environment_conf
-                configure_genenvrules_conf
-                configure_service_files
+        configure_genenvrules_conf
+        configure_service_files
         COMMENT "Configuring ${DESTDIR} for deployment")
+
 endif()