Jeff Rogers wrote: > I'm confusing myself now tho, because it certainly looks like the > threads are only ever reaped by the driver thread, which should > absolutely finish Ns_ThreadCreate before it can call it again. Conn > threads create a new thread to replace themselves when they hit > maxconns, but they don't reap at that time, so it should be ok.
Ok, I think I remembered how it happened. D is DriverThread, which reaps when it creates conn threads C is ConnThread, which upon exiting on hitting maxconns adds itself to the reap list and creates a new conn thread without reaping. "create XXX" is Ns_CreateThread, and actually starts the thread running "finish creating" is when the tid is written to the ConnData. The gap between these is the race. D: create C1 .... C1: run ... die ... add C1 to reap list ... create C2 ... C2: run ... die ... add C2 to reap list ... create C3 ... C1: finish creating C2 ... exit D: finish creating C1 ... reap (C1, C2) *splat* Of course D is queuing conns this whole time and doesn't create a thread on every call to QueueConn, so there's a few steps left out here, but I'm mostly sure this captures the scenario. As I said before, my tweak to Ns_CreateThread ensures that the 'finish creating' (tid written to ConnData) happens before the thread starts running on Linux, but other implementations (even possibly a different version of NPTL) might not get such a guarantee. And as with all race conditions, scheduling matters, so you might never see this on a 4-core box, for example. -J ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ aolserver-talk mailing list aolserver-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/aolserver-talk