Comment 4 for bug 819473

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

I've tracked down the problem and implemented a fix. The issue is that Xvnc in inetd mode detects whether it is run as "wait" or "nowait" by checking if the inetd socket has a valid peer name with getpeername(). If it has a valid peer name then it assumes nowait mode, otherwise it assumes wait mode. But this is unreliable, because if it is run in nowait mode and a client connects and disconnects very quickly then the socket will no longer have a valid peer name when Xvnc checks and it will mistakenly use wait mode. The 100% CPU results from repeatedly trying to call accept() on the socket in the select loop.

My solution is to instead detect wait vs. nowait via getsockopt(..., SOL_SOCKET, SO_ACCEPTCONN, ...), which works reliably in both modes.