]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Clean up dlobj cache only when no user is present
authorTakashi Iwai <tiwai@suse.de>
Tue, 9 Apr 2013 12:55:46 +0000 (14:55 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 9 Apr 2013 13:00:11 +0000 (15:00 +0200)
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>
src/dlmisc.c

index ecbbe8d40c7247bdbb965a25ca4e89cfa8990119..585c7f60121c7e7cf9fd99c4e781c7f6a0e4dafc 100644 (file)
@@ -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