Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Fix recursive dispose #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hyperair
Copy link

@hyperair hyperair commented Nov 7, 2011

This branch fixes a crasher in Banshee when a DAAP service disappears on Ubuntu, as shown on https://bugzilla.gnome.org/show_bug.cgi?id=662309.

Removing event listeners on the resolver can result in recursive calls to
BrowseService.Dispose(), caused by signals being dispatched inside `resolver.Failure
-= OnResolveFailure', rendering the atomicity guaranteed by the lock (this)
block ineffective.

This commit fortifies BrowseService and ServiceBrowser from this:
 - BrowseService.Dispose() will not call DisposeResolver() when already
   disposed.
 - BrowseService.DisposeResolver() will nullify this.resolver before performing
   cleanup on the resolver.
 - ServiceBrowser.OnItemNew() will replace the service entry in its services
   dictionary with the new service before disposing of the old one.
 - ServiceBrowser.OnItemRemoved() will remove the service entry from its services
   dictionary before running Dispose() on it, thus preventing recursive
   Dispose() calls.
Dispose methods of IDisposable objects are should be able to be called more than
once, so avoid doing anything after the first time.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant