Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/use steady_clock to handle backward system clock adjustments #698

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libs/framework/include/celix/BundleActivator.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ namespace impl {
template<typename T>
void waitForExpired(long bndId, std::weak_ptr<celix::BundleContext> &weakCtx, const char *name,
std::weak_ptr<T> &observe) {
auto start = std::chrono::system_clock::now();
auto start = std::chrono::steady_clock::now();
while (!observe.expired()) {
auto now = std::chrono::system_clock::now();
auto now = std::chrono::steady_clock::now();
auto durationInSec = std::chrono::duration_cast<std::chrono::seconds>(now - start);
if (durationInSec > std::chrono::seconds{5}) {
auto msg = std::string{"Cannot destroy bundle "} + std::to_string(bndId) + ". " + name +
Expand Down
4 changes: 2 additions & 2 deletions libs/framework/include/celix/Trackers.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ namespace celix {

template<typename U>
void waitForExpired(std::weak_ptr<U> observe, long svcId, const char* objName) {
auto start = std::chrono::system_clock::now();
auto start = std::chrono::steady_clock::now();
while (!observe.expired()) {
auto now = std::chrono::system_clock::now();
auto now = std::chrono::steady_clock::now();
auto durationInMilli = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
if (durationInMilli > warningTimoutForNonExpiredSvcObject) {
celix_bundleContext_log(cCtx.get(), CELIX_LOG_LEVEL_WARNING, "Cannot remove %s associated with service.id %li, because it is still in use. Current shared_ptr use count is %i\n", objName, svcId, (int)observe.use_count());
Expand Down
4 changes: 2 additions & 2 deletions libs/framework/include/celix/dm/ServiceDependency_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ using namespace celix::dm;

template<typename U>
inline void BaseServiceDependency::waitForExpired(std::weak_ptr<U> observe, long svcId, const char* observeType) {
auto start = std::chrono::system_clock::now();
auto start = std::chrono::steady_clock::now();
while (!observe.expired()) {
auto now = std::chrono::system_clock::now();
auto now = std::chrono::steady_clock::now();
auto durationInMilli = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
if (durationInMilli > warningTimoutForNonExpiredSvcObject) {
if (cCmp) {
Expand Down
Loading