sessiond: refcount `ust_error_accounting_entry`
Keep a reference count of the `ust_error_accounting_entry` to reclaim
memory and cleanup handles as we go.
Triggers on a sessiond target all applications regardless of the UID of
both the trigger and the application. This means that whenever a new UST
counter is created for a UID, we need to keep it around as long as there
is 1. an application from that UID, or 2. an event notifier registered.
This commit achieves that by keeping a count of the registered event
notifiers. If the count is above zero, we keep a reference on every UID
entries. When the count reaches zero, we put that reference on every
entries.
The event notifier count is guarded by a mutex since it's accessed by
both the notification thread and UST registration thread.
Here is the pseudo code for the relevant error accounting events:
App registration:
lookup entry for application UID in hashtable
if found:
get a reference on that existing entry
else:
create a new entry for that UID
get a reference on that new entry
if event_notifier_count > 0:
get an extra reference on the behalf of the event notifiers
Event notifier registration:
increment event_notifier_count
if event_notifier_count == 1:
get a reference on all existing UID entries
App unregistration:
put reference on application UID entry
Event notifier unregistration:
decrement event_notifier_count
if event_notifier_count == 0:
put ref on all existing UID entries
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I74667d30a5b6975bad7975b82f6819e263199cd0
This page took 0.025639 seconds and 4 git commands to generate.