Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
8 changes: 5 additions & 3 deletions src/libmongoc/src/mongoc/mcd-azure.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <mongoc/mongoc-util-private.h>

#include <mlib/cmp.h>
#include <mlib/duration.h>
#include <mlib/timer.h>

#define AZURE_API_VERSION "2018-02-01"

Expand Down Expand Up @@ -122,7 +124,7 @@ mcd_azure_access_token_try_init_from_json_str(mcd_azure_access_token *out,
// which the token will be valid. strtoll() will saturate on range errors
// and return zero on parse errors.
char *parse_end;
long long s = strtoll(expires_in_str, &parse_end, 0);
const long long expires_in = strtoll(expires_in_str, &parse_end, 0);
if (parse_end != expires_in_str + expires_in_len) {
// Did not parse the entire string. Bad
_mongoc_set_error(error,
Expand All @@ -132,7 +134,7 @@ mcd_azure_access_token_try_init_from_json_str(mcd_azure_access_token *out,
mlib_in_range(int, expires_in_len) ? (int)expires_in_len : INT_MAX,
expires_in_str);
} else {
out->expires_in = mcd_seconds(s);
out->expires_in = mlib_duration(expires_in, s);
okay = true;
}
}
Expand Down Expand Up @@ -174,7 +176,7 @@ mcd_azure_access_token_from_imds(mcd_azure_access_token *const out,
mcd_azure_imds_request req = MCD_AZURE_IMDS_REQUEST_INIT;
mcd_azure_imds_request_init(&req, opt_imds_host, opt_port, opt_extra_headers);

if (!_mongoc_http_send(&req.req, 3 * 1000, false, NULL, &resp, error)) {
if (!_mongoc_http_send(&req.req, mlib_expires_after(mlib_duration(3, s)), false, NULL, &resp, error)) {
goto fail;
}

Expand Down
5 changes: 3 additions & 2 deletions src/libmongoc/src/mongoc/mcd-azure.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

#include <mongoc/mongoc-http-private.h>

#include <mongoc/mcd-time.h>
#include <mongoc/mongoc.h>

#include <mlib/duration.h>

/**
* @brief An Azure OAuth2 access token obtained from the Azure API
*/
Expand All @@ -36,7 +37,7 @@ typedef struct mcd_azure_access_token {
char *token_type;
/// The duration after which it will the token will expires. This is relative
/// to the "issue time" of the token.
mcd_duration expires_in;
mlib_duration expires_in;
} mcd_azure_access_token;

/**
Expand Down
Loading