(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.9 and 1.15

version 1.9, 2002/05/20 18:24:09 version 1.15, 2002/05/29 23:26:34
Line 97 
Line 97 
  
 Monitor::~Monitor() Monitor::~Monitor()
 { {
    printf("deregistering with module controller\n");      Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
                     "deregistering with module controller");
  
    if(_module_handle != NULL)    if(_module_handle != NULL)
     {     {
        _controller->deregister_module(PEGASUS_MODULENAME_MONITOR);        _controller->deregister_module(PEGASUS_MODULENAME_MONITOR);
        _controller = 0;        _controller = 0;
          delete _module_handle;
     }     }
    printf("deleting rep\n");      Tracer::trace(TRC_HTTP, Tracer::LEVEL4, "deleting rep");
  
     delete _rep;     delete _rep;
     printf("uninitializing interface \n");      Tracer::trace(TRC_HTTP, Tracer::LEVEL4, "uninitializing interface");
     Socket::uninitializeInterface();     Socket::uninitializeInterface();
     printf("returning from monitor destructor\n");      Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
                     "returning from monitor destructor");
 } }
  
  
Line 123 
Line 126 
  
 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    // register the monitor as a module to gain access to the cimserver's thread pool
    // <<< Wed May 15 09:52:16 2002 mdd >>>    // <<< Wed May 15 09:52:16 2002 mdd >>>
    while(_module_handle == NULL)    while(_module_handle == NULL)
    {    {
   
       try       try
       {       {
   
          _controller = &(ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,          _controller = &(ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
                                                            PEGASUS_MODULENAME_MONITOR,                                                            PEGASUS_MODULENAME_MONITOR,
                                                            (void *)this,                                                            (void *)this,
Line 140 
Line 139 
                                                            0,                                                            0,
                                                            0,                                                            0,
                                                            &_module_handle));                                                            &_module_handle));
          break;  
  
       }       }
       catch( ... )        catch(IncompatibleTypes &)
         {
            ModuleController* controlService =
               new ModuleController(PEGASUS_QUEUENAME_CONTROLSERVICE);
         }
         catch( AlreadyExists & )
       {       {
          ;           break;
       }       }
    }    }
  
   
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
  
     // Windows select() has a strange little bug. It returns immediately if     // Windows select() has a strange little bug. It returns immediately if
Line 166 
Line 168 
  
     int count = 0;     int count = 0;
  
     if (count == 0)  
     {  
         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));
         memcpy(&_rep->active_ex_fd_set, &_rep->ex_fd_set, sizeof(fd_set));         memcpy(&_rep->active_ex_fd_set, &_rep->ex_fd_set, sizeof(fd_set));
Line 182 
Line 183 
             &_rep->active_wr_fd_set,             &_rep->active_wr_fd_set,
             &_rep->active_ex_fd_set,             &_rep->active_ex_fd_set,
             &tv);             &tv);
   
         if (count == 0)         if (count == 0)
         {         {
            pegasus_sleep(milliseconds);  
   
            return false;            return false;
         }         }
  
Line 196 
Line 194 
         else if (count == -1)         else if (count == -1)
 #endif #endif
         {         {
             count = 0;  
             pegasus_sleep(milliseconds);  
   
             return false;             return false;
         }         }
     }  
  
     for (Uint32 i = 0, n = _entries.size(); i < n; i++)      Boolean handled_events = false;
       for (Uint32 i = 0, n = _entries.size(); i < _entries.size(); i++)
     {     {
         Sint32 socket = _entries[i].socket;         Sint32 socket = _entries[i].socket;
         Uint32 events = 0;         Uint32 events = 0;
Line 214 
Line 209 
            {            {
  
               MessageQueue *q = MessageQueue::lookup(_entries[i].queueId);               MessageQueue *q = MessageQueue::lookup(_entries[i].queueId);
               if(q && static_cast<HTTPConnection *>(q)->is_dying())                if(q && static_cast<HTTPConnection *>(q)->is_dying() &&
                    (0 == static_cast<HTTPConnection *>(q)->refcount.value()))
               {               {
                  static_cast<HTTPConnection *>(q)->lock_connection();                  static_cast<HTTPConnection *>(q)->lock_connection();
                  static_cast<HTTPConnection *>(q)->unlock_connection();                  static_cast<HTTPConnection *>(q)->unlock_connection();
Line 223 
Line 219 
                  Message* message= new CloseConnectionMessage(static_cast<HTTPConnection *>(q)->getSocket());                  Message* message= new CloseConnectionMessage(static_cast<HTTPConnection *>(q)->getSocket());
                  message->dest = o.getQueueId();                  message->dest = o.getQueueId();
                  o.enqueue(message);                  o.enqueue(message);
                  i = 0;                   i--;
                  n = _entries.size();                  n = _entries.size();
                  continue;  
               }               }
            }            }
         }         }
Line 270 
Line 265 
  
             if(_entries[i]._type == Monitor::CONNECTION)             if(_entries[i]._type == Monitor::CONNECTION)
             {             {
                  if( static_cast<HTTPConnection *>(queue)->refcount.value() == 0 )
                  {
   
                     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);                   _controller->async_thread_exec(*_module_handle, _dispatch, (void *)queue);
                     else
                        static_cast<HTTPConnection *>(queue)->refcount--;
                  }
             }             }
             else             else
             {             {
Line 279 
Line 281 
                queue->enqueue(message);                queue->enqueue(message);
             }             }
             count--;             count--;
             return true;              pegasus_yield();
         }         }
           handled_events = true;
     }     }
     pegasus_sleep(milliseconds);  
  
     return false;      return(handled_events);
 } }
  
 Boolean Monitor::solicitSocketMessages( Boolean Monitor::solicitSocketMessages(
Line 316 
Line 318 
         FD_SET(socket, &_rep->ex_fd_set);         FD_SET(socket, &_rep->ex_fd_set);
  
     // Add the entry to the list:     // Add the entry to the list:
   
     _MonitorEntry entry(socket, queueId, type);     _MonitorEntry entry(socket, queueId, type);
     entry.dying = 0;  
   
     _entries.append(entry);     _entries.append(entry);
  
     // Success!     // Success!
     ModuleController* controlService =  
         new ModuleController(PEGASUS_QUEUENAME_CONTROLSERVICE);  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
     return true;     return true;
 } }
Line 344 
Line 342 
             FD_CLR(socket, &_rep->wr_fd_set);             FD_CLR(socket, &_rep->wr_fd_set);
             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?
             PEG_METHOD_EXIT();             PEG_METHOD_EXIT();
             return true;             return true;
         }         }
Line 368 
Line 367 
 { {
    HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(parm);    HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(parm);
    if( true == dst->is_dying())    if( true == dst->is_dying())
      {
         dst->refcount--;
       return 0;       return 0;
    dst->lock_connection();     }
    if( false == dst->is_dying())    if( false == dst->is_dying())
       dst->run(1);     {
    dst->unlock_connection();        if(false == dst->run(1))
            pegasus_sleep(1);
  
      }
      dst->refcount--;
    return 0;    return 0;
 } }
  


Legend:
Removed from v.1.9  
changed lines
  Added in v.1.15

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2