Cause: In the group of a classmate said the use of zeromq when a bit of a problem, the problem described as follows "router connect a hundred thousand of client, then the router kill, restart, this time zeromq a thread 99% of the CPU, the card is dead, no longer accept the message." Use GDB tracking found is accept in the dead loop, check Baidu found the following information.
Scenario: A multithreaded server in which each thread executes an event loop. Before the event loop begins, call the Socket/bind/listen listening port, and then add the listener handle (FD) to the Epoll, then start the event loop and execute the epoll_wait. When Epoll_wait returns a valid event, it calls accept to establish a new connection for the listener event, adds the connection handle to Epoll, and calls Read/write for the normal connection for network IO and other processing logic.
Phenomenon: The server process CPU is high, almost every event loop is in accept, the client has timed out.
Cause: Ulimit-n is 65535, the process open FD has exceeded this value, causing the accept to fail to obtain the FD, and at this time the TCP connection three handshake has been established. And because Epoll uses the LT trigger mode, the connection event will be escalated by the epoll, resulting in the so-called "dead loop", in fact, the event loop is not idle, even if there is no actual network IO.
Study.
Debug Zeromq Discover Accept Dead loop