aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/src/hicn/core/mapme.c34
-rw-r--r--hicn-light/src/hicn/strategies/loadBalancer.c29
2 files changed, 33 insertions, 30 deletions
diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c
index af332ede2..a0a34e8ce 100644
--- a/hicn-light/src/hicn/core/mapme.c
+++ b/hicn-light/src/hicn/core/mapme.c
@@ -351,28 +351,30 @@ static bool mapme_setFacePending(const MapMe *mapme, const Name *name,
* It is likely we cannot iterator and remove elements from the hashmap at
* the same time, so we proceed in two steps
*/
- NumberSet * conns = numberSet_Create();
+ if (parcHashMap_Size(TFIB(fibEntry)->nexthops) > 0) {
- PARCIterator *it = parcHashMap_CreateKeyIterator(TFIB(fibEntry)->nexthops);
- while (parcIterator_HasNext(it)) {
- PARCUnsigned *cid = parcIterator_Next(it);
- unsigned conn_id = parcUnsigned_GetUnsigned(cid);
- numberSet_Add(conns, conn_id);
- }
- parcIterator_Release(&it);
+ NumberSet * conns = numberSet_Create();
+
+ PARCIterator *it = parcHashMap_CreateKeyIterator(TFIB(fibEntry)->nexthops);
+ while (parcIterator_HasNext(it)) {
+ PARCUnsigned *cid = parcIterator_Next(it);
+ unsigned conn_id = parcUnsigned_GetUnsigned(cid);
+ numberSet_Add(conns, conn_id);
+ }
+ parcIterator_Release(&it);
- for (size_t i = 0; i < numberSet_Length(conns); i++) {
- unsigned conn_id = numberSet_GetItem(conns, i);
- PARCEventTimer *oldTimer = (PARCEventTimer *)mapmeTFIB_Get(TFIB(fibEntry), conn_id);
- if (oldTimer)
+ for (size_t i = 0; i < numberSet_Length(conns); i++) {
+ unsigned conn_id = numberSet_GetItem(conns, i);
+ PARCEventTimer *oldTimer = (PARCEventTimer *)mapmeTFIB_Get(TFIB(fibEntry), conn_id);
+ if (oldTimer)
parcEventTimer_Stop(oldTimer);
- mapmeTFIB_Remove(TFIB(fibEntry), conn_id);
- }
+ mapmeTFIB_Remove(TFIB(fibEntry), conn_id);
+ }
- numberSet_Release(&conns);
+ numberSet_Release(&conns);
+ }
}
-
// NOTE
// - at producer, send always true, we always send something reliably so we
// set the timer.
diff --git a/hicn-light/src/hicn/strategies/loadBalancer.c b/hicn-light/src/hicn/strategies/loadBalancer.c
index e3f377791..35d64e763 100644
--- a/hicn-light/src/hicn/strategies/loadBalancer.c
+++ b/hicn-light/src/hicn/strategies/loadBalancer.c
@@ -344,22 +344,23 @@ static void _strategyLoadBalancer_ImplDestroy(StrategyImpl **strategyPtr) {
StrategyImpl *impl = *strategyPtr;
StrategyLoadBalancer *strategy = (StrategyLoadBalancer *)impl->context;
+ if (parcHashMap_Size(strategy->strategy_state) > 0) {
+ PARCIterator *it = parcHashMap_CreateKeyIterator(strategy->strategy_state);
+ while (parcIterator_HasNext(it)) {
+ PARCUnsigned *cid = parcIterator_Next(it);
+ StrategyNexthopState *state =
+ (StrategyNexthopState *) parcHashMap_Get(strategy->strategy_state, cid);
+ parcObject_Release((void **) &state);
+ }
+ parcIterator_Release(&it);
- PARCIterator *it = parcHashMap_CreateKeyIterator(strategy->strategy_state);
- while (parcIterator_HasNext(it)) {
- PARCUnsigned *cid = parcIterator_Next(it);
- StrategyNexthopState *state =
- (StrategyNexthopState *)parcHashMap_Get(strategy->strategy_state, cid);
- parcObject_Release((void**)&state);
- }
- parcIterator_Release(&it);
-
- parcHashMap_Release(&(strategy->strategy_state));
+ parcHashMap_Release(&(strategy->strategy_state));
#ifndef WITH_POLICY
- numberSet_Release(&(strategy->nexthops));
+ numberSet_Release(&(strategy->nexthops));
#endif /* ! WITH_POLICY */
- parcMemory_Deallocate((void **)&strategy);
- parcMemory_Deallocate((void **)&impl);
- *strategyPtr = NULL;
+ parcMemory_Deallocate((void **) &strategy);
+ parcMemory_Deallocate((void **) &impl);
+ *strategyPtr = NULL;
+ }
}