(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.130 and 1.136

version 1.130, 2008/02/27 20:21:17 version 1.136, 2008/08/07 18:03:48
Line 39 
Line 39 
 #include "Socket.h" #include "Socket.h"
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/HTTPConnection.h> #include <Pegasus/Common/HTTPConnection.h>
   #include <Pegasus/Common/HTTPAcceptor.h>
 #include <Pegasus/Common/MessageQueueService.h> #include <Pegasus/Common/MessageQueueService.h>
 #include <Pegasus/Common/Exception.h> #include <Pegasus/Common/Exception.h>
 #include "ArrayIterator.h" #include "ArrayIterator.h"
 #include "HostAddress.h" #include "HostAddress.h"
   #include <errno.h>
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
Line 75 
Line 77 
     _uninitialize();     _uninitialize();
 } }
  
   void Tickler::notify()
   {
       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) #if defined(PEGASUS_OS_TYPE_UNIX)
  
 // Use an anonymous pipe for the tickle connection. // Use an anonymous pipe for the tickle connection.
Line 94 
Line 110 
  
     _serverSocket = fds[0];     _serverSocket = fds[0];
     _clientSocket = fds[1];     _clientSocket = fds[1];
   
       Socket::disableBlocking(_serverSocket);
 } }
  
 #else #else
Line 301 
Line 319 
     }     }
     catch (...)     catch (...)
     {     {
         PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4,          PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,
             "Failed to close tickle sockets");             "Failed to close tickle sockets");
     }     }
     Socket::uninitializeInterface();     Socket::uninitializeInterface();
Line 326 
Line 344 
     // 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.
     _entries.append(MonitorEntry(     _entries.append(MonitorEntry(
         _tickler.getServerSocket(),          _tickler.getReadHandle(),
         1,         1,
         MonitorEntry::STATUS_IDLE,         MonitorEntry::STATUS_IDLE,
         MonitorEntry::TYPE_INTERNAL));          MonitorEntry::TYPE_TICKLER));
  
     // Start the count at 1 because _entries[0] is the Tickler     // Start the count at 1 because _entries[0] is the Tickler
     for (int i = 1; i < numberOfMonitorEntriesToAllocate; i++)     for (int i = 1; i < numberOfMonitorEntriesToAllocate; i++)
Line 346 
Line 364 
  
 void Monitor::tickle() void Monitor::tickle()
 { {
     Socket::write(_tickler.getClientSocket(), "\0", 1);      _tickler.notify();
 } }
  
 void Monitor::setState( void Monitor::setState(
Line 427 
Line 445 
                 continue;                 continue;
             }             }
             h._connectionClosePending = false;             h._connectionClosePending = false;
             MessageQueue &o = h.get_owner();              HTTPAcceptor &o = h.getOwningAcceptor();
             Message* message= new CloseConnectionMessage(entry.socket);             Message* message= new CloseConnectionMessage(entry.socket);
             message->dest = o.getQueueId();             message->dest = o.getQueueId();
  
Line 508 
Line 526 
  
     if (events == PEGASUS_SOCKET_ERROR)     if (events == PEGASUS_SOCKET_ERROR)
     {     {
         PEG_TRACE((TRC_HTTP, Tracer::LEVEL4,          PEG_TRACE((TRC_HTTP, Tracer::LEVEL1,
             "Monitor::run - select() returned error %d.", selectErrno));             "Monitor::run - select() returned error %d.", selectErrno));
         // The EBADF error indicates that one or more or the file         // The EBADF error indicates that one or more or the file
         // descriptions was not valid. This could indicate that         // descriptions was not valid. This could indicate that
Line 571 
Line 589 
                             }                             }
                             catch (...)                             catch (...)
                             {                             {
                                 PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,                                  PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL1,
                                     "Caught exception from "                                     "Caught exception from "
                                     "HTTPConnection::run()");                                     "HTTPConnection::run()");
                             }                             }
                             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4,                             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4,
                                 "Exited HTTPConnection::run()");                                 "Exited HTTPConnection::run()");
                             }                             }
   
   
                     }                     }
                     else if (entries[indx].type == MonitorEntry::TYPE_INTERNAL)                      else if (entries[indx].type == MonitorEntry::TYPE_TICKLER)
                     {                     {
                         char buffer;                          _tickler.reset();
                         Sint32 ignored =  
                             Socket::read(entries[indx].socket, &buffer, 1);  
                     }                     }
                     else                     else
                     {                     {
Line 593 
Line 607 
                             "Non-connection entry, indx = %d, has been "                             "Non-connection entry, indx = %d, has been "
                                 "received.",                                 "received.",
                             indx));                             indx));
                         int events = 0;  
                         events |= SocketMessage::READ;  
                         Message* msg = new SocketMessage(                         Message* msg = new SocketMessage(
                             entries[indx].socket, events);                              entries[indx].socket, SocketMessage::READ);
                         entries[indx].status = MonitorEntry::STATUS_BUSY;                         entries[indx].status = MonitorEntry::STATUS_BUSY;
                         _entriesMutex.unlock();                         _entriesMutex.unlock();
                         q->enqueue(msg);                         q->enqueue(msg);
Line 622 
Line 634 
  
             {             {
                 MessageQueue* q = MessageQueue::lookup(entries[indx].queueId);                 MessageQueue* q = MessageQueue::lookup(entries[indx].queueId);
                   PEGASUS_ASSERT(q != 0);
                 HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(q);                 HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(q);
                 dst->_entry_index = indx;                 dst->_entry_index = indx;
                 dst->closeConnectionOnTimeout(&timeNow);                 dst->closeConnectionOnTimeout(&timeNow);
Line 638 
Line 651 
                 entries[indx].type == MonitorEntry::TYPE_CONNECTION)                 entries[indx].type == MonitorEntry::TYPE_CONNECTION)
             {             {
                 MessageQueue* q = MessageQueue::lookup(entries[indx].queueId);                 MessageQueue* q = MessageQueue::lookup(entries[indx].queueId);
                   PEGASUS_ASSERT(q != 0);
                 HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(q);                 HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(q);
                 dst->_entry_index = indx;                 dst->_entry_index = indx;
                 dst->closeConnectionOnTimeout(&timeNow);                 dst->closeConnectionOnTimeout(&timeNow);


Legend:
Removed from v.1.130  
changed lines
  Added in v.1.136

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2