[Aggregator] Fix deletion of the last AP
This commit is contained in:
parent
4a89410b49
commit
e3353e835b
|
@ -13,7 +13,7 @@ char *program_name = NULL ;
|
|||
cfg_t *cfg = NULL ; // Configuration structure
|
||||
couple_list *couples = NULL ; // Computed data list
|
||||
ap_list *token_aps = NULL ; // Token ring of the APs
|
||||
unsigned int nb_aps = 0 ;
|
||||
unsigned int nb_aps = 0 ; // Number of APs in the AP ring
|
||||
|
||||
|
||||
|
||||
|
@ -790,7 +790,6 @@ ap_list* add_ap_front(unsigned char mac_addr_bytes[6])
|
|||
memcpy(ap->mac_addr_bytes, mac_addr_bytes, 6) ;
|
||||
update_ap_seen(ap) ;
|
||||
push_ap(ap) ;
|
||||
++nb_aps ;
|
||||
return ap ;
|
||||
}
|
||||
|
||||
|
@ -822,6 +821,8 @@ void push_ap(ap_list *ap)
|
|||
{
|
||||
assert(ap) ;
|
||||
|
||||
++nb_aps ;
|
||||
|
||||
if (token_aps == NULL) // List does not exist yet
|
||||
{
|
||||
token_aps = ap ;
|
||||
|
@ -872,12 +873,9 @@ void delete_old_aps()
|
|||
{
|
||||
struct timeval now ;
|
||||
|
||||
if (token_aps == NULL)
|
||||
return ;
|
||||
|
||||
gettimeofday(&now, NULL) ;
|
||||
|
||||
while (token_aps != token_aps->next)
|
||||
while (token_aps != NULL)
|
||||
if (sub_date(token_aps->last_seen, now) >
|
||||
(unsigned long) cfg_getint(cfg, "ap_keep_timeout") * 1000)
|
||||
delete_ap(token_aps) ;
|
||||
|
@ -900,7 +898,6 @@ void delete_ap(ap_list *ap)
|
|||
|
||||
unlink_ap(ap) ;
|
||||
free(ap) ;
|
||||
--nb_aps ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -924,12 +921,19 @@ void unlink_ap(ap_list *ap)
|
|||
ap_next->previous = ap_previous ;
|
||||
|
||||
if (ap == token_aps)
|
||||
token_aps = ap_next ;
|
||||
{
|
||||
if (ap->next == ap) // It was the last AP in the ring
|
||||
token_aps = NULL ;
|
||||
else
|
||||
token_aps = ap_next ;
|
||||
}
|
||||
|
||||
--nb_aps ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sends a send order to the given AP.
|
||||
* Sends a 'send' order to the given AP.
|
||||
*/
|
||||
void order_send(ap_list *ap)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue