Further fix for potential race condition in Service Registry.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1684634 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
index a66f7e3..16ab677 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
@@ -419,9 +419,11 @@
             {
                 if (count == 0)
                 {
+                    Object svc = usage.m_svcHolderRef.getAndSet(null).m_service;
+
                     // Remove reference from usages array.
                     ((ServiceRegistrationImpl.ServiceReferenceImpl) ref)
-                        .getRegistration().ungetService(bundle, usage.getService());
+                        .getRegistration().ungetService(bundle, svc);
                 }
             }
             finally