2020#include <mongoc/mongoc-util-private.h>
2121
2222#include <mlib/cmp.h>
23+ #include <mlib/duration.h>
24+ #include <mlib/timer.h>
2325
2426#define AZURE_API_VERSION "2018-02-01"
2527
@@ -122,7 +124,7 @@ mcd_azure_access_token_try_init_from_json_str(mcd_azure_access_token *out,
122124 // which the token will be valid. strtoll() will saturate on range errors
123125 // and return zero on parse errors.
124126 char * parse_end ;
125- long long s = strtoll (expires_in_str , & parse_end , 0 );
127+ const long long expires_in = strtoll (expires_in_str , & parse_end , 0 );
126128 if (parse_end != expires_in_str + expires_in_len ) {
127129 // Did not parse the entire string. Bad
128130 _mongoc_set_error (error ,
@@ -132,7 +134,7 @@ mcd_azure_access_token_try_init_from_json_str(mcd_azure_access_token *out,
132134 mlib_in_range (int , expires_in_len ) ? (int )expires_in_len : INT_MAX ,
133135 expires_in_str );
134136 } else {
135- out -> expires_in = mcd_seconds ( s );
137+ out -> expires_in = mlib_duration ( expires_in , s );
136138 okay = true;
137139 }
138140 }
@@ -174,7 +176,7 @@ mcd_azure_access_token_from_imds(mcd_azure_access_token *const out,
174176 mcd_azure_imds_request req = MCD_AZURE_IMDS_REQUEST_INIT ;
175177 mcd_azure_imds_request_init (& req , opt_imds_host , opt_port , opt_extra_headers );
176178
177- if (!_mongoc_http_send (& req .req , 3 * 1000 , false, NULL , & resp , error )) {
179+ if (!_mongoc_http_send (& req .req , mlib_expires_after ( mlib_duration ( 3 , s )) , false, NULL , & resp , error )) {
178180 goto fail ;
179181 }
180182
0 commit comments