<i>WinSock cores/hangs on thread or app exit</i> status still Open with 4 other changes
by
.
D 2006-03-01T05:16:02
J icomment Logged\sIn:\sYES\s\nuser_id=75003\n\n\n>\sOK.\sEasy.\s\sBut\syou\swill\shave\sto\sfollow\sme...\n\nI\swill\stry.\n\s\n>\sIf\syou\sopen\sa\ssocket,\sdon't\sclose\sit\sand\sexit\sthe\sthread\n>\s(or\sthe\sapplication,\s\sthis\swill\seventually\scome\sto\n>\s\n>\s\s\sTcl_FinalizeThread()\n>\s\n>\sThe\sTcl_FinalizeThread\swill\spull\sthread-exit\shandlers\n>\sone\sby\sone.\sOne\sof\sthem\swill\sbe\sthe\shandler\sto\stear\sdown\n>\sthe\ssocket\ssubsystem.\n\n>\sThis\sthread-exit\shandler\swill\stear-down\sthe\ssocket\sthread\sand\n>\sall\sthe\ssync\sprimitieves\sfor\sthe\ssynchronization.\sAfter\sthat\s\n>\sno\scalls\sinto\sthis\ssubsystem\sshould\sbe\sperformed.\n\nAh,\snow\sI\ssee\swhat\sproblem\sI\shad\sbefore.\sI\swas\slooking\sat\nthe\sTclpFinalizesockets\sfor\sthe\sMac\s:(\sD'oh.\n\n>\sBut....\n>\sAfter\sthat,\sthe\sTclFinalizeIOSubsystem()\sis\scalled.\n>\sThe\sTclFinalizeIOSubsystem\swalks\sthe\slist\sof\sopened\schannels,\n>\sfounds\sone\sstill\sopened\sand\stries\sto\sclose\sit\s(line\s254\sin\s\n>\sgeneric/tclIO.c).\n>\sThe\sTcl_Close\swill\sinvoke\sCloseChannel\sand\sthis\swill\scall\nTcl_CutChannel.\n>\sThe\sTcl_CutChannel\swill,\sas\sthe\slast\sstep\sof\soperation,\scall\n>\sThreadActionProc\swith\s\sTCL_CHANNEL_THREAD_REMOVE.\n>\sUnderstand?\sNow,\sthe\sThreadActionProc\swill\sresult\sin\s\n>\sTcpThreadActionprroc\s(line\s2689\swin/tclWinChan.c)\sand\swill\nstart\s\n>\susing\stsdPtr->socketListLock,\swill\sattemt\sto\sSendMessage\sto\s\n>\swindow\sowned\sby\sthe\sSocketThread\swhich\salready\sis\sexited\s\n>\sand\sso\son\sand\sso\son...\s\n\nOk,\syes\sI\ssee\sthe\sproblem\swith\sthat.\sSo\sthe\snew\sThreadAction\nstuff\sI\sdid\scaused\sthis,\sdue\sto\snot\sfully\sunderstood\nfinalize\sordering.\sMy\sapologies.\sAlthough\s...\sNo,\swe\shad\sno\nthread\sactions\sbefore,\scausing\scrashes\swhen\sthe\ssocket\smoved\naround\sbetween\sthreads.\sMy\sintegration\sfixes\sthis,\sand\nopened\sthe\sproblem\swith\sthe\sfinalize\sordering\s:(\sThanks\sfor\nfinding\sand\sfixing\sthis.\n\n\n>\sIs\sthis\snow\slittle\sbit\smore\sclear?\n\nYep.\n\s\n>\sConcerning\slazy\sinit/teardown\sof\ssocket\ssubsystem,\sthe\nanswer\sis:\syes.\n>\sIf\sthis\sis\sin\splace,\sthen\sthis\swill\sbe\sbetter\sand\smore\nlogical.\sThe\sfirst\n>\schannel/socket\sinits,\sthe\slast\sclosing\stears\sdown\sthe\nsubsystem.\n>\sThis\sis\show\sI'd\sdo\sthe\sthing\sIf\sI\shad\sdesigned\sit.\n\nNote:\sThreadActions\sare\sa\svery\snew\sthing,\sthey\swere\snot\navailable\swhen\sthe\sdriver\swas\swritten\sinitially.\n\n>\sBut\sI\swas\snot\sso\sI\n>\shad\sto\sat\sleast\srectify\sthe\sobviously\sbroken\scurrent\nimplementation.\n\nI\sguess\swe\scan\stry\sto\srewrite\sthe\sdriver\sto\suse\sof\sthe\nthread\sactions\sin\sthis\sway,\snow\sthat\sthe\sproblem\sis\sfixed.\n\nNote:\sDo\syou\shave\stest\scases\swhich\sdemonstrate\sthe\scrash\nwith\sthe\sold\simplementation\s?\sThat\swould\sbe\sgood\sto\shave\sto\nprevent\sany\sfuture\simplementation\sfrom\srunning\sinto\sthe\ssame\ntrap.\n\n
J login andreas_kupries
J mimetype text/plain
J username andreas_kupries
K 1437595fffffffffffffffffffffffffffffffff
U andreas_kupries
Z 1b6a4290a14dcc99a44d787589c263b1