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