From b4088ba62dd00d1be5b152c76115ee0b651f6a3c Mon Sep 17 00:00:00 2001
From: Alessandro D'Uffizi <alessandro.duffizi@lnf.infn.it>
Date: Thu, 26 May 2022 16:22:59 +0200
Subject: [PATCH] use flush just if not sync

---
 ChaosMetadataServiceClientTest/CMakeLists.txt      | 2 +-
 chaos/common/message/MessagePublishSubscribeBase.h | 1 +
 chaos/common/rpc/psm/PSMClient.cpp                 | 4 +++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChaosMetadataServiceClientTest/CMakeLists.txt b/ChaosMetadataServiceClientTest/CMakeLists.txt
index f81ac976a..46155ddd4 100644
--- a/ChaosMetadataServiceClientTest/CMakeLists.txt
+++ b/ChaosMetadataServiceClientTest/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.9)
 # IF (DEFINED ENV{CHAOS_BUNDLE} )
 #   include($ENV{CHAOS_BUNDLE}/tools/project_template/CMakeChaos.txt)
 # ENDIF()
diff --git a/chaos/common/message/MessagePublishSubscribeBase.h b/chaos/common/message/MessagePublishSubscribeBase.h
index 67b8cef8c..ec307bf27 100644
--- a/chaos/common/message/MessagePublishSubscribeBase.h
+++ b/chaos/common/message/MessagePublishSubscribeBase.h
@@ -94,6 +94,7 @@ namespace chaos {
                  */
         
                 void setMsgOpt(msgOpt opt){msg_opt=opt;}
+                msgOpt getMsgOpt()const {return msg_opt;}
                 /**
                  * @brief Add an handler to the message
                  * 
diff --git a/chaos/common/rpc/psm/PSMClient.cpp b/chaos/common/rpc/psm/PSMClient.cpp
index 4d37cdd80..3ff61db6b 100644
--- a/chaos/common/rpc/psm/PSMClient.cpp
+++ b/chaos/common/rpc/psm/PSMClient.cpp
@@ -147,7 +147,9 @@ bool PSMClient::submitMessage(NFISharedPtr forwardInfo,
         if(prod->pushMsgAsync(*forwardInfo->message.get(),key)!=0){
             return false;
         }
-        prod->flush();
+        if(prod->getMsgOpt()!=chaos::common::message::MessagePublishSubscribeBase::MSG_SYNCH){
+            prod->flush(1000);
+        }
 
     } catch(CException& ex){
         //in this case i need to delete the memory
-- 
GitLab