diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-04-09 14:55:46 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-04-09 15:00:11 +0200 |
commit | e79990ac5d09001c8c678feaed057e991ee8379e (patch) | |
tree | 8d40819a9e7845c1e15135e4028ff5b9f560e612 | |
parent | a6813c2d0e2fa4586122d23748033a8bab206b8b (diff) | |
download | alsa-lib-e79990ac5d09001c8c678feaed057e991ee8379e.tar.gz |
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 <tiwai@suse.de>
-rw-r--r-- | src/dlmisc.c | 21 |
1 files 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 |