Skip to content

Commit 98036ed

Browse files
Copilotbbockelm
andcommitted
Use named constant for select timeout instead of magic number
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
1 parent 467294b commit 98036ed

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/scitokens_internal.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ class Validator {
469469
Validator() : m_now(std::chrono::system_clock::now()) {}
470470

471471
void set_now(std::chrono::system_clock::time_point now) { m_now = now; }
472+
473+
// Maximum timeout for select() in microseconds for periodic checks
474+
static constexpr long MAX_SELECT_TIMEOUT_US = 50000; // 50ms
472475

473476
std::unique_ptr<AsyncStatus> verify_async(const SciToken &scitoken) {
474477
const jwt::decoded_jwt<jwt::traits::kazuho_picojson> *jwt_decoded =
@@ -496,10 +499,10 @@ class Validator {
496499

497500
while (!result->m_done) {
498501
auto timeout_val = result->get_timeout_val(expiry_time);
499-
// Limit select to 50ms for periodic checks
500-
if (timeout_val.tv_sec > 0 || timeout_val.tv_usec > 50000) {
502+
// Limit select to MAX_SELECT_TIMEOUT_US for periodic checks
503+
if (timeout_val.tv_sec > 0 || timeout_val.tv_usec > MAX_SELECT_TIMEOUT_US) {
501504
timeout_val.tv_sec = 0;
502-
timeout_val.tv_usec = 50000;
505+
timeout_val.tv_usec = MAX_SELECT_TIMEOUT_US;
503506
}
504507

505508
select(result->get_max_fd() + 1, result->get_read_fd_set(),

0 commit comments

Comments
 (0)