Work around OAuth/EVFILT_TIMER quirk on NetBSD.
authorThomas Munro
Sat, 1 Mar 2025 00:56:33 +0000 (13:56 +1300)
committerThomas Munro
Sat, 1 Mar 2025 01:41:02 +0000 (14:41 +1300)
commitc301a0a74a8aa9ec4fe1f364e05aa17a649f7260
tree74f7c46366d795c41c6be15414ecc44919fa9c6f
parent8a1012b35d6123d8ee1818fce68f435459e297b7
Work around OAuth/EVFILT_TIMER quirk on NetBSD.

NetBSD's EVFILT_TIMER doesn't like zero timeouts, as introduced by
commit b3f0be788.  Steal the workaround from the same problem on Linux
from a few lines up: round zero up to one.  Do this only for NetBSD, as
the other systems with the kevent() API accept zero and shouldn't have
to insert a small bogus wait.

Future improvement ideas:
 * when NetBSD < 10 falls out of support, we could try NODE_ABSTIME for
   the "fire now" meaning if timeout == 0
 * when libcurl tells us to start a 0ms timer and call it back, we could
   figure out how to handle that more directly without involving the
   kernel (the current architecture doesn't make that straightforward)

Failures with EINVAL errors could be seen on the new optional NetBSD CI
task that we're trying to keep green as a candidate for inclusion as
default-enabled CI task.  The NetBSD build farm animals aren't testing
OAuth yet, so no breakage there.

Reviewed-by: Jacob Champion
Discussion: https://postgr.es/m/CA%2BhUKGJ%2BWyJ26QGvO_nkgvbxgw%2B03U4EQ4Hxw%2BQBft6Np%2BXW7w%40mail.gmail.com
src/interfaces/libpq/fe-auth-oauth-curl.c