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

  1 kumpf 1.11 //%/////////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 kumpf 1.11 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4 mike  1.2  // The Open Group, Tivoli Systems
  5            //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.11 // of this software and associated documentation files (the "Software"), to
  8            // deal in the Software without restriction, including without limitation the
  9            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.2  // sell copies of the Software, and to permit persons to whom the Software is
 11            // furnished to do so, subject to the following conditions:
 12            // 
 13 kumpf 1.11 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.2  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.11 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.2  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21            //
 22            //==============================================================================
 23            //
 24            // Author: Mike Brasher (mbrasher@bmc.com)
 25            //
 26            // Modified By:
 27            //         Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
 28            //         Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
 29            //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32            #ifndef Pegasus_HTTPConnection_h
 33            #define Pegasus_HTTPConnection_h
 34            
 35            #include <iostream>
 36            #include <Pegasus/Common/Config.h>
 37            #include <Pegasus/Common/MessageQueue.h>
 38            #include <Pegasus/Common/Pair.h>
 39            #include <Pegasus/Common/String.h>
 40 mike  1.2  #include <Pegasus/Common/Message.h>
 41 kumpf 1.14 #include <Pegasus/Common/ArrayInternal.h>
 42 mike  1.2  #include <Pegasus/Common/Monitor.h>
 43            #include <Pegasus/Common/AuthenticationInfo.h>
 44            #include <Pegasus/Common/TLS.h>
 45            #include <Pegasus/Common/HTTPAcceptor.h>
 46 kumpf 1.13 #include <Pegasus/Common/Linkage.h>
 47 mike  1.2  
 48            PEGASUS_NAMESPACE_BEGIN
 49            
 50 mday  1.12 class HTTPConnector;
 51            
 52 mday  1.3  class MessageQueueService;
 53 mike  1.2  struct HTTPConnectionRep;
 54            
 55            /** This message is sent from a connection to its owner (so that the
 56                owner can do any necessary cleanup).
 57            */
 58            class CloseConnectionMessage : public Message
 59            {
 60 mday  1.3     public:
 61 mike  1.2  
 62 mday  1.4        CloseConnectionMessage(Sint32 socket_) 
 63            	 : Message(CLOSE_CONNECTION_MESSAGE), socket(socket_) { }
 64 mike  1.2  
 65 mday  1.4        Sint32 socket;
 66 mike  1.2  };
 67            
 68            /** This class represents an HTTP listener.
 69            */
 70 mday  1.5  class PEGASUS_COMMON_LINKAGE HTTPConnection : public MessageQueue
 71 mike  1.2  {
 72 mday  1.3     public:
 73 mday  1.5        typedef MessageQueue Base;
 74 mday  1.3        
 75 mday  1.4        /** Constructor. */
 76                  HTTPConnection(
 77            	 Monitor* monitor,
 78            	 //Sint32 socket, 
 79            	 MP_Socket * socket, 
 80 mday  1.8  	 MessageQueue * ownerMessageQueue,
 81            	 MessageQueue * outputMessageQueue);
 82                        
 83 mday  1.4  
 84                  /** Destructor. */
 85                  ~HTTPConnection();
 86            
 87                  /** This method is called whenever a SocketMessage is enqueued
 88            	  on the input queue of the HTTPConnection object.
 89                  */ 
 90                  virtual void handleEnqueue(Message *);
 91                  
 92                  virtual void handleEnqueue();
 93 mike  1.2  
 94 mday  1.4        /** Return socket this connection is using. */
 95                  Sint32 getSocket() { return _socket->getSocket();}
 96 mday  1.12       
 97 mday  1.4        /** Return the number of outstanding requests for all HTTPConnection 
 98            	  instances.
 99                  */
100                  Uint32 getRequestCount();
101 mday  1.8  
102                  Boolean run(Uint32 milliseconds);
103            
104                  void lock_connection(void)
105                  {
106 kumpf 1.10          Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
107                        "HTTPConnection::lock_connection - LOCK REQUESTED");
108 mday  1.8  	 _connection_mut.lock(pegasus_thread_self());
109 kumpf 1.10          Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
110                        "HTTPConnection::lock_connection - LOCK ACQUIRED");
111 mday  1.8        }
112                  
113                  void unlock_connection(void)
114                  {
115            	 _connection_mut.unlock();
116 kumpf 1.10          Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
117                        "HTTPConnection::unlock_connection - LOCK RELEASED");
118 mday  1.8        } 
119                  
120                  Boolean is_dying(void)
121                  {
122            	 if( _dying.value() > 0 )
123            	    return true;
124            	 return false;
125                  }
126 mday  1.7        
127 mday  1.8        MessageQueue & get_owner(void)
128                  {
129            	 return *_ownerMessageQueue;
130                  }
131                  
132 kumpf 1.9        // ATTN-RK-P1-20020521: This is a major hack, required to get the CIM
133                  // server and tests to run successfully.  The problem is that the
134                  // HTTPAcceptor is deleting an HTTPConnection before all the threads
135                  // that are queued up to run in that HTTPConnection instance have had
136                  // a chance to finish.  This hack makes the HTTPAcceptor spin until
137                  // the HTTPConnection event threads have completed, before deleting
138                  // the HTTPConnection.  Note that this fix is not perfect, because
139                  // there is a window between when the HTTPConnection queue lookup is
140                  // done and when the refcount is incremented.  If the HTTPAcceptor
141                  // deletes the HTTPConnection in that window, the soon-to-be-launched
142                  // HTTPConnection event thread will fail (hard).
143                  AtomicInt refcount;
144 mday  1.8  
145 mday  1.4     private:
146 mike  1.2  
147 mday  1.4        void _clearIncoming();
148 mike  1.2  
149 mday  1.4        void _getContentLengthAndContentOffset();
150 mike  1.2  
151 mday  1.4        void _closeConnection();
152 mike  1.2  
153 mday  1.4        void _handleReadEvent();
154 mike  1.2  
155 mday  1.4        Monitor* _monitor;
156 mike  1.2  
157 mday  1.4        //Sint32 _socket;
158                  MP_Socket* _socket;
159 mday  1.8        MessageQueue* _ownerMessageQueue;
160                  MessageQueue* _outputMessageQueue;
161 mike  1.2  
162 mday  1.4        Sint32 _contentOffset; 
163                  Sint32 _contentLength;
164                  Array<Sint8> _incomingBuffer;
165                  AuthenticationInfo* _authInfo;
166                  static AtomicInt _requestCount;
167 mday  1.8        Mutex _connection_mut;
168                  AtomicInt _dying;
169 mday  1.12       int _entry_index;
170                  
171                  friend class Monitor;
172                  friend class HTTPAcceptor;
173                  friend class HTTPConnector;
174 mike  1.2  };
175            
176            PEGASUS_NAMESPACE_END
177            
178            #endif /* Pegasus_HTTPConnection_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2