Skip to content

Commit

Permalink
Delay purging of D-Bus name owner information
Browse files Browse the repository at this point in the history
A cache of D-Bus name owner information is maintained by mce - mostly
for facilitate more informative diagnostic logging. The cached entries
are purged when name owner changed signal is seen. If diagnostic
logging is triggered by the same signal, the cached information can
already be lost and failing re-attempt to get it creates noise on
journal.

Do the actual purging via idle callback, so that it happens after
actions triggered by the name owner signal have been dealt with.
  • Loading branch information
spiiroin committed Feb 24, 2015
1 parent 71fdbeb commit 6cc8693
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion mce-dbus.c
Expand Up @@ -2769,14 +2769,41 @@ mce_dbus_ident_delete_cb(gpointer self)
/** Lookup table for cached D-Bus name owner identification data */
static GHashTable *info_lut = 0;

/** Idle callback for handling delayed dbus name owner purging
*
* @param aptr dbus name as void pointer
*
* @return FALSE to stop handler from repeating
*/
static gboolean mce_dbus_rem_ident_cb(gpointer aptr)
{
char *name = aptr;

if( !info_lut )
goto EXIT;

g_hash_table_remove(info_lut, name);

EXIT:
g_free(name);

return FALSE;
}

/** Remove D-Bus name owner identification data from cache
*
* @param name dbus name to purge from cache
*/
static void mce_dbus_rem_ident(const char *name)
{
if( !info_lut )
goto EXIT;

g_hash_table_remove(info_lut, name);
/* Remove entry via idle callback so that the
* identification information we have is still
* made available for other owner lost handlers
*/
g_idle_add(mce_dbus_rem_ident_cb, g_strdup(name));

EXIT:
return;
Expand Down

0 comments on commit 6cc8693

Please sign in to comment.