]>
Commit | Line | Data |
---|---|---|
9a9954ba AR |
1 | #ifndef SQUID_TRANSIENTS_H |
2 | #define SQUID_TRANSIENTS_H | |
3 | ||
4 | #include "http/MethodType.h" | |
5 | #include "ipc/mem/Page.h" | |
6 | #include "ipc/mem/PageStack.h" | |
7 | #include "ipc/StoreMap.h" | |
8 | #include "Store.h" | |
6919be24 | 9 | #include <vector> |
9a9954ba AR |
10 | |
11 | // StoreEntry restoration info not already stored by Ipc::StoreMap | |
12 | struct TransientsMapExtras { | |
13 | char url[MAX_URL+1]; ///< Request-URI; TODO: decrease MAX_URL by one | |
14 | RequestFlags reqFlags; ///< request flags | |
15 | Http::MethodType reqMethod; ///< request method; extensions are not supported | |
16 | }; | |
17 | typedef Ipc::StoreMapWithExtras<TransientsMapExtras> TransientsMap; | |
18 | ||
e4d13993 AR |
19 | /// Keeps track of store entries being delivered to clients that arrived before |
20 | /// those entries were [fully] cached. This shared table is necessary to sync | |
21 | /// the entry-writing worker with entry-reading worker(s). | |
9a9954ba AR |
22 | class Transients: public Store, public Ipc::StoreMapCleaner |
23 | { | |
24 | public: | |
25 | Transients(); | |
26 | virtual ~Transients(); | |
27 | ||
6919be24 AR |
28 | /// return a local, previously collapsed entry |
29 | StoreEntry *findCollapsed(const sfileno xitIndex); | |
30 | ||
9a9954ba | 31 | /// add an in-transit entry suitable for collapsing future requests |
99921d9d AR |
32 | void startWriting(StoreEntry *e, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod); |
33 | ||
34 | /// called when the in-transit entry has been successfully cached | |
35 | void completeWriting(const StoreEntry &e); | |
9a9954ba | 36 | |
4475555f AR |
37 | /// the calling entry writer no longer expects to cache this entry |
38 | void abandon(const StoreEntry &e); | |
9a9954ba | 39 | |
4475555f AR |
40 | /// whether an in-transit entry is now abandoned by its writer |
41 | bool abandoned(const StoreEntry &e) const; | |
42 | ||
d366a7fa AR |
43 | /// number of entry readers some time ago |
44 | int readers(const StoreEntry &e) const; | |
45 | ||
99921d9d | 46 | /// the caller is done writing or reading this entry |
4475555f | 47 | void disconnect(MemObject &mem_obj); |
9a9954ba AR |
48 | |
49 | /* Store API */ | |
50 | virtual int callback(); | |
51 | virtual StoreEntry * get(const cache_key *); | |
52 | virtual void get(String const key , STOREGETCLIENT callback, void *cbdata); | |
53 | virtual void init(); | |
54 | virtual uint64_t maxSize() const; | |
55 | virtual uint64_t minSize() const; | |
56 | virtual uint64_t currentSize() const; | |
57 | virtual uint64_t currentCount() const; | |
58 | virtual int64_t maxObjectSize() const; | |
59 | virtual void getStats(StoreInfoStats &stats) const; | |
60 | virtual void stat(StoreEntry &) const; | |
61 | virtual StoreSearch *search(String const url, HttpRequest *); | |
62 | virtual void reference(StoreEntry &); | |
63 | virtual bool dereference(StoreEntry &, bool); | |
1bfe9ade | 64 | virtual void markForUnlink(StoreEntry &e); |
9a9954ba AR |
65 | virtual void maintain(); |
66 | ||
67 | static int64_t EntryLimit(); | |
68 | ||
69 | protected: | |
4475555f | 70 | StoreEntry *copyFromShm(const sfileno index); |
9a9954ba AR |
71 | bool copyToShm(const StoreEntry &e, const sfileno index, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod); |
72 | ||
4475555f AR |
73 | bool abandonedAt(const sfileno index) const; |
74 | ||
9a9954ba AR |
75 | // Ipc::StoreMapCleaner API |
76 | virtual void noteFreeMapSlice(const sfileno sliceId); | |
77 | ||
78 | private: | |
6919be24 AR |
79 | /// shared packed info indexed by Store keys, for creating new StoreEntries |
80 | TransientsMap *map; | |
81 | ||
82 | typedef std::vector<StoreEntry*> Locals; | |
83 | /// local collapsed entries indexed by transient ID, for syncing old StoreEntries | |
84 | Locals *locals; | |
9a9954ba AR |
85 | }; |
86 | ||
87 | // TODO: Why use Store as a base? We are not really a cache. | |
88 | ||
e4d13993 | 89 | #endif /* SQUID_TRANSIENTS_H */ |