Hey, > But if the main thread waits for the conditional variable, who drives > the > main event loop? > > Preparing the pipe fd for notifying max conn, and watch it by the > event loop > should be the way.
I should've been more purposefully vague; "lets find the easy way to make it wake up faster". Using the pipe fd sounds like the right idea there. > +1. Never saw the application which call listen(fd, 0), to drop the > new > connection. I thought if OS kernel reaches the max backlog, then it > starts > dropping the new packets. So no need to handle such case in > application, > don't you? (repeating from IRC for posterity): I like shoving an "ERROR: Too many connections" down the pipe before closing it. Gives client authors the chance to throw useful errors for the developer. Otherwise it's likely to manifest as failed gets/sets with no errors. -Dormando