Skip to content

Commit c301a0a

Browse files
committed
Work around OAuth/EVFILT_TIMER quirk on NetBSD.
NetBSD's EVFILT_TIMER doesn't like zero timeouts, as introduced by commit b3f0be7. 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 <jacob.champion@enterprisedb.com> Discussion: https://postgr.es/m/CA%2BhUKGJ%2BWyJ26QGvO_nkgvbxgw%2B03U4EQ4Hxw%2BQBft6Np%2BXW7w%40mail.gmail.com
1 parent 8a1012b commit c301a0a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/interfaces/libpq/fe-auth-oauth-curl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,16 @@ set_timer(struct async_ctx *actx, long timeout)
13631363
#ifdef HAVE_SYS_EVENT_H
13641364
struct kevent ev;
13651365

1366+
#ifdef __NetBSD__
1367+
1368+
/*
1369+
* Work around NetBSD's rejection of zero timeouts (EINVAL), a bit like
1370+
* timerfd above.
1371+
*/
1372+
if (timeout == 0)
1373+
timeout = 1;
1374+
#endif
1375+
13661376
/* Enable/disable the timer itself. */
13671377
EV_SET(&ev, 1, EVFILT_TIMER, timeout < 0 ? EV_DELETE : (EV_ADD | EV_ONESHOT),
13681378
0, timeout, 0);

0 commit comments

Comments
 (0)