<i>Fileevent runs in the wrong thread</i> status still Open with 3 other changes
by
.
D 2020-03-31T14:21:31.795
J icomment Although\ssuggested\sfix\sseems\sto\swork,\sbut\sI\sam\sunsure\swe\sreally\sneed\sto\sreassign\sthe\sasync-callback\shandler\s(Tcl_DeleteFileHandler/Tcl_CreateFileHandler)\salways,\sI'm\strying\sto\sfigure\sbetter\ssolution\sout.\r\n\r\nLet\salone\s8.5\sseems\sto\shandle\sthat\scorrectly\s(and\sI\sdon't\ssee\ssuch\shandler\sreaction\sthere).\r\n\r\nAs\sfor\ssuggested\stest,\sit\sis\stoo\ssporadic\son\smy\sside\s(I\sguess\sthe\shelper\sthread\smostly\saccomplished\sthe\scontext\sswitch\sof\sthe\schannel\son\smy\smachine),\sso\shere\sis\sa\sbit\sbetter\sreproducible\stest\sscript\s(that\salso\srepeats\sconnection\sup\sto\s100\stimes):\r\n<code><pre\sstyle="padding-left:10pt">\r\nset\s::helper\s[thread::create]\r\nset\s::master\s[thread::id]\r\nputs\s"Main\sthread:\\t\\t\s$::master"\r\nputs\s"Helper\sthread:\\t\\t\s$::helper"\r\n\r\nset\s::count\s0\r\nthread::send\s-async\s$::helper\s[list\sset\s::master\s$::master]\r\nthread::send\s-async\s$::helper\s{\r\n\s\sset\s::helper\s[thread::id]\r\n\s\sproc\siteration\s{}\s{\r\n\s\s\s\sset\sfd\s[socket\s-async\s127.0.0.1\s0]\r\n\s\s\s\sthread::detach\s$fd\r\n\s\s\s\sthread::send\s-async\s$::master\s[list\stest\s$fd]\r\n\s\s}\r\n\s\siteration\r\n}\r\nproc\stest\s{fd}\s{\r\n\s\sthread::attach\s$fd\r\n\s\sfileevent\s$fd\swritable\s[list\sapply\s{{fd}\s{\r\n\s\s\s\sputs\s"Fileevent\sthread:\\t\s[thread::id]"\r\n\s\s\s\sif\s{[thread::id]\sne\s$::master}\s{\r\n\s\s\s\s\s\sthread::send\s-async\s$::master\s{puts\s"ERROR:\sinvalid\sthread,\\t\s$::master\sis\sexpecting";\sset\s::count\s100}\r\n\s\s\s\s\s\sexit;\s#\sreturn\r\n\s\s\s\s}\r\n\s\s\s\sclose\s$fd\r\n\s\s\s\sincr\s::count\r\n\s\s\s\sthread::send\s-async\s$::helper\siteration\r\n\s\s}}\s$fd]\r\n}\r\nputs\s**wait**\r\nwhile\s{$::count\s<\s100}\s{\svwait\s::count\s}\r\nthread::release\s-wait\s$::helper\r\n</pre></code>
J login sebres
J mimetype text/x-fossil-wiki
K f583715154c6f33d621418e8c9f6dfae5cc5ebc4
U sebres
Z ed61a65e9e13ec9f1528340b4abd3b04