fix thread-safety bug introduced by 691dc6cb and broken tracker set callback.
authorPengZheng <howtofly@gmail.com>
Tue, 22 Feb 2022 06:53:16 +0000 (14:53 +0800)
committerPengZheng <howtofly@gmail.com>
Tue, 22 Feb 2022 06:57:58 +0000 (14:57 +0800)
commitef1202fec790759e2e13f64973bc788862c0fdd8
treee74c916369e1b25b526aa826199c8eda41d44f8c
parent898f8a748963a492ef52ef52af1c8d70c40eebf4
fix thread-safety bug introduced by 691dc6cb and broken tracker set callback.

One intent of 691dc6cb is to make bundleContext_retainServiceReference and bundleContext_retainServiceReference lockless. Unfortunately it introduced a race condition: if a dying reference (still in registry) get revived by another call of bundleContext_getServiceReferences before it's actually removed from the registry and destroyed, hazard happens.

The set callback of an all-service tracker, whose service name is empty, did not work as expected by CelixBundleContextServicesTests.TrackerOfAllServicesSetTest. Unnecessary set callbacks when closing trackers are eliminated.
13 files changed:
libs/framework/gtest/src/CxxBundleContextTestSuite.cc
libs/framework/gtest/src/bundle_context_services_test.cpp
libs/framework/include/celix_bundle_context.h
libs/framework/include/service_registry.h
libs/framework/src/bundle_context.c
libs/framework/src/framework.c
libs/framework/src/framework_private.h
libs/framework/src/registry_callback_private.h
libs/framework/src/service_reference.c
libs/framework/src/service_registration.c
libs/framework/src/service_registry.c
libs/framework/src/service_tracker.c
libs/utils/include/celix_ref.h