I tried running valgrind on suez using the XrdPosix interface. It kept failing. This is the first problem that valgrind reported. There are others that I will get to in a little while. According to the linux pthread_detach() manual "The effect of multiple pthread_detach() calls on the same target thread is unspecified." This is standards-speak for "don't do dat!!". Alas, XrdClient is doing that in XrdClientPhyConnect.cc in the method XrdClientPhyConnection::StartReader(). The detach call is in a while loop, which can be greatly simplified, as it turns out. While waiting for the new thread to be scheduled at the bottom of the method, there is no need to read out fReaderthreadrunning in a critical section. It just slows this thread and possibly other threads down, and so the following will work fine, and is easier to understand. I was also concerned that if the new thread never runs, then the while loop will be infinite. I put in a limit on the number of waits. Set maxRetries to some reasonable amount. You should probably not enter the while loop if the detach failed. I put in a return but you may want to do something else. The approximate code that you need is below. Share & Enjoy ----------- void XrdClientPhyConnection::StartReader() { bool running; { XrdOucMutexHelper l(fMutex); running = fReaderthreadrunning; } // Start reader thread // Parametric asynchronous stuff. // If we are going Sync, then nothing has to be done, // otherwise the reader thread must be started if ( !running && EnvGetLong(NAME_GOASYNC) ) { Info(XrdClientDebug::kHIDEBUG, "StartReader", "Starting reader thread..."); // Now we launch the reader thread fReaderthreadhandler = new XrdClientThread(SocketReaderThread); if (!fReaderthreadhandler) Error("PhyConnection", "Can't create reader thread: out of system resources"); fReaderthreadhandler->Run(this); if (0 != fReaderthreadhandler->Detach()) { Error("PhyConnection", "Thread detach failed"); // Do we need to take other action here??? return; // ?? } // Sleep until the detached thread starts running, which hopefully // is not forever. int maxRetries = 10; while (--maxRetries >= 0 && !fReaderthreadrunning) { fReaderCV.Wait(100); } } } -- Gregory J. Sharp email: [log in to unmask] Wilson Synchrotron Laboratory url: http://www.lepp.cornell.edu/ ~gregor Cornell University ph: +1 607 255 4882 Ithaca, NY 14853 fax: +1 607 255 8062