Skip to content
Tcl Source Code Artifact [400771fad1]
Login

Artifact [400771fad1]

Artifact 400771fad18b6664648d7a3fad42deef7fe6c06d:

Ticket change [400771fad1] - Ticket [2827000fffffffff|2827000fff] <i>tcl incorrectly reports eof to application</i> status still Open with 4 other changes by andreas_kupries on 2009-07-28 10:01:09.
D 2009-07-28T10:01:09
J icomment \nBehaviour\sof\stestRefChan.tcl\s...\n\nNOTE:\sThe\simplementation\sof\s'watch'\swas\smissing.\sThis\sis\scrucical.\sYou\n\s\s\s\s\s\shave\sto\slook\sat\sthe\swatch\scalls\sto\ssee\sif\s_you_\s(The\src\schannel\n\s\s\s\s\s\simplementation)\sis\sexpected\sto\sgenerate\sevents,\sor\snot.\sSee\n\s\s\s\s\s\ssteps\s3,\s7,\sand\s15.\n\nNOTE\s2:\sThe\shandling\sof\seof\sin\sgetter/reader\sfell\sthrough\sto\sregular\n\s\s\s\s\sread,\sI\sadded\sexit\scommands\sthere.\n\nNOTE\s3:\sThe\smodified\stest\sscript\sis\sattached.\n\n(.1)\sCreate\schannel\sRC\n\n(.2)\sSet\schannel\sRC\sto\sblocking\s-->\s\n\n(.3)\sSet\sup\sa\sfileevent\sreceiver\sfor\sRC\s->\sgetter.\sThis\sinvokes\n\s\s\s\s\src::watch,\sasking\sfor\sread\sevents,\sthis\sposts\sa\sreadable\sevent.\n\n(.4)\sThe\sreadable\sevent\sis\sreceived\sand\s'getter'\scalled.\n\n(.5)\sThe\s'gets'\scommand\sin\s'getter'\sfinds\sempty\sbuffers\sand\scalls\sthe\n\s\s\s\s\schannel's\sinputProc\s->\sReflectInput\s->\sprocedure\src::read.\n\n(.6)\src::read\sreturns\s221\sbytes,\s10\slines\sof\s'111...',\san\sempty\sline,\n\s\s\s\s10\slines\sof\s'222...'.\n\n(.7)\sAs\spart\sof\sthe\sinputProc\sprocessing\sinterest\sin\sread-events\sfrom\n\s\s\s\s\sthe\schannel\sis\sdisabled.\sWe\shave\sdata\sin\sthe\sTcl\sbuffers,\sthese\n\s\s\s\s\swill\sget\sflushed\sfirst.\sNo\sneed\sto\sask\sfor\sevents\sfrom\sthe\sOS\n\s\s\s\s\s(===\sthe\sreflected\schannel).\n\n(.8)\sThe\sIO\score\sreturns\sthe\sfirst\s'111...'\sline\sas\sresult\sof\s'gets'.\n\n(.9)\sThe\sIO\score\sgenerates\sits\sown\sfileevents,\sbased\son\stimers,\sto\n\s\s\s\s\sflush\sthe\sdata\sleft\sover\sin\sthe\sTcl\sbuffers\s(remaining\s'111...'\n\s\s\s\s\setc.\slines.\n\n(10)\sPer\s(.9)\s'getter'\sis\scalled,\sthe\scycle\srepeats.\n\n(11)\sAt\sthe\s11th\scall\s'gets'\sreturns\san\sempty\sline,\sand\sthe\sevent\n\s\s\s\s\sreceiver\sswitches\sto\s'reader'.\sThis\sdoesn't\schange\sthat\sdata\sin\n\s\s\s\s\sthe\sbuffers\sis\sflushed\svia\stimer-based\sfileevents,\sthere\sare\n\s\s\s\s\sstill\sthe\s'222...'\slines\setc.\n\n(12)\s'reader'\sis\scalled,\sfor\sthe\sfirst\sof\sthe\sevents\safter\sthe\sswitch-over.\n\n(13)\sIt\stries\sto\s[read\s10000].\sAs\sonly\sless\sbytes\sthan\sthat\sare\sleft\n\s\s\s\s\sin\sthe\sTcl\sbuffers\sthe\schannel's\sinputProc\sis\scalled\sto\ssdee\sthat\n\s\s\s\s\swe\sfill\sit\sup\swith\smore\sdata\s=>\sReflectInput\s=>\src::read.\n\n\s\s\s\s\sThis\sis\sthe\sso-called\sbogus\scall,\sand\sit\sis\snot\sbogus,\sbut\n\s\s\s\s\scompletely\scorrect.\n\n(14)\sThis\scall\sreturns\s0\sbytes,\sand\sthe\sEOF\sflag\sin\sthe\schannel\sis\sset.\n\n(15)\sThe\sIO\score\snow\s__re-enables__\sinterest\sin\sthe\s'readable'\sevents\n\s\s\s\s\sbecause\sall\sdata\sin\sthe\sTcl\sbuffers\swill\sbe\sdelivered\sto\sthe\n\s\s\s\s\sscript,\sand\sany\smore\sdata\swill\shave\sto\scome\sfrom\sthe\schannel\n\s\s\s\s\sitself.\s<=>\sAny\smore\sevents\shave\sto\scome\sfrom\sthe\schannel\sas\n\s\s\s\s\swell,\sthe\stimer-based\sevents\sare\sstopped.\n\n(16)\sThe\sread\scall\sreturns\sthe\sremaining\sbytes\sfrom\sthe\sTcl\sbuffers.\n\nAt\sthis\spoint\sthe\sscript\sstops\sfor\sme\swith\n\ncan't\swait\sfor\svariable\s"forever":\swould\swait\sforever\n\nbecause\sthe\sRC\schannel\simplementation\sdid\snot\sset\sthings\sup\sto\sproduce\nits\sown\sevents,\sdespite\sbeing\sasked\sto\sin\sstep\s15,\svia\src::watch.\n\nThe\smoment\swe\sdo\sthis\sthe\sposted\sevent\scauses\sanother\scall\sof\s'reader'\nsa\sstep\s(17),\swhich\sthen\shandles\sthe\seof\scondition\sby\sclosing\sthe\nchannel,\swhich\sdisables\sevents,\sfinalizes,\sand\sexits.\sThe\slast\sis\nsomething\sI\sadded\sto\sthe\sscript.\n\n\n\nNow,\swhat\sdoes\sthat\smean\sfor\sthe\sidentity\srefchan\s?\n\nIt\shas\sto\skeep\strack\sof\swhen\sthe\sTcl\sIO\score\swants\sevents\sfrom\sit\sor\nnot.\n\nIf\sit\sreceives\sa\sfileevent\sfrom\sthe\ssocket\sit\sis\sconnected\sto\sat\sa\ntime\sthe\score\sis\snot\sinterested\sin\sidentity\sevents,\sthen\sthis\sevent\nhas\sto\sbe\sremembered\sin\sflags\s(one\sper\sread\sand\swrite),\sbut\snot\sbe\nacted\son,\si.e\sno\sposting\sforward\sto\sthe\score.\n\nOnly\swhen\sevents\sare\senabled\sagain\sfor\sthe\sidentity\schan\sthe\sflags\nhave\sto\sbe\schecked,\sand\sif\swe\sgot\sevents\sfrom\sthe\ssocket\swe\spost\s_one_\nevent\sforward.\n\n
J login andreas_kupries
J mimetype text/plain
J username andreas_kupries
K 2827000fffffffffffffffffffffffffffffffff
U andreas_kupries
Z a56a77878e053448ac1af23bdbc2f5db