From 80d4f51b11ec98eb62b9fede7a1d338fc2fc1e6f Mon Sep 17 00:00:00 2001
From: Claudio Bisegni <Claudio.Bisegni@lnf.infn.it>
Date: Thu, 7 Dec 2017 17:25:14 +0100
Subject: [PATCH] added the print of exception on getNewSocketPair nad added
 new public api for send well format opcode in AbstractRemoteIODriver

---
 .../impl/ZMQDirectIOClientConnection.cpp      |  5 +++-
 .../driver/AbstractRemoteIODriver.h           | 29 +++++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/chaos/common/direct_io/impl/ZMQDirectIOClientConnection.cpp b/chaos/common/direct_io/impl/ZMQDirectIOClientConnection.cpp
index 356ec1d2d..8c1585610 100644
--- a/chaos/common/direct_io/impl/ZMQDirectIOClientConnection.cpp
+++ b/chaos/common/direct_io/impl/ZMQDirectIOClientConnection.cpp
@@ -41,7 +41,8 @@ socket_service(NULL){
 ZMQDirectIOClientConnection::~ZMQDirectIOClientConnection() {}
 
 void ZMQDirectIOClientConnection::init(void *init_data) throw(chaos::CException) {
-    if(ensureSocket() == false) throw CException(-1, "Error configuring socket", __PRETTY_FUNCTION__);
+    int err = 0;
+    if((err = ensureSocket())) throw CException(err, "Error configuring socket", __PRETTY_FUNCTION__);
 }
 
 void ZMQDirectIOClientConnection::deinit() throw(chaos::CException) {
@@ -217,6 +218,8 @@ int ZMQDirectIOClientConnection::getNewSocketPair() {
         }
     } catch(chaos::CException& ex) {
         releaseSocketPair();
+        err = ex.errorCode;
+        DECODE_CHAOS_EXCEPTION(ex);
     }
     return err;
 }
diff --git a/chaos/cu_toolkit/driver_manager/driver/AbstractRemoteIODriver.h b/chaos/cu_toolkit/driver_manager/driver/AbstractRemoteIODriver.h
index 88d8a1e47..32d5a351e 100644
--- a/chaos/cu_toolkit/driver_manager/driver/AbstractRemoteIODriver.h
+++ b/chaos/cu_toolkit/driver_manager/driver/AbstractRemoteIODriver.h
@@ -154,6 +154,26 @@ namespace chaos {
                     
                     ~AbstractRemoteIODriver(){}
                     
+                    //!Send raw request to the remote driver
+                    /*!
+                     \param message_data is the raw data to be transmitted to the remote driver
+                     \param received_data si the raw data received from the driver
+                     */
+                    int sendOpcodeRequest(const std::string opcode,
+                                          chaos::common::data::CDWUniquePtr message_data,
+                                          chaos::common::data::CDWShrdPtr& message_response,
+                                          uint32_t timeout = 5000) {
+                        int err = 0;
+                        LStringWriteLock wl = current_connection_identifier.getWriteLockObject();
+                        if((err = _managePhases())) {
+                            return err;
+                        }
+                        return _sendRawOpcodeRequest(opcode,
+                                                     ChaosMoveOperator(message_data),
+                                                     message_response,
+                                                     timeout);
+                    }
+                    
                     //!Send raw request to the remote driver
                     /*!
                      \param message_data is the raw data to be transmitted to the remote driver
@@ -168,7 +188,8 @@ namespace chaos {
                             return err;
                         }
                         return _sendRawRequest(ChaosMoveOperator(message_data),
-                                               message_response);
+                                               message_response,
+                                               timeout);
                     }
                     
                     //!Send raw message to the remote driver
@@ -326,12 +347,14 @@ namespace chaos {
                     //send datapack as opcode format
                     int _sendRawOpcodeRequest(const std::string opcode,
                                               chaos::common::data::CDWUniquePtr message_data,
-                                              chaos::common::data::CDWShrdPtr& message_response) {
+                                              chaos::common::data::CDWShrdPtr& message_response,
+                                              uint32_t timeout = 5000) {
                         chaos::common::data::CDWUniquePtr opcpde_msg(new chaos::common::data::CDataWrapper());
                         opcpde_msg->addStringValue(MESSAGE_OPCODE, opcode);
                         opcpde_msg->addCSDataValue(MESSAGE_OPCODE_PARAMETER, *message_data);
                         return _sendRawRequest(ChaosMoveOperator(opcpde_msg),
-                                               message_response);
+                                               message_response,
+                                               timeout);
                     }
                     
                     int _sendRawRequest(chaos::common::data::CDWUniquePtr message_data,
-- 
GitLab