On Wednesday 26 March 2003 20:03, you wrote: > 1. Are there ANY cases where a TLS (thread local storage) cd/pwd would > be the WRONG thing? E.g., could we reasonally expect there to be any > cases where one thread A does "pwd", gets "/home/my", does "cd /foo", > and then thread B does "pwd" and EXPECTS to get "/foo" back as the > result? Any such cases in Tcl? In AOLserver? In libgcc? Anywhere > in any C libraries whatsoever?
I did not understand. The scenario you've used (thread A/B) is what *is* usually happening. The thread B gets "/foo" and this is what is expected. But, this is not the source of the problem. The source of the problem is that Tcl internal code remembers the process-wide current working directory in an global Tcl object and neglects to properly lock access to this object for ALL operations, in addition to blindly passing the same object to other threads. We'd need to talk to the Tcl FS implementor and get him/them abandon the object storage in favour of simple char* or put the object into the TSD. > 2. At what level would this hypothetical TLS cd/pwd implementation > need to be inserted? Are there OS-provided library functions that > themselves use cd/pwd, and would thus need to be overriden or > otherwise worked around? Or do Tcl and AOLserver have their own entry > points to all C function calls using cd/pwd, and we could implement > the TLS stuff there? Tcl has all FS-code abstracted in a form of pluggable filesystems. So, you never actually go down to the OS-level without passing N layers of Tcl code. The whole stuff is pretty frightening (just go and look into the generic/tclIOUtil.c and you will see why) but it does gives you a powerful abstraction. Again, I'm sorry if I misunderstood your question(s). I think that you can't protect yourself from the effects of the [cd]. You will, however need to know (from the docs, I suspect) wether some code does change the cwd, and if it does, ypu must take care to put the locks arround it, if necessary for your app. I think it would be good to know what exact spots in Tcl might be potential [cd] doers. I will try to grep the code and see what is done where. Cheers, Zoran -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list: http://www.aolserver.com/listserv.html List information and options: http://listserv.aol.com/