Hi list, running into deadlocks with service registration while refactorring HttpContext mechanism for the OpenSocial stuff and I am not sure how to deal with it. Seen it before, it has a smell but I can not pinpoint the cause and solution... Hope you can point me in the right direction. This is roughly/simplified what happens as far as I understand it (stacktrace below):
DM1 tracks service registrations of InterfaceA for ComponentX DM2 registers a service with InterfaceA DM1 invokes callback serviceAdded(ServiceA) on ComponentX (uses a lock) ComponentX invokes a method on ServiceA ServiceA registers new ServiceB with DM2, again with InterfaceA DM2 registers a service with InterfaceA DM1 invokes callback serviceAdded(ServiceA) on ComponentX (uses a lock) *DEADLOCK* So, if you do something in a dependencycallback that thriggers (in any kind of indirect way) another service registration that results in the same callback and you do any kind of synchronization in the callback your are in for trouble because everything DM does is synchronous and framework serviceevents are as well. Fair enough I think, but how to deal with this? 0. The design sucks.Never have service related side effects in callbacks? Seems a common enough use case though.. 1. Handle callback logic (at least the stuff that has any service related side effects) asynchronous? Cumbersome.. 2. Make DM do stuff asynchronous.. why is it all synchronous? I guess you could get the same scenario with bare OSGi service listeners. 3. ...? Any tips or insights are more then welcome :) Regards, Bram _______________________________________________ Amdatu-developers mailing list [email protected] http://lists.amdatu.org/mailman/listinfo/amdatu-developers

