0

When I use ZMQ to receive messages over TCP on mac, I got the program using 100% of CPU after some hours. By using lsof, I found kqueue got into a wired state

myprogram 56486 user   13u  KQUEUE                                     count=4, state=0x8

and the grogram keeps waiting on something.

Can someone tell me what does state 8 mean in queue?

codes details:

language: Golang

package: github.com/pebbe/zmq4

    poller := zmq.NewPoller()
    // sub is the zmq socket over TCP that receives message
    poller.Add(sub, zmq.POLLIN)
    for {
        polled, _ := poller.Poll(zeroMQTimeout)
        if len(polled) >= 1 && polled[0].Events&zmq.POLLIN != 0 {
            msg, _ := sub.RecvMessageBytes(0)
            go handleMsg(msg[1])
        } else {
            fmt.Printf("something happened at %s\n", time.Now())
        }
    }

by loging, I see that the main goroutine hangs somewhere in the for loop, and it is likely to be at sub.RecvMessageBytes.

Using a blocking receive instead of a poller does not improve the situation.

Musen
  • 1,244
  • 11
  • 23
  • And the code is? – user3666197 Oct 10 '19 at 08:44
  • @user3666197 more code details provided. Pretty cool profile pic, BTW. – Musen Oct 10 '19 at 10:07
  • 1
    I'm tempted to add a "macos" tag, is that behaviour present on other systems, too? That said, general rules require you to extract and provide a [mcve] as part of your question. An external link to some larger project is not sufficient. – Ulrich Eckhardt Oct 10 '19 at 10:29
  • @UlrichEckhardt I agree with you. However, I haven't successfully reproduce the situation, which makes this an intermediate question on kqueue status. – Musen Oct 10 '19 at 11:09

0 Answers0