summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-01-24 20:25:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-01-24 20:25:43 (GMT)
commit8453f13ebd97725fe9e5097d82e933854954b1ca (patch)
tree70612d5687bc7371d1798ade715e4f3ebab54d5d
parentc00162ab9a350bf30c176de949506a19f43f7fd7 (diff)
downloadtcl-bug_3599789.zip
tcl-bug_3599789.tar.gz
tcl-bug_3599789.tar.bz2
Bug 3599789: Proposed fix by Serg G. Bresterbug_3599789
-rw-r--r--library/http/http.tcl23
1 files changed, 23 insertions, 0 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 4a517ac..7d09726 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -249,6 +249,16 @@ proc ::http::CloseSocket {s {token {}}} {
} else {
Log "Cannot close connection $conn_id - no socket in socket map"
}
+ # reset states of all tokens shared this connection :
+ variable sockettokenmap
+ if {[info exists sockettokenmap(s-$s)]} {
+ foreach token $sockettokenmap(s-$s) {
+ if {[info exists $token]} {
+ reset $token "closed"
+ }
+ }
+ unset sockettokenmap(s-$s)
+ }
}
}
@@ -585,6 +595,9 @@ proc http::geturl {url args} {
[expr {$state(-keepalive)?"keepalive":""}]
if {$state(-keepalive)} {
set socketmap($state(socketinfo)) $sock
+ # share connection via keepalive token map
+ variable sockettokenmap
+ lappend sockettokenmap(s-$sock) $token
}
if {![info exists phost]} {
@@ -1285,6 +1298,16 @@ proc http::wait {token} {
variable $token
upvar 0 $token state
+ # check connection was closed (ex. file event by keepalive connection) :
+ if {$state(-keepalive)} {
+ set conn_id $state(socketinfo)
+ variable socketmap
+ if {![info exists socketmap($conn_id)]} {
+ Log "Wait: connection \"$conn_id\" was closed unexpectedly"
+ return [status $token]
+ }
+ }
+
if {![info exists state(status)] || $state(status) eq ""} {
# We must wait on the original variable name, not the upvar alias
vwait ${token}(status)