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

Diff for /pegasus/src/Pegasus/Common/Monitor.cpp between version 1.17 and 1.18

version 1.17, 2002/06/01 00:56:36 version 1.18, 2002/06/07 00:03:34
Line 61 
Line 61 
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   
   static struct timeval create_time = {0, 50};
   static struct timeval destroy_time = {2, 0};
   static struct timeval deadlock_time = {10, 0};
   
   ThreadPool Monitor::_thread_pool(0, "Monitor", 0, 20,
                                    create_time, destroy_time, deadlock_time);
   
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // //
 // MonitorRep // MonitorRep
Line 96 
Line 104 
     FD_ZERO(&_rep->active_ex_fd_set);     FD_ZERO(&_rep->active_ex_fd_set);
 } }
  
   Monitor::Monitor(Boolean async)
      : _module_handle(0), _controller(0), _async(async)
   {
       Socket::initializeInterface();
       _rep = new MonitorRep;
       FD_ZERO(&_rep->rd_fd_set);
       FD_ZERO(&_rep->wr_fd_set);
       FD_ZERO(&_rep->ex_fd_set);
       FD_ZERO(&_rep->active_rd_fd_set);
       FD_ZERO(&_rep->active_wr_fd_set);
       FD_ZERO(&_rep->active_ex_fd_set);
   }
 Monitor::~Monitor() Monitor::~Monitor()
 { {
     Tracer::trace(TRC_HTTP, Tracer::LEVEL4,     Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
Line 117 
Line 137 
 } }
  
  
   int Monitor::kill_idle_threads()
   {
      static struct timeval now, last;
      gettimeofday(&now, NULL);
   
      if( now.tv_sec - last.tv_sec > 0 )
      {
         gettimeofday(&last, NULL);
         return _thread_pool.kill_dead_threads();
      }
      return 0;
   }
   
  
 //<<< Tue May 14 20:38:26 2002 mdd >>> //<<< Tue May 14 20:38:26 2002 mdd >>>
 //  register with module controller //  register with module controller
Line 127 
Line 160 
  
 Boolean Monitor::run(Uint32 milliseconds) Boolean Monitor::run(Uint32 milliseconds)
 { {
    // register the monitor as a module to gain access to the cimserver's thread pool  
    // <<< Wed May 15 09:52:16 2002 mdd >>>  
    while( _module_handle == NULL)  
    {  
       try  
       {  
          _controller = &(ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,  
                                                            PEGASUS_MODULENAME_MONITOR,  
                                                            (void *)this,  
                                                            0,  
                                                            0,  
                                                            0,  
                                                            &_module_handle));  
  
       }     static struct timeval now, last;
       catch(IncompatibleTypes &)  
       {  
          ModuleController* controlService =  
             new ModuleController(PEGASUS_QUEUENAME_CONTROLSERVICE);  
       }  
       catch( AlreadyExists & )  
       {  
          break;  
       }  
    }  
  
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
  
Line 168 
Line 178 
     // there were no undispatched events from last time.     // there were no undispatched events from last time.
  
     int count = 0;     int count = 0;
       pegasus_gettimeofday(&now);
  
     memcpy(&_rep->active_rd_fd_set, &_rep->rd_fd_set, sizeof(fd_set));     memcpy(&_rep->active_rd_fd_set, &_rep->rd_fd_set, sizeof(fd_set));
 //    memcpy(&_rep->active_wr_fd_set, &_rep->wr_fd_set, sizeof(fd_set)); //    memcpy(&_rep->active_wr_fd_set, &_rep->wr_fd_set, sizeof(fd_set));
Line 187 
Line 197 
        &tv);        &tv);
     if (count == 0)     if (count == 0)
     {     {
          if( now.tv_sec - last.tv_sec > 2)
          {
             kill_idle_threads();
             MessageQueueService::kill_idle_threads();
             pegasus_gettimeofday(&last);
          }
        return false;        return false;
     }     }
   
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
     else if (count == SOCKET_ERROR)     else if (count == SOCKET_ERROR)
 #else #else
Line 266 
Line 281 
                break;                break;
             }             }
  
             if(_entries[i]._type == Monitor::CONNECTION)              if(_async == true && _entries[i]._type == Monitor::CONNECTION)
             {             {
                if( static_cast<HTTPConnection *>(queue)->refcount.value() == 0 )                if( static_cast<HTTPConnection *>(queue)->refcount.value() == 0 )
                {                {
  
                   static_cast<HTTPConnection *>(queue)->refcount++;                   static_cast<HTTPConnection *>(queue)->refcount++;
                   if( false == static_cast<HTTPConnection *>(queue)->is_dying())                   if( false == static_cast<HTTPConnection *>(queue)->is_dying())
                      _controller->async_thread_exec(*_module_handle, _dispatch, (void *)queue);                       _thread_pool.allocate_and_awaken((void *)queue, _dispatch);
                   else                   else
                      static_cast<HTTPConnection *>(queue)->refcount--;                      static_cast<HTTPConnection *>(queue)->refcount--;
                }                }
Line 346 
Line 361 
             FD_CLR(socket, &_rep->ex_fd_set);             FD_CLR(socket, &_rep->ex_fd_set);
             _entries.remove(i);             _entries.remove(i);
             // ATTN-RK-P3-20020521: Need "Socket::close(socket);" here?             // ATTN-RK-P3-20020521: Need "Socket::close(socket);" here?
               Socket::close(socket);
             PEG_METHOD_EXIT();             PEG_METHOD_EXIT();
             return true;             return true;
         }         }


Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2