Ejemplo n.º 1
0
void sfl_agent_release(SFLAgent *agent)
{
    /* release and free the samplers, pollers and receivers */
    SFLSampler *sm = agent->samplers;
    SFLPoller *pl = agent->pollers;
    SFLReceiver *rcv = agent->receivers;

    for(; sm != NULL; ) {
	SFLSampler *nextSm = sm->nxt;
	sflFree(agent, sm);
	sm = nextSm;
    }
    agent->samplers = NULL;

    for(; pl != NULL; ) {
	SFLPoller *nextPl = pl->nxt;
	sflFree(agent, pl);
	pl = nextPl;
    }
    agent->pollers = NULL;

    for(; rcv != NULL; ) {
	SFLReceiver *nextRcv = rcv->nxt;
	sflFree(agent, rcv);
	rcv = nextRcv;
    }
    agent->receivers = NULL;

#ifdef SFLOW_DO_SOCKET
    /* close the sockets */
    if(agent->receiverSocket4 > 0) close(agent->receiverSocket4);
    if(agent->receiverSocket6 > 0) close(agent->receiverSocket6);
#endif
}
Ejemplo n.º 2
0
void sfl_agent_release(SFLAgent *agent)
{
  SFLSampler *sm;
  SFLPoller *pl;
  SFLReceiver *rcv;

  /* release and free the samplers */
  for(sm = agent->samplers; sm != NULL; ) {
    SFLSampler *nextSm = sm->nxt;
    sflFree(agent, sm);
    sm = nextSm;
  }
  agent->samplers = NULL;

  /* release and free the pollers */
  for(pl = agent->pollers; pl != NULL; ) {
    SFLPoller *nextPl = pl->nxt;
    sflFree(agent, pl);
    pl = nextPl;
  }
  agent->pollers = NULL;

  /* release and free the receivers */
  for(rcv = agent->receivers; rcv != NULL; ) {
    SFLReceiver *nextRcv = rcv->nxt;
    sflFree(agent, rcv);
    rcv = nextRcv;
  }
  agent->receivers = NULL;

  /* close the socket */
  if(agent->receiverSocket > 0) close(agent->receiverSocket);
}
Ejemplo n.º 3
0
int sfl_agent_removePoller(SFLAgent *agent, SFLDataSource_instance *pdsi)
{
    /* find it, unlink it and free it */
    SFLPoller *prev = NULL, *pl = agent->pollers;
    for(; pl != NULL; prev = pl, pl = pl->nxt) {
	if(sfl_dsi_compare(pdsi, &pl->dsi) == 0) {
	    if(prev == NULL) agent->pollers = pl->nxt;
	    else prev->nxt = pl->nxt;
	    sflFree(agent, pl);
	    return 1;
	}
    }
    /* not found */
    return 0;
}
Ejemplo n.º 4
0
int sfl_agent_removeSampler(SFLAgent *agent, SFLDataSource_instance *pdsi)
{
    /* find it, unlink it and free it */
    SFLSampler *prev = NULL, *sm = agent->samplers;
    for(; sm != NULL; prev = sm, sm = sm->nxt) {
	if(sfl_dsi_compare(pdsi, &sm->dsi) == 0) {
	    if(prev == NULL) agent->samplers = sm->nxt;
	    else prev->nxt = sm->nxt;
	    sfl_agent_jumpTableRemove(agent, sm);
	    sflFree(agent, sm);
	    return 1;
	}
    }
    /* not found */
    return 0;
}