sessiond: refcount `ust_error_accounting_entry`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 16 Apr 2021 15:14:21 +0000 (11:14 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 23 Apr 2021 00:18:37 +0000 (20:18 -0400)
commita5a212809b470aafd9c7f4cacbebfb4652feb16b
treefaad8732583e136cd85fc381db3b8cfac705bdfc
parent7c2fae7c05b6eb686317f9c443366f046f0a2757
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
src/bin/lttng-sessiond/event-notifier-error-accounting.c
src/bin/lttng-sessiond/ust-app.c
tests/regression/tools/notification/test_notification_notifier_discarded_count
This page took 0.026611 seconds and 5 git commands to generate.