subscr: Introduce subscr_purge_inactive to free unused subscribers
Introduce a method that will remove all subscribers that have a zero use count. This is useful if someone wants to purge subscribers from memory or wants to disable the everything in RAM feature.
This commit is contained in:
parent
daee5ca7c1
commit
f694d5f47a
|
@ -90,6 +90,8 @@ struct gsm_subscriber *subscr_active_by_imsi(struct gsm_network *net,
|
|||
|
||||
char *subscr_name(struct gsm_subscriber *subscr);
|
||||
|
||||
int subscr_purge_inactive(struct gsm_network *net);
|
||||
|
||||
/* internal */
|
||||
struct gsm_subscriber *subscr_alloc(void);
|
||||
extern struct llist_head active_subscribers;
|
||||
|
|
|
@ -133,3 +133,18 @@ struct gsm_subscriber *subscr_active_by_imsi(struct gsm_network *net, const char
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int subscr_purge_inactive(struct gsm_network *net)
|
||||
{
|
||||
struct gsm_subscriber *subscr, *tmp;
|
||||
int purged = 0;
|
||||
|
||||
llist_for_each_entry_safe(subscr, tmp, subscr_bsc_active_subscriber(), entry) {
|
||||
if (subscr->net == net && subscr->use_count <= 0) {
|
||||
subscr_free(subscr);
|
||||
purged += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return purged;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue