Pjsip TCP listener fails on many asterisk versions

I have a fairly straightforward config, and I’m running on NetBSD 9. I am building asterisk from pkgsrc, our packaging system. No direct-attached hardware – just softphones, a hardphone, and an Obi FXO/FXS gateway, all SIP via pjsip. With asterisk 16 and 19, things are ok.

I have the usual listeners on udp/5060, tcp/5060, tls/5061.

With 18, 20, 21, 22 asterisk starts up, and with fstat (like lsof) I can see the tcp listening sockets. After about a second they are no longer listening. ktrace shows that there is a spurious accept (since there was no connection) and the listening socket is broken.

 26475      1 asterisk CALL  listen(0x19,5)
 26475      1 asterisk RET   listen 0
 26475      1 asterisk CALL  __clock_gettime50(3,0x7f7fff1b14c0)
 26475      1 asterisk RET   __clock_gettime50 0
 26475      1 asterisk CALL  getsockopt(0x19,0xffff,0x1008,0x7b808b5c0280,0x7f7fff1b1580)
 26475      1 asterisk RET   getsockopt 0
 26475      1 asterisk CALL  ioctl(0x19,FIONBIO,0x7f7fff1b1580)
 26475      1 asterisk GIO   fd 25 wrote 4 bytes
       "\^A\0\0\0"
 26475      1 asterisk RET   ioctl 0
 26475      1 asterisk CALL  accept(0x19,0x7b8088ab6140,0x7b8088ab615c)
 26475      1 asterisk RET   accept -1 errno 35 Resource temporarily unavailable

I realize it’s time to fire up gdb, but I wonder if anyone else has seen this or has any clues. I do wonder about non-blocking IO, but I don’t see a call to select or anything like that before accept, and calling accept on a non-blocking socket should have it return with an error, I think. but not necessarily that one. So I also wonder what the plan is, vs using select. (I know I need to start reading code.)