From e79990ac5d09001c8c678feaed057e991ee8379e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 9 Apr 2013 14:55:46 +0200 Subject: [PATCH] Clean up dlobj cache only when no user is present Cleaning up the dlobj cache seems crashing some cases when the library is used from another plugin like openal-soft. A simple workaround is to do the cleanup only when really no user is left, i.e. after all close calls. Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=814250 Signed-off-by: Takashi Iwai --- src/dlmisc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/dlmisc.c b/src/dlmisc.c index ecbbe8d4..585c7f60 100644 --- a/src/dlmisc.c +++ b/src/dlmisc.c @@ -295,17 +295,24 @@ void snd_dlobj_cache_cleanup(void) struct list_head *p, *npos; struct dlobj_cache *c; + /* clean up caches only when really no user is present */ snd_dlobj_lock(); + list_for_each(p, &pcm_dlobj_list) { + c = list_entry(p, struct dlobj_cache, list); + if (c->refcnt) + goto unlock; + } + list_for_each_safe(p, npos, &pcm_dlobj_list) { c = list_entry(p, struct dlobj_cache, list); - if (c->refcnt == 0) { - list_del(p); - snd_dlclose(c->dlobj); - free((void *)c->name); /* shut up gcc warning */ - free((void *)c->lib); /* shut up gcc warning */ - free(c); - } + list_del(p); + snd_dlclose(c->dlobj); + free((void *)c->name); /* shut up gcc warning */ + free((void *)c->lib); /* shut up gcc warning */ + free(c); } + + unlock: snd_dlobj_unlock(); } #endif -- 2.11.0