(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.121.4.5 and 1.125

version 1.121.4.5, 2008/03/26 19:21:44 version 1.125, 2007/10/30 17:24:10
Line 76 
Line 76 
     _uninitialize();     _uninitialize();
 } }
  
 void Tickler::notify()  #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
 {  
     Socket::write(_clientSocket, "\0", 1);  
 }  
   
 void Tickler::reset()  
 {  
     // Clear all bytes from the tickle socket  
     char buffer[32];  
     while (Socket::read(_serverSocket, buffer, 32) > 0)  
     {  
     }  
 }  
   
 #if defined(PEGASUS_OS_TYPE_UNIX)  
  
 // Use an anonymous pipe for the tickle connection. // Use an anonymous pipe for the tickle connection.
  
Line 109 
Line 95 
  
     _serverSocket = fds[0];     _serverSocket = fds[0];
     _clientSocket = fds[1];     _clientSocket = fds[1];
   
     Socket::disableBlocking(_serverSocket);  
 } }
  
 #else #else
  
 // Use an external loopback socket connection to allow the tickle socket to // Use an external loopback socket connection to allow the tickle socket to
 // be included in the select() array on non-Unix platforms.  // be included in the select() array on Windows.
  
 void Tickler::_initialize() void Tickler::_initialize()
 { {
Line 356 
Line 340 
  
     // Create a MonitorEntry for the Tickler and set its state to IDLE so the     // Create a MonitorEntry for the Tickler and set its state to IDLE so the
     // Monitor will watch for its events.     // Monitor will watch for its events.
     _MonitorEntry entry(_tickler.getReadHandle(), 1, INTERNAL);      _MonitorEntry entry(_tickler.getServerSocket(), 1, INTERNAL);
     entry._status = _MonitorEntry::IDLE;     entry._status = _MonitorEntry::IDLE;
     _entries.append(entry);     _entries.append(entry);
  
Line 376 
Line 360 
  
 void Monitor::tickle() void Monitor::tickle()
 { {
     _tickler.notify();      AutoMutex autoMutex(_tickleMutex);
       Socket::write(_tickler.getClientSocket(), "\0\0", 2);
 } }
  
 void Monitor::setState( void Monitor::setState(
Line 525 
Line 510 
 #endif #endif
     _entry_mut.lock();     _entry_mut.lock();
  
     struct timeval timeNow;  
     Time::gettimeofday(&timeNow);  
   
     // After enqueue a message and the autoEntryMutex has been released and     // After enqueue a message and the autoEntryMutex has been released and
     // locked again, the array of _entries can be changed. The ArrayIterator     // locked again, the array of _entries can be changed. The ArrayIterator
     // has be reset with the original _entries     // has be reset with the original _entries
Line 571 
Line 553 
                             "entries[indx].type for indx = %d is "                             "entries[indx].type for indx = %d is "
                                 "Monitor::CONNECTION",                                 "Monitor::CONNECTION",
                             indx));                             indx));
                           static_cast<HTTPConnection *>(q)->_entry_index = indx;
   
                           // Do not update the entry just yet. The entry gets
                           // updated once the request has been read.
                           //entries[indx]._status = _MonitorEntry::BUSY;
   
                           // If allocate_and_awaken failure, retry on next
                           // iteration
   /* Removed for PEP 183.
                           if (!MessageQueueService::get_thread_pool()->
                                   allocate_and_awaken((void *)q, _dispatch))
                           {
                               PEG_TRACE_CSTRING(TRC_DISCARDED_DATA,
                                   Tracer::LEVEL2,
                                   "Monitor::run: Insufficient resources to "
                                       "process request.");
                               entries[indx]._status = _MonitorEntry::IDLE;
                               return true;
                           }
   */
   // Added for PEP 183
                         HTTPConnection *dst =                         HTTPConnection *dst =
                             reinterpret_cast<HTTPConnection *>(q);                             reinterpret_cast<HTTPConnection *>(q);
                         dst->_entry_index = indx;  
   
                         // Update idle start time because we have received some  
                         // data. Any data is good data at this point, and we'll  
                         // keep the connection alive, even if we've exceeded  
                         // the idleConnectionTimeout, which will be checked  
                         // when we call closeConnectionOnTimeout() next.  
                         Time::gettimeofday(&dst->_idleStartTime);  
   
                         // Check for accept pending (ie. SSL handshake pending)  
                         // or idle connection timeouts for sockets from which  
                         // we received data (avoiding extra queue lookup below).  
                         if (!dst->closeConnectionOnTimeout(&timeNow))  
                         {  
   
                         PEG_TRACE((TRC_HTTP, Tracer::LEVEL4,                         PEG_TRACE((TRC_HTTP, Tracer::LEVEL4,
                             "Monitor::_dispatch: entering run() for "                             "Monitor::_dispatch: entering run() for "
                                 "indx = %d, queueId = %d, q = %p",                                 "indx = %d, queueId = %d, q = %p",
                             dst->_entry_index,                             dst->_entry_index,
                                 dst->_monitor->                              dst->_monitor->_entries[dst->_entry_index].queueId,
                                     _entries[dst->_entry_index].queueId,  
                             dst));                             dst));
  
                         try                         try
Line 608 
Line 595 
                         PEG_TRACE((TRC_HTTP, Tracer::LEVEL4,                         PEG_TRACE((TRC_HTTP, Tracer::LEVEL4,
                             "Monitor::_dispatch: exited run() for index %d",                             "Monitor::_dispatch: exited run() for index %d",
                             dst->_entry_index));                             dst->_entry_index));
                         }  
                           // It is possible the entry status may not be set to
                           // busy.  The following will fail in that case.
                           // PEGASUS_ASSERT(dst->_monitor->_entries[
                           //     dst->_entry_index]._status.get() ==
                           //    _MonitorEntry::BUSY);
                           // Once the HTTPConnection thread has set the status
                           // value to either Monitor::DYING or Monitor::IDLE,
                           // it has returned control of the connection to the
                           // Monitor.  It is no longer permissible to access
                           // the connection or the entry in the _entries table.
   
                           // The following is not relevant as the worker thread
                           // or the reader thread will update the status of the
                           // entry.
                           //if (dst->_connectionClosePending)
                           //{
                           //  dst->_monitor->_entries[dst->_entry_index]._status =
                           //    _MonitorEntry::DYING;
                           //}
                           //else
                           //{
                           //  dst->_monitor->_entries[dst->_entry_index]._status =
                           //    _MonitorEntry::IDLE;
                           //}
   // end Added for PEP 183
                     }                     }
                     else if (entries[indx]._type == Monitor::INTERNAL)                     else if (entries[indx]._type == Monitor::INTERNAL)
                     {                     {
                         _tickler.reset();                          // set ourself to BUSY,
                           // read the data
                           // and set ourself back to IDLE
   
                           entries[indx]._status = _MonitorEntry::BUSY;
                           static char buffer[2];
                           Sint32 amt =
                               Socket::read(entries[indx].socket,&buffer, 2);
   
                           entries[indx]._status = _MonitorEntry::IDLE;
                     }                     }
                     else                     else
                     {                     {
Line 641 
Line 662 
                 {                 {
                 }                 }
             }             }
             // else check for accept pending (ie. SSL handshake pending) or  
             // idle connection timeouts for sockets from which we did not  
             // receive data.  
             else if ((entries[indx]._status.get() == _MonitorEntry::IDLE) &&  
                 entries[indx]._type == Monitor::CONNECTION)  
             {  
                 MessageQueue *q = MessageQueue::lookup(entries[indx].queueId);  
                 HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(q);  
                 dst->_entry_index = indx;  
                 dst->closeConnectionOnTimeout(&timeNow);  
             }  
         }  
     }  
     // else if "events" is zero (ie. select timed out) then we still need  
     // to check if there are any pending SSL handshakes that have timed out.  
     else  
     {  
         for (int indx = 0; indx < (int)entries.size(); indx++)  
         {  
             if ((entries[indx]._status.get() == _MonitorEntry::IDLE) &&  
                 entries[indx]._type == Monitor::CONNECTION)  
             {  
                 MessageQueue *q = MessageQueue::lookup(entries[indx].queueId);  
                 HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(q);  
                 dst->_entry_index = indx;  
                 dst->closeConnectionOnTimeout(&timeNow);  
             }  
         }         }
     }     }
 } }


Legend:
Removed from v.1.121.4.5  
changed lines
  Added in v.1.125

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2