Skip to content

Commit e98b71c

Browse files
authored
Improve logging in PendingUrlRequests. (#1428)
Do not post messages to log for CancelAll and CancelAllAndWait if there is no pending or cancelled requests. Resolves: OLPEDGE-2822 Signed-off-by: Yevhen Krasilnyk <[email protected]>
1 parent a657055 commit e98b71c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

olp-cpp-sdk-core/src/client/PendingUrlRequests.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -198,6 +198,10 @@ bool PendingUrlRequests::CancelAll() {
198198
// is taking care of the Network callback.
199199
std::lock_guard<std::mutex> lock(mutex_);
200200

201+
if (pending_requests_.empty()) {
202+
return true;
203+
}
204+
201205
OLP_SDK_LOG_DEBUG_F(kLogTag,
202206
"CancelAll, pending_requests=%zu, current_thread_id=%s",
203207
pending_requests_.size(), GetCurrentThreadId().c_str());
@@ -218,16 +222,16 @@ bool PendingUrlRequests::CancelAllAndWait() const {
218222
// will not work
219223
std::lock_guard<std::mutex> lock(mutex_);
220224

225+
if (pending_requests_.empty() && cancelled_requests_.empty()) {
226+
return true;
227+
}
228+
221229
OLP_SDK_LOG_DEBUG_F(kLogTag,
222230
"CancelAllAndWait, pending_requests=%zu, "
223231
"cancelled_requests=%zu, current_thread_id=%s",
224232
pending_requests_.size(), cancelled_requests_.size(),
225233
GetCurrentThreadId().c_str());
226234

227-
if (pending_requests_.empty() && cancelled_requests_.empty()) {
228-
return true;
229-
}
230-
231235
pending_requests = pending_requests_;
232236
cancelled_requests = cancelled_requests_;
233237
}

0 commit comments

Comments
 (0)