osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc |   4 ++--
 osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc   |   8 ++++----
 osaf/services/saf/smfsv/smfd/SmfUtils.cc         |  23 +++++++++++++++++++----
 osaf/services/saf/smfsv/smfd/SmfUtils.hh         |   2 +-
 4 files changed, 26 insertions(+), 11 deletions(-)


The elapsed time is not correctly added to the total time spent in the loops of 
the functions
waitForNodeDestination and getNodeDestination.
This function ensures that the elapsed time is accounted for correctly with 
relation to the rebootTimeout
as configured by the user. The patch also fixes a 20s deviation from the user 
configured rebootTimeout

diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc 
b/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
@@ -183,7 +183,7 @@ SmfCliCommandAction::execute(SaImmOiHand
        for (it = m_plmExecEnvList.begin(); it != m_plmExecEnvList.end(); ++it) 
{
                const std::string& n = it->getPrefered();
                 SmfndNodeDest nodeDest;
-               if (!getNodeDestination(n, &nodeDest, NULL)) {
+               if (!getNodeDestination(n, &nodeDest, NULL, -1)) {
                        LOG_ER("SmfCliCommandAction no node destination found 
for node %s", n.c_str());
                        result = SA_AIS_ERR_NOT_EXIST;
                        goto done;
@@ -230,7 +230,7 @@ SmfCliCommandAction::rollback(const std:
        for (it = m_plmExecEnvList.rbegin(); it != m_plmExecEnvList.rend(); 
it++) {
                const std::string& n = it->getPrefered();
                 SmfndNodeDest nodeDest;
-               if (!getNodeDestination(n, &nodeDest, NULL)) {
+               if (!getNodeDestination(n, &nodeDest, NULL, -1)) {
                        LOG_ER("SmfCliCommandAction no node destination found 
for node %s", n.c_str());
                        result = SA_AIS_ERR_NOT_EXIST;
                        goto done;
diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc 
b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
@@ -1958,7 +1958,7 @@ SmfUpgradeStep::callActivationCmd()
                      actCommand.c_str(), getSwNode().c_str());
                TRACE("Get node destination for %s", getSwNode().c_str());
 
-               if (!getNodeDestination(getSwNode(), &nodeDest, NULL)) {
+               if (!getNodeDestination(getSwNode(), &nodeDest, NULL, -1)) {
                        LOG_NO("no node destination found for node %s", 
getSwNode().c_str());
                        result = false;
                        goto done;
@@ -2308,7 +2308,7 @@ SmfUpgradeStep::nodeReboot()
        cmd = smfd_cb->smfNodeRebootCmd;
 
        for (listIt = nodeList.begin(); listIt != nodeList.end(); ++listIt) {
-                if (!getNodeDestination(*listIt, &nodeDest, NULL)) {
+                if (!getNodeDestination(*listIt, &nodeDest, NULL, -1)) {
                         LOG_NO("SmfUpgradeStep::nodeReboot: no node 
destination found for node %s", (*listIt).c_str());
                         result = false;
                         goto done;
@@ -2349,7 +2349,7 @@ SmfUpgradeStep::nodeReboot()
 
        while (true) {
                 for (nodeIt = rebootedNodeList.begin(); nodeIt != 
rebootedNodeList.end();) {
-                        if(getNodeDestination((*nodeIt).node_name, &nodeDest, 
&elapsedTime)) {
+                        if(getNodeDestination((*nodeIt).node_name, &nodeDest, 
&elapsedTime, -1)) {
                                 /* Check if node UP counter have been stepped 
*/
                                 if(nodeDest.nd_up_cntr > (*nodeIt).nd_up_cntr) 
{
                                         cmdNodeList.push_back(*nodeIt);        
   //Save rebooted nodes for next step
@@ -2390,7 +2390,7 @@ SmfUpgradeStep::nodeReboot()
 
        while (true) {
                 for (nodeIt = cmdNodeList.begin(); nodeIt != 
cmdNodeList.end();) {
-                        if(getNodeDestination((*nodeIt).node_name, &nodeDest, 
NULL)) {
+                        if(getNodeDestination((*nodeIt).node_name, &nodeDest, 
NULL, -1)) {
                                 if (smfnd_exec_remote_cmd(cmd.c_str(), 
&nodeDest, cliTimeout, 0) == 0) {
                                         nodeIt = cmdNodeList.erase(nodeIt);  
//The node have accepted the command
                                 }
diff --git a/osaf/services/saf/smfsv/smfd/SmfUtils.cc 
b/osaf/services/saf/smfsv/smfd/SmfUtils.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUtils.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUtils.cc
@@ -69,13 +69,14 @@ waitForNodeDestination(const std::string
 {
         int interval = 2;  //seconds
         int nodetimeout = smfd_cb->rebootTimeout/1000000000; //seconds
+        int elapsedTime = 0;
 
-        while (!getNodeDestination(i_node, o_nodeDest, NULL)) {
-                if (nodetimeout > 0) {
+        while (!getNodeDestination(i_node, o_nodeDest, &elapsedTime, 
nodetimeout)) {
+                if (elapsedTime < nodetimeout){
                         TRACE("No destination found, try again wait %d 
seconds", interval);
                         struct timespec sleepTime = { interval, 0 };
                         osaf_nanosleep(&sleepTime);
-                        nodetimeout -= interval;
+                        elapsedTime = elapsedTime + interval;
                 } else {
                         LOG_NO("no node destination found whitin time limit 
for node %s", i_node.c_str());
                         return false;
@@ -86,7 +87,7 @@ waitForNodeDestination(const std::string
 }
 
 bool 
-getNodeDestination(const std::string & i_node, SmfndNodeDest* o_nodeDest, int 
*elapsedTime)
+getNodeDestination(const std::string & i_node, SmfndNodeDest* o_nodeDest, int 
*elapsedTime, int maxWaitTime)
 {
        SmfImmUtils immUtil;
        SaImmAttrValuesT_2 **attributes;
@@ -133,6 +134,12 @@ getNodeDestination(const std::string & i
                         timeout--;
                         if (elapsedTime)
                                 *elapsedTime = *elapsedTime + 2*ONE_SECOND;
+                        if (maxWaitTime != -1) {
+                                if (*elapsedTime >= maxWaitTime) {
+                                        LOG_NO("Failed to get node dest for 
clm node %s", i_node.c_str());
+                                        return false;
+                                }
+                        }
                 }
                 return true;
 
@@ -158,6 +165,14 @@ getNodeDestination(const std::string & i
                         timeout--;
                         if (elapsedTime)
                                 *elapsedTime = *elapsedTime + 2*ONE_SECOND;
+
+                        if (maxWaitTime != -1) {
+                                if (*elapsedTime >= maxWaitTime) {
+                                        LOG_NO("Failed to get node dest for 
clm node %s", i_node.c_str());
+                                               free(nodeName);
+                                        return false;
+                                }
+                       }
                 }
                 free(nodeName);
         } else {
diff --git a/osaf/services/saf/smfsv/smfd/SmfUtils.hh 
b/osaf/services/saf/smfsv/smfd/SmfUtils.hh
--- a/osaf/services/saf/smfsv/smfd/SmfUtils.hh
+++ b/osaf/services/saf/smfsv/smfd/SmfUtils.hh
@@ -73,7 +73,7 @@ extern "C" {
 }
 #endif
 extern bool waitForNodeDestination(const std::string & i_node, SmfndNodeDest* 
o_nodeDest);
-extern bool getNodeDestination(const std::string & i_node, SmfndNodeDest* 
o_nodeDest, int *elapsedTime);
+extern bool getNodeDestination(const std::string & i_node, SmfndNodeDest* 
o_nodeDest, int *elapsedTime, int maxWaitTime);
 extern std::string replaceAllCopy(const std::string& i_haystack, const  
std::string& i_needle, const  std::string& i_replacement);
 
 ///

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to