Skip to content
Tcl Source Code Artifact [328f3c44bd]
Login

Artifact [328f3c44bd]

Artifact 328f3c44bd8eb60be1a15932d875d298d55687a7:

Ticket change [328f3c44bd] - New ticket [478856ffffffffff|478856ffff] <i>Fileevents not always generated</i>. by stwo on 2001-11-06 20:44:25.
D 2001-11-06T20:44:25
J assignee andreas_kupries
J cmimetype text/plain
J comment Code\sexamples\sin\sthis\smessage\sare\sTcl-pseudocode.\n\nRead\sincoming\swith:\nread\s$channel\s$read_amount\n\nSend\soutgoing\swith:\nif\s{buffering\s==\snone}\s{\n\s\s\s\sputs\s-nonewline\s$channel\s$msg\\n\n}\selse\sif\s{buffering\s==\sfull}\s{\n\s\s\s\sputs\s$channel\s$msg\n\s\s\s\s\s\s\s\sflush\s$channel\n}\n\nConditions:\nsend_amount\s=\s[string\slength\s$msg]\nread_amount\s<\ssend_amount\s<\sbuffersize\s\s(important)\nencoding\s!=\sbinary\ntranslation\s=\s?\nbuffering\s=\ssee\sabove\n\n\nIn\sthis\ssituation,\sthe\sprogram\swill\snot\salways\sget\nfileevents.\s\sAn\sindependent\s[read\s$channel\s1]\sseems\sto\nunblock\severything,\sand\sthe\sprogram\swill\skeep\sgetting\nfileevents\suntil\sit\shas\sconsumed\sall\sthe\sdata\sfrom\sthe\nbuffer.\n\n\nIf\sthis\sis\sa\sbug\sof\ssome\ssort\sand\snot\smy\sfault\sand\nisn't\salready\son\sSF\s(I\schecked\sbut\sdidn't\ssee\sanything\nlike\sit),\sthen\sI'm\sguessing\sit\shasn't\sbeen\sfound\nbecause\sthere\sare\svery\sfew\sprograms\sreading\sfrom\nchannels\sin\sthis\smanner.\s\sThe\sones\sI\shave\slooked\sat\sso\nfar\seither\suse\s[gets],\sor\s[read\sread_amount]\swhere\nread_amount\s==\sbuffersize.\n\n\nI\sam\susing\ssockets.\nThis\sbit\sof\s(serial)\scode\son\sthe\sWiki\swill\salso\sexhibit\nthis\sbehaviour.\nhttp://mini.net/tcl/1885.html\n\nAll\sthese\stests\sexhibited\sthis\sbehaviour.\s\sIn\seach\ncase,\sthe\stest\swas\sperformed\swith\sone\send\sacting\sas\sthe\nserver,\sand\sthen\sagain\swith\sthe\sother\send\sacting\sas\sthe\nserver.\n\nTcl8.3.3\s\nWin95\s-.\sWin95\s(localhost)\nWinNT\s-\sWinNT\s(localhost)\nWin95\s-\sWinNT\s(net)\nWinNT\s-\sWinNT\s(net)\nWinNT\s-\sWinNT\s(serial\s-\s2\smachines)\nWin95\s-\sLinux\s2.2.18\s(net)\nLinux\s2.2.18\s-\sLinux\s2.2.18\s(localhost)\n\nTcl8.4a3\nLinux\s2.2.18\s-\sLinux\s2.2.18\s(localhost)\n\n\n\n---------------\n\nNotes\son\s[puts]:\n\nbuffering\s==\snone\n\s\s[puts\s$data]\s!=\s[puts\s-nonewline\s$data\\n]\n\nbuffering\s==\sfull\n\s\s[puts\s$data]\s==\s[puts\s-nonewline\s$data\\n]\n\nAccording\sto\sthe\sman\spage,\s[puts]\swithout\s'-nonewline'\nwill\s*output*\sa\snewline\safter\swhatever\sit's\ssupposed\sto\noutput.\sThe\skey\sword\shere\sis\s*output*.\s\sIf\sbuffering\sis\nset\sto\snone,\sthere\scan\sbe\stwo\sactual\n'output\soperations'.\sOne\sfor\s[puts]'s\sstring,\sone\sfor\nthe\snewline.\sIf\sthe\schannel\son\sthe\sreceiving\shas\sset\sup\na\s[fileevent\sreadable],\sit\scan\sbe\scalled\stwice,\sonce\nfor\s[puts]'s\sstring,\sonce\sfor\sthe\snewline.\sHowever,\sa\n[puts\s-nonewline\s$msg\\n]\swill\sresult\sin\sonly\sone\soutput\noperation,and\sone\sfileevent\son\sthe\sreceiving\send.\nThis\sis\swith\sbuffering\s==\sfull.\nLooking\sat\sthe\sTcl\ssource,\sthe\sway\sthis\sis\sdone\sis\nmakes\ssense\sto\sme,\sperhaps\ssomething\sshould\sbe\sadded\sto\nthe\sman\spage\sto\sclarify.\n\nI\sknow\sthat\sit's\spossible\sfor\sthe\smessage\sto\sbe\sbroken\nup,\sand\sfor\sthe\sreceiver\sto\sget\sany\snumber\sof\nfileevents.\s\sBut\sit\sseems\sthat\sI\swill\salways\sget\nat\sleast\sone\sextra\sfileevent\swhere\sthe\snewline\scould\nhave\sbeen\spart\sof\sthe\sprior\sfileevent.\s\sI\swas\sa\sbit\nconfused\sby\smy\sprogram's\sbehaviour\suntil\sI\sworked\sthis\sout.\n
J foundin None
J priority 5\sMedium
J resolution None
J status Open
J submitter stwo
J subsystem 25.\sChannel\sSystem
J title Fileevents\snot\salways\sgenerated
J type Bug
K 478856ffffffffffffffffffffffffffffffffff
U stwo
Z a9d2233ba8c3fcbed2d7663ff11e37a1