(file) Return to Thread.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Thread.cpp between version 1.100.2.6 and 1.100.4.1

version 1.100.2.6, 2008/10/23 18:59:32 version 1.100.4.1, 2007/11/09 18:59:30
Line 57 
Line 57 
  
 extern "C" void *_start_wrapper(void *arg_) extern "C" void *_start_wrapper(void *arg_)
 { {
     // Clean up dynamic memory now to prevent a leak if the thread is canceled.      StartWrapperArg *arg = (StartWrapperArg *) arg_;
     StartWrapperArg arg;  
     arg.start = ((StartWrapperArg *) arg_)->start;  
     arg.arg = ((StartWrapperArg *) arg_)->arg;  
     delete (StartWrapperArg *) arg_;  
  
     // establish cancelability of the thread      void *return_value = (*arg->start) (arg->arg);
     pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);      delete arg;
     pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);  
   
     void *return_value = (*arg.start) (arg.arg);  
  
     return return_value;     return return_value;
 } }
Line 158 
Line 151 
     arg->start = _start;     arg->start = _start;
     arg->arg = this;     arg->arg = this;
  
     Threads::Type type =      Threads::Type type = _is_detached ? Threads::DETACHED : Threads::JOINABLE;
         _is_detached ? Threads::THREADS_DETACHED : Threads::THREADS_JOINABLE;  
     int rc = Threads::create(_handle.thid, type, _start_wrapper, arg);     int rc = Threads::create(_handle.thid, type, _start_wrapper, arg);
  
     // On Linux distributions released prior 2005, the implementation of     // On Linux distributions released prior 2005, the implementation of
Line 185 
Line 177 
     return PEGASUS_THREAD_OK;     return PEGASUS_THREAD_OK;
 } }
  
 static sigset_t *block_signal_mask(sigset_t * sig)  
 {  
     sigemptyset(sig);  
     // should not be used for main()  
     sigaddset(sig, SIGHUP);  
     sigaddset(sig, SIGINT);  
     // maybe useless, since KILL can't be blocked according to POSIX  
     sigaddset(sig, SIGKILL);  
   
     sigaddset(sig, SIGABRT);  
     sigaddset(sig, SIGALRM);  
     sigaddset(sig, SIGPIPE);  
   
   
 // Note: older versions of the linux pthreads library use SIGUSR1 and SIGUSR2  
 // internally to stop and start threads that are blocking, the newer ones  
 // implement this through the kernel's real time signals  
 // since SIGSTOP/CONT can handle suspend()/resume() on Linux  
 // block them  
 // #if defined(PEGASUS_PLATFORM_LINUX_IX86_GNU)  
 //     sigaddset(sig, SIGUSR1);  
 //     sigaddset(sig, SIGUSR2);  
 // #endif  
 #if defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined (PEGASUS_OS_VMS)  
     sigprocmask(SIG_BLOCK, sig, NULL);  
 #else  
     pthread_sigmask(SIG_BLOCK, sig, NULL);  
 #endif  
     return sig;  
 }  
   
 /*  
 ATTN: remove this!  
 */  
 #if 1  
 static Uint32 _num_threads = 0;  
 static Mutex _num_threads_mutex;  
 #endif  
   
 Thread::Thread( Thread::Thread(
     ThreadReturnType(PEGASUS_THREAD_CDECL* start) (void*),     ThreadReturnType(PEGASUS_THREAD_CDECL* start) (void*),
     void* parameter,     void* parameter,
Line 237 
Line 190 
       _thread_parm(parameter),       _thread_parm(parameter),
       _exit_code(0)       _exit_code(0)
 { {
 /*  
 ATTN: remove this!  
 */  
 #if 1  
     Uint32 num_threads;  
     _num_threads_mutex.lock();  
     _num_threads++;  
     num_threads = _num_threads;  
     printf("Thread::Thread(): num_threads=%u\n", num_threads);  
     _num_threads_mutex.unlock();  
 #endif  
   
     Threads::clear(_handle.thid);     Threads::clear(_handle.thid);
 } }
  
 Thread::~Thread() Thread::~Thread()
 { {
 /*  
 ATTN: remove this!  
 */  
 #if 1  
     Uint32 num_threads;  
     _num_threads_mutex.lock();  
     _num_threads--;  
     num_threads = _num_threads;  
     printf("Thread::~Thread(): num_threads=%u\n", num_threads);  
     _num_threads_mutex.unlock();  
 #endif  
   
     try     try
     {     {
         join();         join();


Legend:
Removed from v.1.100.2.6  
changed lines
  Added in v.1.100.4.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2