Index: openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl,v diff -u -N -r1.20.2.4 -r1.20.2.5 --- openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl 16 Sep 2021 09:51:55 -0000 1.20.2.4 +++ openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl 17 Sep 2021 09:27:47 -0000 1.20.2.5 @@ -166,7 +166,7 @@ ::xotcl::THREAD instproc destroy {} { :log "destroy called" - if {![:persistent] && + if {!${:persistent} && [nsv_exists [self class] [self]]} { set tid [nsv_get [self class] [self]] set refcount [::thread::release $tid] @@ -200,19 +200,20 @@ #:check_blueprint #:log "after lock" if {![nsv_exists [self class] [self]]} { - if {[:lightweight]} { + if {${:lightweight}} { :log "CREATE lightweight thread" set tid [::thread::create -thin] } else { set tid [::thread::create] } - if {[:persistent]} { + nsv_set [self class] [self] $tid + if {${:persistent}} { :log "--created new persistent [self class] as $tid pid=[pid]" } else { :log "--created new [self class] as $tid pid=[pid]" } #:log "--THREAD DO send [self] epoch = [ns_ictl epoch]" - if {[:lightweight]} { + if {${:lightweight}} { } elseif {![ns_ictl epoch]} { #ns_log notice "--THREAD send [self] no epoch" # We are during initialization. For some unknown reasons, XOTcl @@ -224,12 +225,18 @@ append initcmd ${:initcmd} #ns_log notice "INIT $initcmd" ::thread::send $tid $initcmd - + # - # Tell the world about the thread only once it is fully - # working to avoid potential race-conditions during startup. + # There is a potential race condition during startup on a very + # slow/busy system, where the throttle thread can receive + # commands, although it is not full initialized. One approach + # would be to move the nsv setting of the pid here, where the + # thread is fully initialized, .... but unfortunately, this + # leads to problems as well. This needs deeper investing, + # ... but is not very important, since it is very hard to + # reconstruct the problem case. # - nsv_set [self class] [self] $tid + #nsv_set [self class] [self] $tid } else { set tid [nsv_get [self class] [self]] } @@ -244,7 +251,7 @@ # # This is the first call. # - if {![:persistent] && ![info exists :recreate]} { + if {!${:persistent} && ![info exists :recreate]} { # # For a shared thread, we do ref-counting through preserve. # @@ -305,7 +312,7 @@ Class create ::xotcl::THREAD::Client -parameter {server {serverobj [self]}} ::xotcl::THREAD::Client instproc do args { - [:server] do [:serverobj] {*}$args + ${:server} do ${:serverobj} {*}$args } ::xo::library source_dependent