oauth: Fix postcondition for set_timer on macOS
authorThomas Munro <tmunro@postgresql.org>
Wed, 19 Mar 2025 03:22:52 +0000 (16:22 +1300)
committerThomas Munro <tmunro@postgresql.org>
Wed, 19 Mar 2025 03:45:01 +0000 (16:45 +1300)
commit434dbf6907ec8fafa6862a0f00385f293e63ac0e
tree18ec3570b9de343ae1675bafbb8eb8c28da16092
parent8d9d5843b55f47d24031165f99b07d41715b93e9
oauth: Fix postcondition for set_timer on macOS

On macOS, readding an EVFILT_TIMER to a kqueue does not appear to clear
out previously queued timer events, so checks for timer expiration do
not work correctly during token retrieval. Switching to IPv4-only
communication exposes the problem, because libcurl is no longer clearing
out other timeouts related to Happy Eyeballs dual-stack handling.

Fully remove and re-register the kqueue timer events during each call to
set_timer(), to clear out any stale expirations.

Author: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: https://postgr.es/m/CAOYmi%2Bn4EDOOUL27_OqYT2-F2rS6S%2B3mK-ppWb2Ec92UEoUbYA%40mail.gmail.com
src/interfaces/libpq/fe-auth-oauth-curl.c