Skip to content
Tcl Source Code Artifact [818a8c8896]
Login

Artifact [818a8c8896]

Artifact 818a8c889662cfcacd1b55d9b8c3453bfc39c91a:

Ticket change [818a8c8896] - New ticket [3574493fffffffff|3574493fff] <i>TclpFinalizeSockets hangs on windows </i>. by ralfixx on 2012-10-04 15:06:15.
D 2012-10-04T15:06:15
J assignee nobody
J cmimetype text/plain
J comment This\sseems\srelated\sto\sthe\schange\sintroduced\sby\s\sID:\s1437595.\n\nWhen\srunning\sthe\sattached\scode\son\sLinux,\sthe\sprogram\sopens\sthe\sserver\nsocket,\swaits\sone\ssecond\sand\sthen\sexits\sas\sexpected.\n\nWhen\srunning\sthe\ssame\scode\son\sWindows-7\sagainst\stcl\s8.3,\sthe\sprogram\nbehaves\sas\sabove\son\sLinux.\n\nWhen\srunning\sthe\ssame\scode\son\sWindows-7\sagainst\stcl\s8.5\s(Activestate,\s\nor\snon-threaded\smakes\sno\sdifference)\sthe\sprogram\sblocks\nin\sthe\s_exit()\scall.\s\s\n\nThe\sreason\sis\sto\sbe\sseen\sin\sTclFinalize()\swhere\son\nWindows\sit\swaits\sfor\sthe\ssocket\sthread\sto\sexit\swhen\sunloading\sthe\sTCL\nDLL,\sbut\sthe\scorresponding\sthread\seither\sdoes\sno\slonger\sexist,\sor\sdoes\nnot\sget\sthe\sMessage,\sor\sdoes\snot\srespond\sto\sit:\n\nwin/tclWin32Dll.c:\n\s\sDLLMain()\n\s\s\s\s\s\s\s\scase\sDLL_PROCESS_DETACH:\n\s\s\s\s\s\s\s\s...\n\s\s\s\sTcl_Finalize();\n=>\ngeneric/TclEvent.c\n\sTcl_Finalize()\n\s\s\s=>\sTcl_FinalizeThread()\n\s\s\s\s\s\s=>\sTclFinalizeIOSubsystem();\n\s\s\s\s\s\s\s\s\s=>\sTclpFinalizeSockets();\n\n=>\nwin/tclWinSock.c\n\sTclpFinalizeSockets()\n\s=>\sPostMessage(tsdPtr->hwnd,\sSOCKET_TERMINATE,\s0,\s0);\n\s\s\s//\sthis\sblocks:\n\s\s\s\sWaitForSingleObject(tsdPtr->readyEvent,\sINFINITE);\n\nThe\sPostMessage()\sreturn\scode\sis\s0\sat\sthat\spoint,\sindicating\san\serror,\s\nthe\scorresponding\serror\sis\s1400/invalid\swindow\shandle.\s\s\nIf\sI\schange\sthe\scode\sto\n\n\s\s\sif\s(res)\sWaitForSingleObject(tsdPtr->readyEvent,\sINFINITE);\n\nthe\sprogram\sterminates\sas\sexpected.\s\sIt\sseems\san\serror\sto\scall\nWaitForSingleObject()\sif\sthe\sPostMessage()\scall\sdid\snot\ssucceed,\ssince\nthe\sWait()\srelies\son\sthe\sother\sthread\sto\ssignal\sthe\sWait().\s\s\nIf\sthe\sother\sthread\sdoes\snot\sget\sthe\scall,\sit\scannot\ssignal...\n\nProposed\spatch\sagainst\stcl8.5.12:\n\n---\stcl8.5.12/win/tclWinSock.c2012/09/18\s18:43:471.1\n+++\stcl8.5.12/win/tclWinSock.c2012/10/04\s15:04:50\n@@\s-461,14\s+461,14\s@@\n\s\s\s\s\sif\s(tsdPtr\s!=\sNULL)\s{\n\sif\s(tsdPtr->socketThread\s!=\sNULL)\s{\n\s\s\s\s\sif\s(tsdPtr->hwnd\s!=\sNULL)\s{\n-PostMessage(tsdPtr->hwnd,\sSOCKET_TERMINATE,\s0,\s0);\n+int\sres\s=\sPostMessage(tsdPtr->hwnd,\sSOCKET_TERMINATE,\s0,\s0);\n\s\n\s/*\n\s\s*\sWait\sfor\sthe\sthread\sto\sexit.\sThis\sensures\sthat\swe\sare\n\s\s*\scompletely\scleaned\sup\sbefore\swe\sleave\sthis\sfunction.\n\s\s*/\n\s\n-WaitForSingleObject(tsdPtr->readyEvent,\sINFINITE);\n+if\s(res)\sWaitForSingleObject(tsdPtr->readyEvent,\sINFINITE);\n\stsdPtr->hwnd\s=\sNULL;\n\s\s\s\s\s}\n\s\s\s\s\sCloseHandle(tsdPtr->socketThread);\n
J foundin None
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter ralfixx
J subsystem None
J title TclpFinalizeSockets\shangs\son\swindows\s
J type Bug
K 3574493fffffffffffffffffffffffffffffffff
U ralfixx
Z 9539bb841ed4d622fb6b876a22e0fba3