Artifact
45d366189585c34b0c40d68080380ec6eb7b7a85:
Ticket change
[45d3661895]
- Closed ticket
[218203ffffffffff|218203ffff]: <i>fcopy -command, which is supposed to run in the background, </i> plus 9 other changes
by
dgp on
2001-01-26 08:48:59.
D 2001-01-26T08:48:59
J assignee dgp
J foundin obsolete:\s8.4a2
J icomment I've\sre-opened\sthis\s[fcopy]\sbug\ssince\sit\sis\sthe\ssame\sone\nthat\sbroke\stclhttpd3.2.1\sand\sthe\sTCT's\sTIP\sdrafting\sand\narchive\sservice.\n\nHere\sare\sthree\sscripts\sthat\sdemonstrate\sthe\sbug.\nFirst\sa\sserver\sprogram:\n\n#\sFILE:\sserver.tcl\nproc\sconnect\s{socket\sip\sport}\s{\n\s\s\s\sset\spipe\s[open\s[list\s|\s[info\snameofexecutable]\scgi.tcl\s2>@\sstderr]\sr+]\n\s\s\s\sfconfigure\s$pipe\s-blocking\s0\n\s\s\s\sfileevent\s$socket\sreadable\s[list\sstartcopy\s$pipe\s$socket]\n}\nproc\sstartcopy\s{pipe\ssocket}\s{\n\s\s\s\sif\s{[gets\s$socket\ssize]\s<\s0}\s{\n\s\s\s\s\s\s\s\sif\s{[eof\s$socket]}\s{exit}\n\s\s\s\s\s\s\s\s#\sNot\sEOF;\sassume\sblocked\s-\swait\sand\stry\sagain\n\s\s\s\s\s\s\s\sreturn\n\s\s\s\s}\n\s\s\s\s#\sForce\sinput\sbuffer\sbigger\sthan\swhole\smessage\n\s\s\s\s#\s(bigger\sthan\soutput\schannel\sflush\sthreshold)\n\s\s\s\sfconfigure\s$socket\s-buffersize\s[expr\s{$size\s+\s1}]\n\s\s\s\sfileevent\s$socket\sreadable\s{}\n\s\s\s\sputs\sstderr\s"server:\scopying\s$size\sbytes\sto\scgi..."\n\s\s\s\sfcopy\s$socket\s$pipe\s-size\s$size\s-command\s[list\sdonecopy\s$size]\n}\nproc\sdonecopy\s{size\swritten\s{msg\s{}}}\s{\n\s\s\s\sputs\sstderr\s"server:\scopied\s$written\sbytes\sto\scgi."\n\s\s\s\sif\s{$size\s!=\s$written}\s\s{\n\s\s\s\s\s\s\s\sputs\sstderr\s"server:\sbytes\swritten\s($written)\s!=\sbytes\sread\s($size)"\n\s\s\s\s}\n\s\s\s\sif\s{[string\slength\s$msg]}\s{\n\s\s\s\s\s\s\s\sputs\sstderr\s"Copy\serror:\s$msg"\n\s\s\s\s}\n\s\s\s\sset\s::done\s1\n}\nsocket\s-server\sconnect\s5000\nvwait\sdone\n\nThe\sserver\sprogram\sspawns\sa\s"CGI"\sprocess:\n#\sFILE:\scgi.tcl\nputs\sstderr\s"cgi:\sreading\sdata..."\nset\sdata\s[read\sstdin]\nputs\sstderr\s"cgi:\sreceived\s[string\slength\s$data]\sbytes"\n\nAnd\sthere\sis\sa\sclient\sprogram:\n#\sFILE\sclient.tcl\n#\n#\sCreate\smessage\slonger\sthan\sCGI\spipe\sflush\sthreshold:\nset\sdata\sa\n#set\sexp\s13\s\s\s\s\s;#\sLiunx\s-\sflush\sthreshold\sis\s4096\nset\sexp\s15\s\s\s\s\s\s;#\sSolaris\s-\sflush\sthreshold\sis\s16384\nwhile\s{[incr\sexp\s-1]}\s{\n\s\s\s\sset\sdata\s$data$data\n}\nappend\sdata\sb\s\s\s;#\sExceed\sthreshold\sby\s1\nset\ss\s[socket\slocalhost\s5000]\nfconfigure\s$s\s-buffering\snone\nputs\s$s\s[string\slength\s$data]\nputs\s-nonewline\s$s\s$data\nflush\s$s\n#\sWait\sas\smany\smilliseconds\sas\scaller\sasks\nafter\s[lindex\s$argv\s0]\n\nFirst\sstart\sthe\sserver\sin\sone\sshell\swindow:\n\s\s\s\s\s\s\s\s$\stclsh\sserver.tcl\n\nThen\sstart\sthe\sclient\sin\sanother\sshell\swindow.\nThe\sclient\stakes\san\sargument\s--\sthe\snumber\sof\nmilliseconds\sto\swait\sbetween\ssending\sdata\sto\nthe\sserver\sand\sexiting\s(closing\sthe\sconnection).\n$\stclsh\sclient.tcl\s0\n\nBack\sin\sthe\sserver\swindow,\ssee\sthese\smessages:\nserver:\scopying\s4097\sbytes\sto\scgi...\ncgi:\sreading\sdata...\nserver:\scopied\s0\sbytes\sto\scgi.\nserver:\sbytes\swritten\s(0)\s!=\sbytes\sread\s(4097)\ncgi:\sreceived\s4097\sbytes\n\nNote\sthat\sthe\sserver\sbelieves\sit\ssent\s0\sbytes\son\nto\sthe\scgi\sprocess,\sthough\sthe\scgi\sprocess\sknows\nit\sreceived\sall\s4097\sbytes.\n\nTry\sit\sagain,\sthis\stime\swith\sa\sdelay\sin\sthe\sclient:\n$\stclsh\sclient.tcl\s10000\n\nServer\smessages:\nserver:\scopying\s4097\sbytes\sto\scgi...\ncgi:\sreading\sdata...\n<10\ssecond\sdelay>\nserver:\scopied\s0\sbytes\sto\scgi.\nserver:\sbytes\swritten\s(0)\s!=\sbytes\sread\s(4097)\ncgi:\sreceived\s4097\sbytes\n\nThe\sserver\sis\sstill\sconfused\sabout\show\smany\sbytes\sit\ncopied\sover\sto\sthe\scgi\sprocess,\splus\sit\shangs\sthe\swhole\ntime\sthe\sclient\sprogram\skeeps\sthe\ssocket\sconnection\sopen.\nImagine\sthe\strouble\swhen\sclient.tcl\sis\sreplaced\swith\sa\nweb\sbrowser\sthat\sdoes\snot\sclose\sits\sconnection\safter\nsending\sPOST\sdata!\s\sThis\sis\swhy\sI\ssaw\sNetscape\s4.74\s\nspinning\sits\swheel\seach\stime\sI\stried\sto\ssubmit\snew\sTIP\nrevisions!\n\nThe\sproblem\scan\sbe\stracked\sto\sbad\smanagement\sof\sthe\scount\nof\sthe\snumber\sof\sbytes\scopied\sin\sthe\sCopyData()\sroutine\sin\ngeneric/tclIO.c.\s\sA\spatch\scorrecting\sthe\sproblem\sis\son\nthe\sway.\n\nThis\sbug\sdates\sback\sall\sthe\sway\sto\sTcl\s8.0,\sas\slong\sas\n[fcopy]\shas\sbeen\saround.\s\sIn\sparticular,\sit\sis\sin\sboth\n8.3.2\sand\s8.4a2.\s\sThe\snext\sreleases\sof\sboth\s8.3\sand\s8.4\nought\sto\sinclude\sthe\sfix.\n\n\n\n
J login dgp
J mimetype text/plain
J priority 7\sHigh
J resolution None
J status Closed
J subsystem 62.\s(unused)
J username dgp
K 218203ffffffffffffffffffffffffffffffffff
U dgp
Z 93a3c8f2acd281e787c376d3bc517274