Skip to content
Tcl Source Code Artifact [1791748018]
Login

Artifact [1791748018]

Artifact 17917480180627a01fe1672bfac842582d70e812:

Ticket change [1791748018] - Ticket [3545363fffffffff|3545363fff] <i>socket/vwait hang in io-53.10 and socket.test</i> status still Open with 4 other changes by twylite on 2012-07-20 17:38:22.
D 2012-07-20T17:38:22
J icomment I've\suploaded\std-patch-3545363-1.diff,\sa\spatch\sagainst\sbranch\s\sbug-3545363\scheckout\sa1fbf5e7.\s\sIt\spasses\sall\s(relevant)\stests\son\sWindows\s7\s64-bit\s(32-bit\stclsh)\swith\sno\scrashes\sor\shangs.\n\nBug\s3545363\sis\scaused\sby\smultiple\scode\slocations\streating\sinfoPtr->sockets\sas\sa\ssingle\sfd\srather\sthan\sa\slinked\slist\sof\sfds.\s\sFor\sconnected\ssockets\s(i.e.\snot\sserver\slistening\ssockets)\sthis\sis\sa\svalid\sassumption;\sbut\sother\scode\slocations\ssuch\sas\sTcpCloseProc()\sand\sSocketProc()\smust\shandle\sall\ssocket\stypes\sand\streat\sinfoPtr->sockets\sas\sa\slist.\n\nTcpCloseProc()\swas\sleaking\smemory\sby\snot\sfreeing\sthe\sinfoPtr->sockets\slinked\slist.\s\sAdding\sthe\sckfree()\sexposed\sa\sbug\swhere\sTcpAccept()\swas\sdereferencing\sa\sreleased\spointer.\s\sIf\sTcpAccept()\saccepts\sthe\ssocket\sand\scalls\sthe\sinfoPtr->acceptProc()\sthen\sTcl\scode\s(the\s-server\sscript)\sis\sevaluated.\s\sIn\ssocket_any-2.10\sthe\sTcl\sscript\scloses\sthe\sserver\ssocket\s(frees\sinfoPtr->sockets\sand\sinfoPtr).\s\sAfter\sthe\seval,\sTcpAccept()\sreturns\sup\sthe\sstack\sto\sSocketEventProc()\swhich\sis\sstill\swalking\sfds\s(now\sfreed).\s\sBefore\sadding\sckfree()\sto\sTcpCloseProc()\sfds\swas\sleaked\sso\sthe\sfor\sloop\scalled\sTcpAccept()\sagain\swhich\swould\sget\sINVALID_SOCKET\sand\swrite\stwo\svalues\sinto\sfds->infoPtr\s(previously\sfreed),\sbut\sthis\soverwrite\swasn't\scausing\sa\scrash\s(just\sinvisible\scorruption).\n\nThis\shas\sbeen\sfixed\sby\shaving\sthe\saccept\slogic\sterminate\sthe\sloop\safter\sone\ssocket\sis\saccepted.\s\sTo\sensure\slocking\sis\shandled\scorrectly\sthe\saccept()\sand\sinfoPtr->readyEvents\smanipulation\shas\sbeen\smoved\sto\sSocketEventProc(),\swith\sTcpAccept()\sjust\shandling\sthe\ssetup\sof\sthe\sclient\schannel\safter\sthe\ssocket\sis\saccepted.\s\sHaving\sall\sthe\slogics\sand\sreadyEvents\smanipulation\sin\sone\splace\sshould\salso\simprove\scode\smaintainability.\n\nSlight\srefactoring\sin\sCreateSocket()\sand\sNewSocketInfo()\sto\sextract\scommon\slogic\sto\sadd\sto\sthe\sinfoPtr->sockets\slinked\slist,\snow\sin\sAddSocketInfoFd().\s\sThis\salso\smakes\sclearer\swhat\sCreateSocket()\sis\strying\sto\sdo.\n
J login twylite
J mimetype text/plain
J username twylite
K 3545363fffffffffffffffffffffffffffffffff
U twylite
Z 7aba42d277a24d0cc1262d2f89b78c5c