This is a draft implementation of a lockless work queue to address the contention observed when the server is processing connections. However, the design of the lockless queue means it is unsafe to free a node after it is dequeued as another thread could be using it. I have noticed this behaviour intermittently, where a thread tries to access a node that has been freed, breaking the linked list.
Possible solutions to this problem:
Use a double word compare and swap, but this is not available on commonly used hardware.
Use node pointer modification counters to only free a node when no thread is using it.