Skip to content

Commit

Permalink
out_stackdriver bug fix: return cached token when current_timestamp i…
Browse files Browse the repository at this point in the history
…s less than cached_expiration (fluent#9652)

* out_stackdriver: return cached token when current_timestamp is less than cached_expiration.

Signed-off-by: shuaichen <[email protected]>

* stackdriver: revert log line change

Signed-off-by: Braydon Kains <[email protected]>

---------

Signed-off-by: shuaichen <[email protected]>
Signed-off-by: Braydon Kains <[email protected]>
Co-authored-by: Braydon Kains <[email protected]>
Signed-off-by: AdheipSingh <[email protected]>
  • Loading branch information
2 people authored and AdheipSingh committed Dec 4, 2024
1 parent 6ecb32f commit 0e75a94
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 0e75a94

Please sign in to comment.