D 2025-05-22T09:14:23.523 J foundin 1.8,\scommit\sca1a846290,\sbut\saffects\solder\sand\snewer\scommits\sas\swell J icomment There\sis\sa\ssubtle\sbug\swhen\strying\sto\sconnect\sto\sa\sserver\snot\srunning\svia\shttp::geturl\susing\stcltls.\stcltls\swaits\sfor\sthe\sconnection\sand\sloops\sendlessly\snot\sgiving\sthe\sTcl\sevent\sloop\sthe\schance\sto\shandle\stimer\sevents\sfor\sa\stimeout.\sExample\scode\sto\sreproduce:\r\n\r\n```\r\npackage\srequire\shttp;\r\npackage\srequire\stls;\r\nset\stok\s[http::geturl\shttps://localhost:8143/info\s-timeout\s3000]\s#\suse\sport\swith\sno\sservice\slistening\shere!\r\nhttp::status\s$tok;\r\n```\r\n\r\nThe\sproblem\sis\sfixed\swith\sthe\sfollowing\spatch.\sAnother\sway\sto\scorrect\sthe\sissue\smight\sbe\sto\schange\sthe\sTcl\shttp\spackage\sto\sset\sthe\ssocket\sto\sasync\seven\swhen\swaiting\sfor\sthe\sinitial\sconnection\sbut\sthis\sseems\sto\sbe\sa\sbigger\seffort.\sI\sconsider\sand\sendless\sloop\sin\sa\sTcl\scommand\sas\sproblematic\sso\sI\sdecided\sto\savoid\sit.\sKeep\sin\smind\sthat\stcltls\sproperly\saborts\sthe\sloop\sfor\sasync\ssockets\sduring\sthe\sconnection\sphase.\r\n\r\n```\r\ndiff\s-rcN\svanilla/tcltls-ca1a846290/generic/tlsIO.c\stcltls-1.8-ca1a846290/generic/tlsIO.c\r\n***\svanilla/tcltls-ca1a846290/generic/tlsIO.c\s\s\sThu\sJan\s\s2\s19:05:36\s2025\r\n---\stcltls-1.8-ca1a846290/generic/tlsIO.c\s\s\s\s\s\s\sThu\sMay\s22\s10:46:27\s2025\r\n***************\r\n***\s222,235\s****\r\n\s\s\s\s\s\s\s\sdprintf("bioShouldRetry\s=\s%d",\sbioShouldRetry);\r\n\r\n\s\s\s\s\s\s\s\sif\s(err\s<=\s0)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\sif\s(rc\s==\sSSL_ERROR_WANT_CONNECT\s||\src\s==\sSSL_ERROR_WANT_ACCEPT)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sbioShouldRetry\s=\s1;\r\n!\s\s\s\s\s\s\s\s\s\s\s}\selse\sif\s(rc\s==\sSSL_ERROR_WANT_READ)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sbioShouldRetry\s=\s1;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sstatePtr->want\s|=\sTCL_READABLE;\r\n!\s\s\s\s\s\s\s\s\s\s\s}\selse\sif\s(rc\s==\sSSL_ERROR_WANT_WRITE)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sbioShouldRetry\s=\s1;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sstatePtr->want\s|=\sTCL_WRITABLE;\r\n\s\s\s\s\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s}\r\n\r\n---\s222,250\s----\r\n\s\s\s\s\s\s\s\sdprintf("bioShouldRetry\s=\s%d",\sbioShouldRetry);\r\n\r\n\s\s\s\s\s\s\s\sif\s(err\s<=\s0)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s/*\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\sProblem\shere\swhen\ssocket\sis\snot\sasync\sand\sstill\snot\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\sconnected,\savoid\sto\sloop\sendlessly.\sThis\shappens\sto\sbe\sthe\scase\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\sthe\sthe\sdestination\sIP\sis\sreachable\sbut\sno\sservice\sresponds\son\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\sthe\srequested\sport.\sTcl\shttp\sdoes\snot\sput\sthe\ssocket\sin\sasync\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\smode\suntil\sconnected\sso\swe\sneed\sto\sallow\sthe\sTcl\sevent\sloop\sto\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\scatch\sthe\stimeoout\sand\ssits\son\sa\svwait\sfor\sthe\shttp\stoken.\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\sTest\scase\swhich\syields\shang\sin\sendless\sloop\shere\swithout\sthis\spatch\sis:\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\spackage\srequire\shttp;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\spackage\srequire\stls;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\sset\stok\s[http::geturl\shttps://localhost:8143/info\s-timeout\s3000]\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*\shttp::status\s$tok;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s*/\r\n!\s\s\s\s\s\s\s\s\s\s\sif(statePtr->flags\s&\sTLS_TCL_ASYNC)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sif\s(rc\s==\sSSL_ERROR_WANT_CONNECT\s||\src\s==\sSSL_ERROR_WANT_ACCEPT)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sbioShouldRetry\s=\s1;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\selse\sif\s(rc\s==\sSSL_ERROR_WANT_READ)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sbioShouldRetry\s=\s1;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sstatePtr->want\s|=\sTCL_READABLE;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\selse\sif\s(rc\s==\sSSL_ERROR_WANT_WRITE)\s{\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sbioShouldRetry\s=\s1;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sstatePtr->want\s|=\sTCL_WRITABLE;\r\n!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s}\r\n``` J login anonymous J mimetype text/x-markdown J severity Critical J status Open J title http:geturl\shttps://localhost:8143/info\shangs\swhen\sserver\snot\srunning J type Code\sDefect K 48eddca89ea79b5cb6477d5f9f46cc890873cf92 U anonymous Z 73611c082e9cb9942042eb18e49c80ab