diff --git a/plugins/out_stackdriver/stackdriver.c b/plugins/out_stackdriver/stackdriver.c index 903bffce98d..99ef657a0b4 100644 --- a/plugins/out_stackdriver/stackdriver.c +++ b/plugins/out_stackdriver/stackdriver.c @@ -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) { @@ -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 { /*