Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _HTTP_SERVER_SESSION_H_
00034 #define _HTTP_SERVER_SESSION_H_
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define LAZY_BUF_ALLOC
00046
00047 #include "P_Net.h"
00048
00049 #include "HttpConnectionCount.h"
00050 #include "HttpProxyAPIEnums.h"
00051
00052 class HttpSM;
00053 class MIOBuffer;
00054 class IOBufferReader;
00055
00056 enum HSS_State {
00057 HSS_INIT,
00058 HSS_ACTIVE,
00059 HSS_KA_CLIENT_SLAVE,
00060 HSS_KA_SHARED
00061 };
00062
00063 enum {
00064 HTTP_SS_MAGIC_ALIVE = 0x0123FEED,
00065 HTTP_SS_MAGIC_DEAD = 0xDEADFEED
00066 };
00067
00068 class HttpServerSession : public VConnection
00069 {
00070 public:
00071 HttpServerSession()
00072 : VConnection(NULL),
00073 hostname_hash(),
00074 con_id(0), transact_count(0),
00075 state(HSS_INIT), to_parent_proxy(false), server_trans_stat(0),
00076 private_session(false),
00077 sharing_match(TS_SERVER_SESSION_SHARING_MATCH_BOTH),
00078 sharing_pool(TS_SERVER_SESSION_SHARING_POOL_GLOBAL),
00079 enable_origin_connection_limiting(false),
00080 connection_count(NULL), read_buffer(NULL),
00081 server_vc(NULL), magic(HTTP_SS_MAGIC_DEAD), buf_reader(NULL)
00082 {
00083 ink_zero(server_ip);
00084 }
00085
00086 void destroy();
00087 void new_connection(NetVConnection *new_vc);
00088
00089 void reset_read_buffer(void)
00090 {
00091 ink_assert(read_buffer->_writer);
00092 ink_assert(buf_reader != NULL);
00093 read_buffer->dealloc_all_readers();
00094 read_buffer->_writer = NULL;
00095 buf_reader = read_buffer->alloc_reader();
00096 }
00097
00098 IOBufferReader *get_reader()
00099 {
00100 return buf_reader;
00101 };
00102
00103 virtual VIO *do_io_read(Continuation *c, int64_t nbytes = INT64_MAX, MIOBuffer *buf = 0);
00104
00105 virtual VIO *do_io_write(Continuation *c = NULL, int64_t nbytes = INT64_MAX, IOBufferReader *buf = 0, bool owner = false);
00106
00107 virtual void do_io_close(int lerrno = -1);
00108 virtual void do_io_shutdown(ShutdownHowTo_t howto);
00109
00110 virtual void reenable(VIO *vio);
00111
00112 void release();
00113 void attach_hostname(const char *hostname);
00114 NetVConnection *get_netvc()
00115 {
00116 return server_vc;
00117 };
00118
00119
00120 IpEndpoint server_ip;
00121 INK_MD5 hostname_hash;
00122
00123 int64_t con_id;
00124 int transact_count;
00125 HSS_State state;
00126
00127
00128
00129
00130
00131
00132 bool to_parent_proxy;
00133
00134
00135
00136 int server_trans_stat;
00137
00138
00139
00140 bool private_session;
00141
00142
00143 TSServerSessionSharingMatchType sharing_match;
00144 TSServerSessionSharingPoolType sharing_pool;
00145
00146
00147 LINK(HttpServerSession, ip_hash_link);
00148 LINK(HttpServerSession, host_hash_link);
00149
00150
00151
00152 bool enable_origin_connection_limiting;
00153 ConnectionCount *connection_count;
00154
00155
00156
00157
00158
00159
00160
00161
00162 MIOBuffer *read_buffer;
00163
00164 private:
00165 HttpServerSession(HttpServerSession &);
00166
00167 NetVConnection *server_vc;
00168 int magic;
00169
00170 IOBufferReader *buf_reader;
00171 };
00172
00173 extern ClassAllocator<HttpServerSession> httpServerSessionAllocator;
00174
00175 inline void
00176 HttpServerSession::attach_hostname(const char *hostname)
00177 {
00178 if (CRYPTO_HASH_ZERO == hostname_hash) {
00179 ink_code_md5((unsigned char *) hostname, strlen(hostname), (unsigned char *) &hostname_hash);
00180 }
00181 }
00182 #endif