<i>write-only nonblocking refchan and Tcl internal buffers</i> status still Open with 3 other changes
by
.
D 2024-03-30T12:02:18.651
J icomment A\schannel\swritable\sevent\sis\sbeing\sgenerated\sby\sa\spiece\sof\scode\son\sa\speriodic\sbasis\swith\sno\sknowledge\sof\sthe\schannel\sstate\sand\swhether\sit\sis\sactually\swritable\sor\snot.\sThis\sis\sso\sbroken\sas\sto\sbe\sself-evident\sin\smy\sopinion\sand\sshould\sneed\sno\sdebate\sbut\sto\sanswer\sNathan's\spoints\sbelow.\r\n\r\nThe\sfailure\sof\ssocket-14.11.0,\smarking\sa\sconnection\swhen\sit\sis\snot\syet\sopen,\sor\s\sis\snot\sa\strivial\smatter.\sThat\sspecific\sscenario\sis\sexactly\sone\sthat\smight\sbe\sused\sto\simplement\sa\sport\sscanner\s(which\salways\soperate\sasynchronously\sfor\sobvious\sreasons).\sThe\scurrent\strunk\simplementation\swill\sshow\sall\sports\sopen\seven\swhen\sthey\sare\snot!\sAnd\snote\sthe\sscript\sis\snot\saware\sthe\schannel\sis\sbroken\sas\syou\sseem\sto\sthink!\r\n\r\nConsider\sthe\scomplementary\scase\swhere\sthey\sare\sopen.\sThe\sevent\sfires\sBEFORE\sthe\sTCP\sconnection\sactually\scompletes,\sthe\swrite\shandler\sruns\sand\swrites\sconnection\sdetails\sto\ssyslog.\sNot\san\suncommon\sscenario\sbut\sthe\sfconfigure\sthat\sretrieves\saddress/port\sinformation\sreturns\sempty\sstrings\sbecause\sthe\sconnection\shas\snot\scompleted\smaking\sthe\slogging\suseless.\r\n\r\nA\sthird\sexample\s-\sadmittedly\sa\scode\sinspection\sbased\sconjecture;\sI\shave\snot\stried\sthis\sas\sI\sdon't\shave\sa\smultihomed\smachine.\sTcl's\ssocket\simplementation\sis\ssmart\senough\sthat\sif\sthe\sdestination\shosts\sresolves\sto\smultiple\saddresses,\sit\swill\stry\seach\sin\sturn\suntil\sone\ssucceeds.\sThe\swrite\sevent\swill\strigger\son\sthe\sfirst\s*attempted*\sconnection\swhich\smay\sactually\sfail\swhen\sa\ssubsequent\scandidate\ssucceeds.\r\n\r\nNow\swith\srespect\sto\sthe\s`-async`\soption,\slet's\signore\stwapi\sbecause\sit\ssimply\sclones\sTcl\ssocket\ssemantics.\sThe\stwo\sillustrative\sfragments\syou\sgave\sare\svery\sdifferent\ssemantics.\sWhen\sthe\s-async\soption\sis\sspecified,\sthe\scommand\sreturns\swithout\swaiting\sfor\sthe\sTCP\sconnect\sto\sbe\scompleted\sand\sconnection\sopen.\sThe\sapplication\scan\scontinue\sother\swork\suntil\sthe\sconnection\sis\sopen.\sWithout\sthe\s-async\soption,\sthe\sapplication\sis\sblocked\sfrom\sany\sother\swork\suntil\sthe\sconnection\sis\sopen,\swhich\smay\sbe\sseveral\sor\seven\stens\sof\smilliseconds.\sChanging\ssocket\swith\sfconfigure\s-blocking\s0\scannot\schange\sthis\s(in\sthe\ssecond\sexample!).\s-async\sdoes\snot\smake\sthe\ssocket\snon-blocking,\sand\s-blocking\s0\sdoes\snot\smake\sthe\sconnection\sasynchronous\s(how\scan\sit\swhen\sit\scan\sonly\sbe\sdone\safterward!).\sSo\sI\scompletely\sfail\sto\sunderstand\syour\scomment\sof\sredundancy.\r\n\r\nThe\sfundamental\sproblem\shere\sis\sthat\sthe\sreflected\schannel\sframework\shas\sincomplete\ssupport\swhen\sit\scomes\sto\sevent\sdriven\sI/O.\sAll\schannel\sdrivers\sI\shave\swritten\sor\sseen\shave\stwo\scomponents.\sThe\sfirst\sis\sthe\schannel\sdriver\sitself\s-\sin\sthis\scase\sthe\stclrchannel\sdriver.\sThe\ssecond\scomponent\sof\sthe\sdriver\shooks\sinto\sTcl\sevent\sprocessing\svia\sthe\sTcl_EventSetupProc\s/\sTcl_EventCheckProc\scallbacks.\sThese\sare\swhere\sthe\schannel\simplementations\sgenerate\snotification\sevents\sbut\sthe\srefchan\sframework\shas\sequivalent.\sThe\scorrect\sfix\swould\sbe\sto\sadd\sthe\sequivalent\sfacilities\sto\srefchan,\sor\salternatively\senhance\sthe\schannel\sdriver\sAPI\s(and\srefchan)\sto\sbe\sable\sto\sexchange\sstate\sinformation\sthat\swould\slet\sthe\scommon\schannel\scode\smake\sproper\sdecisions\sthat\sdepend\son\schannel\sstate.\r\n\r\nBoth\sare\slikely\sto\sbe\snon-trivial\sand\stricky\sto\sget\sright,\spossibly\swhy\sthey\swere\snever\simplemented,\sand\sprobably\snot\sfeasible\sin\sthe\s9.0\stime\sframe.\r\n\r\nAs\san\salternative\ssolution,\sI\spropose\sturning\soff\sbuffering\sfor\srefchans\s(either\svia\san\sinternal\s-buffering\snone\sor\sa\s-buffersize\s1).\sThis\sforces\scalls\sto\srefchans\salways\sto\sbe\spassed\sdown\sto\sthe\srefchan\sscript\swhich\sis\sthen\sresponsible\sfor\sgenerating\sevents\sexactly\sas\sNathan's\stest\scode\sdoes.\sThis\sexperiment\sis\sin\sbranch\s[apn-bug-de232b49f2](https://core.tcl-lang.org/tcl/timeline?r=apn-bug-de232b49f2).\sThere\sare\ssome\sside\seffects\sthat\sI\swill\sdetail\slater\sbut\sfor\snow,\sall\stests\spass\s(both\ssocket-14.11.0\sas\swell\sas\sio-44.6\swhich\stests\sNathan's\scoroutine\sbased\sdriver).
J login apnadkarni
J mimetype text/x-markdown
K de232b49f26da1c18e07513d4c7caa203cd27910
U apnadkarni
Z da1b104a01f21c94d668680f4061f45c