Index: openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl 22 May 2007 12:45:37 -0000 1.12 +++ openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl 24 May 2007 08:56:33 -0000 1.13 @@ -139,13 +139,6 @@ } } - # - # a simple calback for cleanup of per connection objects - # - ::xotcl::Object instproc destroy_on_cleanup {} { - set ::xotcl_cleanup([self]) [list [self] destroy] - } - } # ::xotcl::Class instproc import {class pattern} { @@ -188,14 +181,28 @@ # if {[catch {set registered [ns_ictl gettraces freeconn]}]} { ns_log notice "*** you should really upgrade to Aolserver 4.5" - ns_ictl oncleanup ::xo::cleanup + # "ns_ictl oncleanup" is called after variables are deleted + # ns_ictl oncleanup "ns_log notice --oncleanup" + + ::xotcl::Object instproc destroy_on_cleanup {} { + #my log "--cleanup adding ::xotcl_cleanup([self]) [list [self] destroy]" + if {![array exists ::xotcl_cleanup]} { + ns_atclose ::xo::cleanup + } + set ::xotcl_cleanup([self]) [list [self] destroy] + + } } else { + ::xotcl::Object instproc destroy_on_cleanup {} { + set ::xotcl_cleanup([self]) [list [self] destroy] + } + # register only once if {[lsearch $registered ::xo::cleanup] == -1} { ns_ictl trace freeconn ::xo::cleanup } } proc cleanup {} { - ns_log notice "*** start of cleanup" + #ns_log notice "*** start of cleanup ([array get ::xotcl_cleanup])" set at_end "" foreach {name cmd} [array get ::xotcl_cleanup] { if {![::xotcl::Object isobject $name]} { @@ -221,7 +228,7 @@ if {[catch {eval $at_end} errorMsg]} { ns_log notice "Error during ::xo::cleanup: $errorMsg $::errorInfo" } - ns_log notice "*** end of cleanup" + #ns_log notice "*** end of cleanup (at_end $at_end)" } }