Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chusitoo committed Dec 31, 2024
1 parent 6de20c1 commit d7be7c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class HttpClient : public opentelemetry::ext::http::client::HttpClient
std::unordered_map<uint64_t, std::shared_ptr<Session>> pending_to_abort_sessions_;
std::unordered_map<uint64_t, HttpCurlEasyResource> pending_to_remove_session_handles_;
std::list<std::shared_ptr<Session>> pending_to_remove_sessions_;
std::deque<Session *> pending_to_retry_sessions_;
std::deque<std::shared_ptr<Session>> pending_to_retry_sessions_;

std::mutex background_thread_m_;
std::unique_ptr<std::thread> background_thread_;
Expand Down
7 changes: 4 additions & 3 deletions ext/src/http/client/curl/http_client_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ bool HttpClient::MaybeSpawnBackgroundThread()

if (operation->IsRetryable())
{
self->pending_to_retry_sessions_.push_front(session);
self->pending_to_retry_sessions_.push_front(hold_session);
}
}
}
Expand Down Expand Up @@ -790,7 +790,8 @@ bool HttpClient::doRemoveSessions()

bool HttpClient::doRetrySessions()
{
auto has_data = false;
const auto now = std::chrono::system_clock::now();
auto has_data = false;

// Assumptions:
// - This is a FIFO list so older sessions, pushed at the front, always end up at the tail
Expand All @@ -807,7 +808,7 @@ bool HttpClient::doRetrySessions()
{
retry_it = decltype(retry_it){pending_to_retry_sessions_.erase(std::next(retry_it).base())};
}
else if (operation->NextRetryTime() < std::chrono::system_clock::now())
else if (operation->NextRetryTime() < now)
{
auto easy_handle = operation->GetCurlEasyHandle();
curl_multi_remove_handle(multi_handle_, easy_handle);
Expand Down
7 changes: 6 additions & 1 deletion ext/src/http/client/curl/http_operation_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,12 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method,
compression_(compression),
is_log_enabled_(is_log_enabled),
retry_policy_(retry_policy),
retry_attempts_(0),
retry_attempts_((retry_policy.max_attempts > 0U &&
retry_policy.initial_backoff > SecondsDecimal::zero() &&
retry_policy.max_backoff > SecondsDecimal::zero() &&
retry_policy.backoff_multiplier > 0.0f)
? 0
: retry_policy.max_attempts),
response_code_(0)
{
/* get a curl handle */
Expand Down

0 comments on commit d7be7c0

Please sign in to comment.