<i>missing file events on server socket under Windows</i> status still Open with 4 other changes
by
.
D 2001-03-23T08:39:22
J icomment Logged\sIn:\sYES\s\nuser_id=178287\n\nI\sbelieve\sI\sfinally\smanaged\sto\strack\sdown\sthis\selusive\sbug.\n\nBackground:\sTcl\suses\sWSAAsyncSelect()\s(winsock\sAPI)\sto\stell\s\nwinsock\sto\scall\sa\sparticular\sfunction\s(SocketProc())\swhen\s\nan\sevent\ssuch\sas\sincoming\sdata\soccurs.\s\sThis\sfunction\s\nbasically\schecks\swhat\ssort\sof\sevent\soccurred\sand\ssets\ssome\s\nflags\sto\sbe\schecked\slater\sin\sTcl's\sidle/event\shandling\sloop.\nEventually\sthis\sloop\scalls\sanother\sfunction\s(SocketEventProc\n())\sthat\sverifies\sthat\sthe\scondition\sfor\sthe\sevent\s(well,\s\nFD_READ\sevents,\sat\sleast)\sis\sstill\smet\sbefore\ssignalling\s\nback\sto\sTcl\s(via\sTcl_NotifyChannel())\sto\strigger\sthe\s\nfunction\swe\sspecified\s(via\sTcl_CreateChannelHandler())\sas\s\nour\sown\shandler\sfor\sthe\sevent.\n\nNow,\sin\svarious\splaces\sthe\sTcl\ssocket\sdrivers\sdisable\sthe\s\nWSAAsyncSelect()\shandler\sbefore\sdoing\ssome\sthings\sand\sre-\nenabling\sit.\s\s(Re-enabling\salso\scauses\sany\sexisting\s\nconditions\sto\sre-generate\sevents\s--\sie.,\sthe\shandler\s\nspecified\sto\sWSAAsyncSelect()\sis\scalled).\s\sBefore\sthis\s\nverification\sstep\smentioned\sabove\s(involving\sa\scall\sto\sthe\s\nregular\snon-event-driven\sselect()\sfunction)\sis\sone\ssuch\s\nplace\swhere\sthe\sWSAAsyncSelect()\shandler\sis\sdisabled\ntemporarily.\n\nHowever,\sthe\scode\swas\ssuch\sthat\sit's\sonly\sRE-enabled\safter\s\nthe\sselect()\scall\swhen\sthe\ssocket\sno\slonger\shas\sdata\sto\sbe\s\nread\s(select()\sreturns\s0).\sIf\sthere's\sdata\son\sthe\ssocket\s\n(because,\sperhaps,\smultiple\spackets\scame\sin\svery\squickly,\s\nbefore\sthe\schannel\shandler\scould\sread\sthe\sfirst\sand\sclear\nthe\sevent),\sthen\sthe\sWSAAsyncSelect()\shandler\sis\sapparently\s\nnot\sre-enabled.\n\nI\ssuspect,\sthough\sI\shaven't\sverified,\sthat\sin\s8.0.5\sand\s\nearlier\sthe\sproblem\sdidn't\soccur\sfor\sone\sof\sa\sfew\spossible\s\nreasons:\n\n1.\sThe\sparticular\scodepath\sthat\sleft\sthe\sevent\shandler\s\ndisabled\swas\sbasically\snever\scalled\s(ie.,\sat\sthis\spoint\s\nthere\swas\snever\sdata\sleft\sto\sbe\sread\sand\sselect()\swould\s\nalways\sreturn\s0).\n\n2.\s-Or-\sthe\sWSAAsyncSelect()\shandler\swas\sbeing\sre-enabled\s\nlater\son\sin\sthe\sevent\shandling\sloop\sbut\sisn't\sin\slater\s\nversions.\n\n3.\s-Or-\s8.0.5\sand\searlier\scalled\sWSAAsyncSelect()\sdirectly\s\nat\sthis\spoint,\srather\sthan\scalling\sSendMessage()\sto\strigger\s\na\slater\scall\sto\sWSAAsyncSelect()\sto\sre-enable\sthe\shandler,\s\nwhich\smay\scause\sa\srace\scondition\sof\ssorts.\s\s(Though\sin\sthis\s\ncase,\sthe\spatch\sbelow\swould\sprobably\sjust\sbe\slucky\sthat\sit\s\nworks\sfor\sme).\n\nAt\sany\srate,\shere's\sthe\schange\sthat\sworked\sfor\sme\sto\sfix\s\nthis\sproblem\s(in\s"diff\s-c"\sformat;\swill\salso\supload\sto\s\npatches\ssection).\s\sThe\slittle\sprogram\sI\swrote\sto\srecreate\s\nand\sdebug\sthis\sproblem\sscreams\salong\shappily\swithout\sany\s\napparent\sdropping\sof\sevents.\sJust\sone\sline\sthat's\sinside\san\s\nelse\s{}\sblock\sthat\sapparently\sshouldn't\sbe\s(the\sSendMessage\n()\scall,\swhich\striggers\sa\slater\scall\sto\sWSAAsyncSelect(),\s\nis\smoved\sso\sit\sis\scalled\sregardless\sof\sthe\sselect()\sreturn\s\nvalue):\n\n<pre>\n***\s./orig/tcl8.2.3/win/tclWinSock.cSun\sAug\s\s1\s15:09:29\s\n1999\n---\s./tcl8.2.3/win/tclWinSock.cThu\sMar\s22\s16:44:48\s2001\n***************\n***\s853,862\s****\n\s\sif\s((*winSock.select)(0,\s&readFds,\sNULL,\sNULL,\s\n&timeout)\s!=\s0)\s{\n\s\s\s\s\s\smask\s|=\sTCL_READABLE;\n\s\s}\selse\s{\n-\s\s\s\s\sSendMessage(tsdPtr->hwnd,\sSOCKET_SELECT,\n-\s\s\s\s\s(WPARAM)\sSELECT,\s(LPARAM)\sinfoPtr);\n\s\s\s\s\s\sinfoPtr->readyEvents\s&=\s~(FD_READ);\n\s\s}\n\s\s\s\s\s\s}\n\s\s\s\s\s\sif\s(events\s&\s(FD_WRITE\s|\sFD_CONNECT))\s{\n\s\smask\s|=\sTCL_WRITABLE;\n---\s853,862\s----\n\s\sif\s((*winSock.select)(0,\s&readFds,\sNULL,\sNULL,\s\n&timeout)\s!=\s0)\s{\n\s\s\s\s\s\smask\s|=\sTCL_READABLE;\n\s\s}\selse\s{\n\s\s\s\s\s\sinfoPtr->readyEvents\s&=\s~(FD_READ);\n\s\s}\n+\sSendMessage(tsdPtr->hwnd,\sSOCKET_SELECT,\n+\s(WPARAM)\sSELECT,\s(LPARAM)\sinfoPtr);\n\s\s\s\s\s\s}\n\s\s\s\s\s\sif\s(events\s&\s(FD_WRITE\s|\sFD_CONNECT))\s{\n\s\smask\s|=\sTCL_WRITABLE;\n</pre>\n
J login ashmael
J mimetype text/plain
J username ashmael
K 219205ffffffffffffffffffffffffffffffffff
U ashmael
Z 8ef2061c05ef018ef22666d0a8498806