armanbilge/epollcat

KqueueExecutorSchedule#poll should not hang forever if no work to do

Closed this issue · 2 comments

The following line in KqueueExecutorSchedule#poll will hang (the better part of) forever
if given a finalChangeCount of 0 (and null timeout, indicating never):

kevent64(kqfd, changelist, finalChangeCount, eventlist, maxEvents, flags, timeoutSpec)

That is probably not what the author intended.

Discovered on Apple M1 whilst working on a fix for Issue #52.

One of the test cases which provoke this bug.
The code is rough & ready, and not really ready
to be presented in public. Even though it is shy, I
told it that it is for the better good.

 test("Bind :: - IPv6 wildcard".only) {
    IOServerSocketChannel
      .open
      .evalTap(_.setOption(StandardSocketOptions.SO_REUSEADDR, java.lang.Boolea\
n.TRUE))
      .use { ch =>
        for {
          // On Scala Native 0.4.n InetSocketAddress(0) will use IPv4, WRONG!   
          isa <- IO(new InetSocketAddress("::", 0))
          _ <- IO(assert(clue(
                           isa.getAddress
                           .isInstanceOf[Inet6Address])))
          _ <- ch.bind(isa)
        } yield ()
      }
  }

I have also run into this problem while working on #35 😅