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

out_stackdriver bug fix: return cached token when current_timestamp is less than cached_expiration #9652

Merged
merged 2 commits into from
Nov 27, 2024
Merged
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
5 changes: 4 additions & 1 deletion plugins/out_stackdriver/stackdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ static flb_sds_t get_google_token(struct flb_stackdriver *ctx)
int ret = 0;
flb_sds_t output = NULL;
time_t cached_expiration = 0;
time_t current_timestamp = 0;

ret = pthread_mutex_trylock(&ctx->token_mutex);
if (ret == EBUSY) {
Expand All @@ -369,7 +370,9 @@ static flb_sds_t get_google_token(struct flb_stackdriver *ctx)
*/
output = oauth2_cache_to_token();
cached_expiration = oauth2_cache_get_expiration();
if (time(NULL) >= cached_expiration) {
current_timestamp = time(NULL);

if (current_timestamp < cached_expiration) {
return output;
} else {
/*
Expand Down
Loading