Skip to content

Commit

Permalink
sync when last collector removed
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Jan 10, 2020
1 parent c45aa92 commit dbf6cce
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Linux/mod_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,10 @@ extern "C" {
coll->mark = YES;
}

static void deleteMarkedCollectors(EVMod *mod) {
static int deleteMarkedCollectors(EVMod *mod) {
HSP_mod_SONIC *mdata = (HSP_mod_SONIC *)mod->data;
HSPSonicCollector *coll;
int nDeleted = 0;
UTHASH_WALK(mdata->collectors, coll) {
if(coll->mark) {
myDebug(1, "sonic collector removed %s", coll->collectorName);
Expand All @@ -389,8 +390,10 @@ extern "C" {
if(coll->deviceName)
my_free(coll->deviceName);
my_free(coll);
nDeleted++;
}
}
return nDeleted;
}

/*_________________---------------------------__________________
Expand Down Expand Up @@ -1054,11 +1057,16 @@ extern "C" {
}
}
}
deleteMarkedCollectors(mod);
if(deleteMarkedCollectors(mod) > 0
&& UTArrayN(mdata->newCollectors) == 0) {
// collector(s) deleted and none added, so we need to sync here.
// Otherwise the sync happens when the new collector(s) are fully discovered.
syncConfig(mod);
}

// if this was initial startup then we need to bump the state-machine forward here
if(mdata->state == HSP_SONIC_STATE_CONNECTED)
mdata->state = HSP_SONIC_STATE_DISCOVER;

}

static void db_getCollectorNames(EVMod *mod) {
Expand Down

0 comments on commit dbf6cce

Please sign in to comment.