Subj : Re: IOCP problem To : comp.programming.threads From : SenderX Date : Tue Jan 25 2005 04:19 am > I've setup IOCP for a named pipe server that I have. > > I create the pipes and then create the completion port and assign it to > each > pipe in turn. Then I create a couple of worker threads and each worker > sits > on GetQueuedCompletionStatus. Ok. This sounds good so far. > I then started stress testing the server and I've found that I get strange > hangs if I use more than one worker thread. Does the problem seem to only affect you if you're using more than one thread, while your stress testing? If so, it's a probably a straight forward synchronization problem ( most likely ) that could be caused by a number of different things. One reason I say this, is because you say your "stress testing" with multi-threads. Cranking up an artificially heavy-load can and will expose most of your applications race-conditions ( if any ); Memory leaks, IOCP reordering side-effect, event-driven deadlock issues, and a host of other possible problems that could be directly related to your specific issue(s). > I did some reading in this > newsgroup yesterday and somebody mentioned that with IOCP it is possible > for > one than one thread to wake up to handle the event No. One IOCP post == One Completion obtained through GQCS(). Any operation that is documented to generate an IOCP completion ( WSASend/Recv, PQCS(), ect. ) will generate only one completion event. This event could come in the form of GQCS() returning with a successful transfer of bytes, an error, a custom post, ect.. Could you post the relevant code that extracts and dispatches all of the events/errors returned from GQCS? Basically, a skeleton of your worker thread loop would help. > so I handled this by > using a "running" flag for the threads and let one thread actually handle > the event, with the others doing nothing, but sending a completion packet > back. Ok. Yeah. Post the code that implements this, and any other code that links this logic to the dequeueing and dispatching of an event from GQCS(). > I though this was working, but it still seems to act strangely when > more than one worker thread is created. It sounds a bit strange. ;) > I think I must be doing something wrong somewhere, but I'm not sure where. > I thought I had it licked when I read about the problem that somebody else > had and it was exactly the same. Could you post a link to the information you read? P.S. Here are some relevant links that you might find useful: http://www.jetbyte.com/portfolio-showarticle.asp?articleId=44&catId=1&subcatId=2 http://www.sysinternals.com/ntw2k/info/comport.shtml http://support.microsoft.com/default.aspx?scid=kb;en-us;192800 http://msdn.microsoft.com/msdnmag/issues/1000/winsock/default.aspx http://msdn.microsoft.com/msdnmag/issues/01/08/concur/default.aspx .