.
D 2014-03-11T10:30:14.898
T +comment 521b7229c4ea02fdea00f3a59cc09e7a0b188b92 socket\s-async\sand\sgets/puts\sstall\son\swindows\s(Ticket\s[336441ed59])\r\n\r\nThis\sis\sa\schange\sfor\sa\sproblem\swhich\sis\spretty\smuch\simpossible\sto\stest\r\nfor\sin\sthe\stestsuite,\sas\sit\sis\sa\srace\scondition\son\sa\sproblem\swith\r\nWindows\sand\sas\ssuch\scannot\sbe\sreliably\sinduced\sfrom\sthe\sTcl\sside,\r\nscript\snor\sC.\r\n\r\nThe\sproblem\saffects\sonly\ssockets\swhich\sare\sopened\s-async.\r\n\r\nAt\sthe\stime\sof\sthe\ssocket's\screation\sthe\score\swill\sremember\sthis\sfact\r\nin\sthe\sSocketState\sflags\s(SOCKET_ASYNC_CONNECT\s<SAC>)\sand\sin\sthe\r\nevents\sto\slook\sfor\swith\sselect\s(FD_CONNECT).\r\n\r\nThen,\sto\shandle\sthe\spossiblity\sthat\sthe\sscript\swrites\sto\sor\sread\sfrom\r\nthe\ssocket\sbefore\sthe\sconnection\shas\scompleted\sthe\sdriver\sfunctions\r\nTcp(Input|Output)Proc\scheck\sfor\sthe\sflag,\sand\sif\sit\sis\sstill\sset\senter\r\nWaitForSocketEvent\s(FD_CONNECT)\s<WFSE>\sto\ssync-wait\sfor\sthe\sconnection\r\nbefore\scontinuing\sto\sactually\sread/write.\r\n\r\nUnfortunately\sWindows\ssometimes\sdeigns\sto\snot\sdeliver\sFD_CONNECT,\r\nskipping\sdirectly\sto\sFD_READ|WRITE.\sWhen\sthat\shappens\sthe\sunmodified\r\nWFSE\sgets\sstuck\sin\sWFSO,\sand\shangs\sthe\sentire\sTcl\sprocess.\r\n\r\nThe\score\sactually\salready\shas\scode\sto\sdeal\swith\sthat\ssituation,\sin\r\npart.\sThis\scode\sis\sfound\sin\sthe\sSOCKET_MESSAGE\sbranch\sof\sthe\sbig\r\nswitch\sin\sSocketProc().\sWhen\sit\sfinds\s<SAC>\sin\sthe\sflags\snot\sreset\sby\r\nan\sFD_CONNECT\sevent\sit\sunconditionally\sclears\sthe\sflag\sand\sforces\san\r\nFD_WRITE\son\sother\sparts\s(My\schange\sadds\sa\scomment\sto\sthe\slocation\sin\r\nquestion,\sas\smarker).\r\n\r\nThis\scode\sworks\sfor\swhen\sWindows\sdelivers\sthe\sfirst\sevent\sbefore\sthe\r\nscript\smanages\sto\sread/write\sfrom\sthe\snew\ssocket,\sbecause\sthen\sthe\r\ndriver\sfunctions\swill\ssee\sthe\scleared\sflag\sand\snot\senter\sWFSE\sto\swait\r\nfor\sFD_CONNECT\sin\sthe\sfirst\splace.\r\n\r\nHowever,\sif\sthe\sscript\swas\sfast\senough\sto\salready\sbe\sin\sthe\sWFSE\r\nwaiting\sfor\sFD_CONNECT\sthen\sthe\smain\sthread\sis\sstuck\sand\sthe\schange\smade\sby\sSocketProc()\sdoes\snot\shelp.\r\n\r\nThe\scommit\shere\sfixes\sthat\sissue\sby\sextending\sWFSE\sto\srecognize\sthe\r\nreset\sof\sSAC\sby\sSocketProc()\sas\sa\svalid\sbreak\scondition\swhen\sit\swaits\r\nfor\sFD_CONNECT,\sthus\spreventing\sit\sfrom\sgetting\sstuck.
U oehhar
Z 945d776c87cb15a283dd01922176c7f2