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

Diff for /pegasus/src/Pegasus/Common/MessageQueueService.cpp between version 1.82.6.1 and 1.98

version 1.82.6.1, 2003/10/29 22:09:18 version 1.98, 2005/03/23 03:00:42
Line 1 
Line 1 
 //%2003////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
 // IBM Corp.; EMC Corporation, The Open Group. // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 26 
Line 30 
 // Author: Mike Day (mdday@us.ibm.com) // Author: Mike Day (mdday@us.ibm.com)
 // //
 // Modified By: // Modified By:
   //              Amit K Arora, IBM (amita@in.ibm.com) for Bug#1090,#2657
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 43 
Line 48 
  
 static struct timeval create_time = {0, 1}; static struct timeval create_time = {0, 1};
 static struct timeval destroy_time = {300, 0}; static struct timeval destroy_time = {300, 0};
 static struct timeval deadlock_time = {0, 0};  
  
 ThreadPool *MessageQueueService::_thread_pool = 0; ThreadPool *MessageQueueService::_thread_pool = 0;
  
Line 56 
Line 60 
    return _thread_pool;    return _thread_pool;
 } }
  
 void unload_idle_providers(void);  
   
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL  MessageQueueService::kill_idle_threads(void *parm) PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL  MessageQueueService::kill_idle_threads(void *parm)
 { {
  
Line 77 
Line 79 
  
       }       }
    }    }
    exit_thread((PEGASUS_THREAD_RETURN)dead_threads);  
    return (PEGASUS_THREAD_RETURN)dead_threads;  
 }  
   
   
 void MessageQueueService::force_shutdown(Boolean destroy_flag)  
 {  
    return;  
   
 #ifdef MESSAGEQUEUESERVICE_DEBUG  
         //l10n  
    MessageLoaderParms parms("Common.MessageQueueService.FORCING_SHUTDOWN",  
                             "Forcing shutdown of CIMOM Message Router");  
    PEGASUS_STD(cout) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);  
 #endif  
   
   
    MessageQueueService *svc;  
    int counter = 0;  
    _polling_list.lock();  
    svc = _polling_list.next(0);  
  
    while(svc != 0)  #ifdef PEGASUS_POINTER_64BIT
    {     return (PEGASUS_THREAD_RETURN)(Uint64)dead_threads;
 #ifdef MESSAGEQUEUESERVICE_DEBUG  #elif PEGASUS_PLATFORM_AIX_RS_IBMCXX
                 //l10n - reuse same MessageLoaderParms to avoid multiple creates     return (PEGASUS_THREAD_RETURN)(unsigned long)dead_threads;
         parms.msg_id = "Common.MessageQueueService.STOPPING_SERVICE";  #else
                 parms.default_msg = "Stopping $0";     return (PEGASUS_THREAD_RETURN)(Uint32)dead_threads;
                 parms.arg0 = svc->getQueueName();  
                 PEGASUS_STD(cout) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);  
 #endif #endif
   
       _polling_sem.signal();  
       svc->_shutdown_incoming_queue();  
       counter++;  
       _polling_sem.signal();  
       svc = _polling_list.next(svc);  
    }    }
    _polling_list.unlock();  
   
    _polling_sem.signal();  
   
    MessageQueueService::_stop_polling = 1;  
   
    if(destroy_flag == true)  
    {  
   
       svc = _polling_list.remove_last();  
       while(svc)  
       {  
          delete svc;  
          svc = _polling_list.remove_last();  
       }  
   
    }  
 }  
   
  
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::polling_routine(void *parm) PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::polling_routine(void *parm)
 { {
Line 141 
Line 95 
    DQueue<MessageQueueService> *list = reinterpret_cast<DQueue<MessageQueueService> *>(myself->get_parm());    DQueue<MessageQueueService> *list = reinterpret_cast<DQueue<MessageQueueService> *>(myself->get_parm());
    while ( _stop_polling.value()  == 0 )    while ( _stop_polling.value()  == 0 )
    {    {
         try
         {
       _polling_sem.wait();       _polling_sem.wait();
         }
         catch (WaitInterrupted)
         {
            PEG_TRACE_STRING(TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL4,
               "polling_routine(): got WaitInterrupted exception." );
         }
   
       if(_stop_polling.value() != 0 )       if(_stop_polling.value() != 0 )
       {       {
          break;          break;
Line 161 
Line 124 
       if(_check_idle_flag.value() != 0 )       if(_check_idle_flag.value() != 0 )
       {       {
          _check_idle_flag = 0;          _check_idle_flag = 0;
          Thread th(kill_idle_threads, 0, true);  
          th.run();           // If there are insufficent resources to run
            // kill_idle_threads, then just return.
            _thread_pool->allocate_and_awaken(service, kill_idle_threads);
       }       }
    }    }
    myself->exit_self( (PEGASUS_THREAD_RETURN) 1 );    myself->exit_self( (PEGASUS_THREAD_RETURN) 1 );
Line 178 
Line 143 
 MessageQueueService::MessageQueueService(const char *name, MessageQueueService::MessageQueueService(const char *name,
                                          Uint32 queueID,                                          Uint32 queueID,
                                          Uint32 capabilities,                                          Uint32 capabilities,
                                          Uint32 mask,                                           Uint32 mask)
                                          int threads)  
    : Base(name, true,  queueID),    : Base(name, true,  queueID),
  
      _mask(mask),      _mask(mask),
Line 198 
Line 162 
    _default_op_timeout.tv_sec = 30;    _default_op_timeout.tv_sec = 30;
    _default_op_timeout.tv_usec = 100;    _default_op_timeout.tv_usec = 100;
  
    _meta_dispatcher_mutex.lock(pegasus_thread_self());     AutoMutex autoMut(_meta_dispatcher_mutex);
  
    if( _meta_dispatcher == 0 )    if( _meta_dispatcher == 0 )
    {    {
Line 206 
Line 170 
       _meta_dispatcher = new cimom();       _meta_dispatcher = new cimom();
       if (_meta_dispatcher == NULL )       if (_meta_dispatcher == NULL )
       {       {
          _meta_dispatcher_mutex.unlock();  
          throw NullPointer();          throw NullPointer();
       }       }
       _thread_pool = new ThreadPool(0, "MessageQueueService", 0, threads,        _thread_pool = new ThreadPool(0, "MessageQueueService", 0, 0,
                                     create_time, destroy_time, deadlock_time);                                      create_time, destroy_time);
  
       _polling_thread = new Thread(polling_routine,  
                                    reinterpret_cast<void *>(&_polling_list),  
                                    false);  
       _polling_thread->run();  
    }    }
    _service_count++;    _service_count++;
  
    if( false == register_service(name, _capabilities, _mask) )    if( false == register_service(name, _capabilities, _mask) )
    {    {
       _meta_dispatcher_mutex.unlock();  
       //l10n       //l10n
       //throw BindFailedException("MessageQueueService Base Unable to register with  Meta Dispatcher");       //throw BindFailedException("MessageQueueService Base Unable to register with  Meta Dispatcher");
       MessageLoaderParms parms("Common.MessageQueueService.UNABLE_TO_REGISTER",       MessageLoaderParms parms("Common.MessageQueueService.UNABLE_TO_REGISTER",
Line 232 
Line 190 
  
    _polling_list.insert_last(this);    _polling_list.insert_last(this);
  
    _meta_dispatcher_mutex.unlock();  //   _meta_dispatcher_mutex.unlock();  //Bug#1090
 //   _callback_thread.run(); //   _callback_thread.run();
  
 //   _req_thread.run(); //   _req_thread.run();
Line 249 
Line 207 
    }    }
    _callback_ready.signal();    _callback_ready.signal();
  
    _meta_dispatcher_mutex.lock(pegasus_thread_self());     {
        AutoMutex autoMut(_meta_dispatcher_mutex);
    _service_count--;    _service_count--;
    if (_service_count.value() == 0 )    if (_service_count.value() == 0 )
    {    {
  
       _stop_polling++;       _stop_polling++;
       _polling_sem.signal();       _polling_sem.signal();
             if (_polling_thread) {
       _polling_thread->join();       _polling_thread->join();
       delete _polling_thread;       delete _polling_thread;
       _polling_thread = 0;       _polling_thread = 0;
             }
       _meta_dispatcher->_shutdown_routed_queue();       _meta_dispatcher->_shutdown_routed_queue();
       delete _meta_dispatcher;       delete _meta_dispatcher;
       _meta_dispatcher = 0;       _meta_dispatcher = 0;
Line 266 
Line 227 
       delete _thread_pool;       delete _thread_pool;
       _thread_pool = 0;       _thread_pool = 0;
    }    }
    _meta_dispatcher_mutex.unlock();     } // mutex unlocks here
    _polling_list.remove(this);    _polling_list.remove(this);
    // Clean up in case there are extra stuff on the queue.    // Clean up in case there are extra stuff on the queue.
   while (_incoming.count())   while (_incoming.count())
Line 305 
Line 266 
  
  
  
 void MessageQueueService::enqueue(Message *msg) throw(IPCException)  void MessageQueueService::enqueue(Message *msg)
 { {
    PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE, "MessageQueueService::enqueue()");    PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE, "MessageQueueService::enqueue()");
  
Line 323 
Line 284 
  
    while ( service->_die.value() == 0 )    while ( service->_die.value() == 0 )
    {    {
         try
         {
       service->_callback_ready.wait();       service->_callback_ready.wait();
         }
         catch (WaitInterrupted)
         {
            PEG_TRACE_STRING(TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL4,
               "_callback_proc(): got WaitInterrupted exception." );
         }
  
       service->_callback.lock();       service->_callback.lock();
       operation = service->_callback.next(0);       operation = service->_callback.next(0);
Line 350 
Line 319 
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::_req_proc(void * parm) PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::_req_proc(void * parm)
 { {
    MessageQueueService *service = reinterpret_cast<MessageQueueService *>(parm);    MessageQueueService *service = reinterpret_cast<MessageQueueService *>(parm);
   
      if ( service->_die.value() != 0)
                    return (0);
   
    // pull messages off the incoming queue and dispatch them. then    // pull messages off the incoming queue and dispatch them. then
    // check pending messages that are non-blocking    // check pending messages that are non-blocking
    AsyncOpNode *operation = 0;    AsyncOpNode *operation = 0;
  
    if ( service->_die.value() == 0 )           // many operations may have been queued.
            do
     {     {
          try          try
          {          {
Line 362 
Line 336 
          }          }
          catch(ListClosed & )          catch(ListClosed & )
          {          {
             operation = 0;                           break;
   
             return(0);  
          }          }
   
          if( operation )          if( operation )
          {          {
             operation->_service_ptr = service;             operation->_service_ptr = service;
             service->_handle_incoming_operation(operation);             service->_handle_incoming_operation(operation);
          }          }
     }           } while (operation);
  
    return(0);    return(0);
 } }
Line 625 
Line 598 
 { {
    if (_incoming_queue_shutdown.value() > 0 )    if (_incoming_queue_shutdown.value() > 0 )
       return false;       return false;
      if (_polling_thread == NULL)  {
         _polling_thread = new Thread(polling_routine,
                                      reinterpret_cast<void *>(&_polling_list),
                                      false);
         while (!_polling_thread->run())
         {
            pegasus_yield();
         }
           }
 // ATTN optimization remove the message checking altogether in the base // ATTN optimization remove the message checking altogether in the base
 // << Mon Feb 18 14:02:20 2002 mdd >> // << Mon Feb 18 14:02:20 2002 mdd >>
    op->lock();    op->lock();
Line 864 
Line 845 
    op->_op_dest = MessageQueue::lookup(destination); // destination of this message    op->_op_dest = MessageQueue::lookup(destination); // destination of this message
    op->_flags |= ASYNC_OPFLAGS_CALLBACK;    op->_flags |= ASYNC_OPFLAGS_CALLBACK;
    op->_flags &= ~(ASYNC_OPFLAGS_FIRE_AND_FORGET);    op->_flags &= ~(ASYNC_OPFLAGS_FIRE_AND_FORGET);
    op->_state &= ~ASYNC_OPSTATE_COMPLETE;  
    // initialize the callback data    // initialize the callback data
    op->_async_callback = callback;   // callback function to be executed by recpt. of response    op->_async_callback = callback;   // callback function to be executed by recpt. of response
    op->_callback_node = op;          // the op node    op->_callback_node = op;          // the op node
Line 988 
Line 968 
              this,              this,
              (void *)0);              (void *)0);
  
      try
      {
    request->op->_client_sem.wait();    request->op->_client_sem.wait();
      }
      catch (WaitInterrupted)
      {
         PEG_TRACE_STRING(TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL4,
            "SendWait(): got WaitInterrupted exception" );
      }
    request->op->lock();    request->op->lock();
    AsyncReply * rpl = static_cast<AsyncReply *>(request->op->_response.remove_first());    AsyncReply * rpl = static_cast<AsyncReply *>(request->op->_response.remove_first());
    rpl->op = 0;    rpl->op = 0;
Line 1172 
Line 1160 
 { {
    static Mutex _monitor;    static Mutex _monitor;
    Uint32 value;    Uint32 value;
    _monitor.lock(pegasus_thread_self());     AutoMutex autoMut(_monitor);
   
    _xid++;    _xid++;
    value =  _xid.value();    value =  _xid.value();
    _monitor.unlock();  
    return value;    return value;
  
 } }


Legend:
Removed from v.1.82.6.1  
changed lines
  Added in v.1.98

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2