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_CACHE_SM_H_
00034 #define _HTTP_CACHE_SM_H_
00035
00036 #include "P_Cache.h"
00037 #include "StatSystem.h"
00038 #include "ProxyConfig.h"
00039 #include "URL.h"
00040 #include "HTTP.h"
00041 #include "HttpConfig.h"
00042
00043 class HttpSM;
00044 class HttpCacheSM;
00045 class CacheLookupHttpConfig;
00046
00047 struct HttpCacheAction:public Action
00048 {
00049 HttpCacheAction();
00050 virtual void cancel(Continuation * c = NULL);
00051 void init(HttpCacheSM * sm_arg)
00052 {
00053 sm = sm_arg;
00054 };
00055 HttpCacheSM *sm;
00056 };
00057
00058 class HttpCacheSM:public Continuation
00059 {
00060 public:
00061 HttpCacheSM();
00062
00063 void init(HttpSM * sm_arg, ProxyMutex * amutex)
00064 {
00065 master_sm = sm_arg;
00066 mutex = amutex;
00067 captive_action.init(this);
00068 }
00069
00070 Action *open_read(URL * url, HTTPHdr * hdr, CacheLookupHttpConfig * params, time_t pin_in_cache);
00071
00072 Action *open_write(URL * url,
00073 HTTPHdr * request, CacheHTTPInfo * old_info, time_t pin_in_cache, bool retry, bool allow_multiple);
00074
00075 CacheVConnection *cache_read_vc;
00076 CacheVConnection *cache_write_vc;
00077
00078 bool read_locked;
00079 bool write_locked;
00080
00081 bool readwhilewrite_inprogress;
00082
00083 HttpSM *master_sm;
00084 Action *pending_action;
00085
00086
00087 inline void set_readwhilewrite_inprogress(bool value)
00088 {
00089 readwhilewrite_inprogress = value;
00090 }
00091
00092
00093 inline bool is_readwhilewrite_inprogress()
00094 {
00095 return readwhilewrite_inprogress;
00096 }
00097
00098 inline void abort_read()
00099 {
00100 if (cache_read_vc) {
00101 HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat);
00102 cache_read_vc->do_io(VIO::ABORT);
00103 cache_read_vc = NULL;
00104 }
00105 }
00106 inline void abort_write()
00107 {
00108 if (cache_write_vc) {
00109 HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat);
00110 cache_write_vc->do_io(VIO::ABORT);
00111 cache_write_vc = NULL;
00112 }
00113 }
00114 inline void close_write()
00115 {
00116 if (cache_write_vc) {
00117 HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat);
00118 cache_write_vc->do_io(VIO::CLOSE);
00119 cache_write_vc = NULL;
00120 }
00121 }
00122 inline void close_read()
00123 {
00124 if (cache_read_vc) {
00125 HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat);
00126 cache_read_vc->do_io(VIO::CLOSE);
00127 cache_read_vc = NULL;
00128 }
00129 }
00130 inline void end_both()
00131 {
00132
00133
00134 close_read();
00135 abort_write();
00136 }
00137 inline URL *get_lookup_url()
00138 {
00139 return lookup_url;
00140 }
00141 inline void set_lookup_url(URL * url)
00142 {
00143 lookup_url = url;
00144 }
00145
00146 private:
00147
00148 void do_schedule_in();
00149 Action *do_cache_open_read();
00150
00151 int state_cache_open_read(int event, void *data);
00152 int state_cache_open_write(int event, void *data);
00153
00154 HttpCacheAction captive_action;
00155 bool open_read_cb;
00156 bool open_write_cb;
00157
00158
00159 int open_read_tries;
00160 HTTPHdr *read_request_hdr;
00161 CacheLookupHttpConfig *read_config;
00162 time_t read_pin_in_cache;
00163
00164
00165 bool retry_write;
00166 int open_write_tries;
00167
00168
00169 URL *lookup_url;
00170
00171
00172 int lookup_max_recursive;
00173 int current_lookup_level;
00174 };
00175
00176 #endif