osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc | 49 ++++++++++++---------------
1 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
b/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
--- a/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
+++ b/osaf/services/saf/amf/amfd/sg_nwayact_fsm.cc
@@ -105,7 +105,15 @@
if ((i_su->saAmfSuReadinessState !=
SA_AMF_READINESS_IN_SERVICE) ||
((i_su->sg_of_su->saAmfSGMaxActiveSIsperSU != 0)
&& (i_su->sg_of_su->saAmfSGMaxActiveSIsperSU <=
i_su->saAmfSUNumCurrActiveSIs))) {
- i_su = i_su->sg_list_su_next;
+ std::set<AVD_SU*, AVD_SU::comparator>::iterator
iter = i_su->sg_of_su->list_of_su.find(i_su);
+ if (iter != i_su->sg_of_su->list_of_su.end()) {
+ ++iter;
+ if (iter !=
i_su->sg_of_su->list_of_su.end()) {
+ i_su = *iter;
+ } else {
+ i_su = NULL;
+ }
+ }
continue;
}
@@ -138,12 +146,15 @@
* take more assignments so that the SI can be assigned.
*/
l_flag = false;
- i_su = sg->list_of_su;
- while ((i_su != NULL) && (false == sg->equal_ranked_su)){
+ for (const auto& iter : sg->list_of_su) {
+ if (sg->equal_ranked_su == true) {
+ break;
+ }
+
+ i_su = iter;
if ((i_su->saAmfSuReadinessState !=
SA_AMF_READINESS_IN_SERVICE) ||
((i_su->sg_of_su->saAmfSGMaxActiveSIsperSU != 0)
&& (i_su->sg_of_su->saAmfSGMaxActiveSIsperSU <=
i_su->saAmfSUNumCurrActiveSIs))) {
- i_su = i_su->sg_list_su_next;
continue;
}
@@ -161,7 +172,6 @@
/* This SU has already a assignment for this SI
go to the
* next SU.
*/
- i_su = i_su->sg_list_su_next;
continue;
}
@@ -182,8 +192,6 @@
}
/* choose the next SU */
- i_su = i_su->sg_list_su_next;
-
} /* while (i_su != AVD_SU_NULL) */
if (true == sg->equal_ranked_su) {
@@ -1659,7 +1667,6 @@
}
uint32_t SG_NACV::sg_admin_down(AVD_CL_CB *cb, AVD_SG *sg) {
- AVD_SU *i_su;
TRACE_ENTER2("%u", sg->sg_fsm_state);
@@ -1669,7 +1676,6 @@
switch (sg->sg_fsm_state) {
case AVD_SG_FSM_STABLE:
-
if (sg->saAmfSGAdminState == SA_AMF_ADMIN_LOCKED) {
/* SG lock. Identify all the assigned SUs, send
D2N-INFO_SU_SI_ASSIGN
* modify quiesced all for each of the SU. Add them to
@@ -1677,16 +1683,13 @@
* If no assigned SU exist, no action, stay in stable
state.
*/
- i_su = sg->list_of_su;
- while (i_su != NULL) {
+ for (const auto& i_su : sg->list_of_su) {
if (i_su->list_of_susi != AVD_SU_SI_REL_NULL) {
avd_sg_su_si_mod_snd(cb, i_su,
SA_AMF_HA_QUIESCED);
/* add the SU to the operation list */
avd_sg_su_oper_list_add(cb, i_su,
false);
}
-
- i_su = i_su->sg_list_su_next;
}
} /* if (sg->admin_state == NCS_ADMIN_STATE_LOCK) */
@@ -1696,16 +1699,13 @@
* the SU operation list. Change state to SG_admin.
* If no assigned SU exist, no action, stay in stable
state.
*/
- i_su = sg->list_of_su;
- while (i_su != NULL) {
+ for (const auto& i_su : sg->list_of_su) {
if (i_su->list_of_susi != AVD_SU_SI_REL_NULL) {
avd_sg_su_si_mod_snd(cb, i_su,
SA_AMF_HA_QUIESCING);
/* add the SU to the operation list */
avd_sg_su_oper_list_add(cb, i_su,
false);
}
-
- i_su = i_su->sg_list_su_next;
}
} /* if (sg->admin_state == NCS_ADMIN_STATE_SHUTDOWN) */
@@ -1765,14 +1765,14 @@
*next_si_tobe_assigned = true;
return NULL;
}
- i_su = sg->list_of_su;
- while (i_su != NULL){
+
+ for (const auto& iter : sg->list_of_su) {
+ i_su = iter;
if ((i_su->saAmfSuReadinessState !=
SA_AMF_READINESS_IN_SERVICE) ||
((i_su->sg_of_su->saAmfSGMaxActiveSIsperSU != 0)
&& (i_su->sg_of_su->saAmfSGMaxActiveSIsperSU <=
i_su->saAmfSUNumCurrActiveSIs))) {
- i_su = i_su->sg_list_su_next;
continue;
}
l_flag = true;
@@ -1780,7 +1780,6 @@
/* This SU has already a assignment for this SI go to
the
* next SU.
*/
- i_su = i_su->sg_list_su_next;
continue;
}
@@ -1796,8 +1795,6 @@
}
pre_temp_su = i_su;
/* choose the next SU */
- i_su = i_su->sg_list_su_next;
-
}/* while (i_su != NULL)*/
if (false == l_flag){
@@ -1844,10 +1841,9 @@
avd_sg->max_assigned_su = avd_sg->min_assigned_su = NULL;
avd_sg->si_tobe_redistributed = NULL;
- i_su = avd_sg->list_of_su;
- while (i_su != NULL) {
+ for (const auto& iter : avd_sg->list_of_su) {
+ i_su = iter;
if (i_su->saAmfSuReadinessState != SA_AMF_READINESS_IN_SERVICE)
{
- i_su = i_su->sg_list_su_next;
continue;
}
if (NULL == avd_sg->max_assigned_su) {
@@ -1860,7 +1856,6 @@
if (i_su->saAmfSUNumCurrActiveSIs <
avd_sg->min_assigned_su->saAmfSUNumCurrActiveSIs)
avd_sg->min_assigned_su = i_su;
}
- i_su = i_su->sg_list_su_next;
} /* while (i_su != NULL) */
if ((NULL == avd_sg->max_assigned_su) || (NULL ==
avd_sg->min_assigned_su)) {
------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel