]> git.ipfire.org Git - thirdparty/squid.git/blame - src/StoreClient.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / StoreClient.h
CommitLineData
c8be6d7b 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
c8be6d7b 3 *
bbc27441
AJ
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.
c8be6d7b 7 */
8
9#ifndef SQUID_STORECLIENT_H
10#define SQUID_STORECLIENT_H
11
582c2af2 12#include "dlink.h"
c8be6d7b 13#include "StoreIOBuffer.h"
e877aaac 14#include "StoreIOState.h"
c8be6d7b 15
f53969cc 16typedef void STCB(void *, StoreIOBuffer); /* store callback */
c8be6d7b 17
3b13a8fd 18class StoreEntry;
e6ccf245 19
62e76326 20class StoreClient
21{
22
e6ccf245 23public:
62e76326 24 virtual ~StoreClient () {}
25
26 virtual void created (StoreEntry *newEntry) = 0;
e6ccf245 27};
e6ccf245 28
9a0a18de 29#if USE_DELAY_POOLS
b67e2c8c 30#include "DelayId.h"
31#endif
32
c8be6d7b 33/* keep track each client receiving data from that particular StoreEntry */
62e76326 34
35class store_client
36{
5c2f68b7 37 CBDATA_CLASS(store_client);
62e76326 38
528b2c61 39public:
528b2c61 40 store_client(StoreEntry *);
2f44bd34 41 ~store_client();
47f6e231 42 bool memReaderHasLowerOffset(int64_t) const;
528b2c61 43 int getType() const;
44 void fail();
45 void callback(ssize_t len, bool error = false);
46 void doCopy (StoreEntry *e);
47 void readHeader(const char *buf, ssize_t len);
beae59b0 48 void readBody(const char *buf, ssize_t len);
528b2c61 49 void copy(StoreEntry *, StoreIOBuffer, STCB *, void *);
fcc35180 50 void dumpStats(MemBuf * output, int clientNumber) const;
528b2c61 51
47f6e231 52 int64_t cmp_offset;
c8be6d7b 53#if STORE_CLIENT_LIST_DEBUG
62e76326 54
c8be6d7b 55 void *owner;
56#endif
62e76326 57
f53969cc 58 StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
d3b3ab85 59 StoreIOState::Pointer swapin_sio;
62e76326 60
26ac0430 61 struct {
3dd52a0b
FC
62 bool disk_io_pending;
63 bool store_copying;
64 bool copy_event_pending;
3d0ac046 65 } flags;
62e76326 66
9a0a18de 67#if USE_DELAY_POOLS
b67e2c8c 68 DelayId delayId;
69 void setDelayId(DelayId delay_id);
c8be6d7b 70#endif
62e76326 71
c8be6d7b 72 dlink_node node;
73 /* Below here is private - do no alter outside storeClient calls */
74 StoreIOBuffer copyInto;
62e76326 75
528b2c61 76private:
f25d697f
AR
77 bool moreToSend() const;
78
528b2c61 79 void fileRead();
4e70dae3 80 void scheduleDiskRead();
81 void scheduleMemRead();
82 void scheduleRead();
0cdcf3d7 83 bool startSwapin();
528b2c61 84 void unpackHeader(char const *buf, ssize_t len);
62e76326 85
528b2c61 86 int type;
87 bool object_ok;
62e76326 88
90703668 89 /* Until we finish stuffing code into store_client */
90
91public:
92
26ac0430
AJ
93 struct Callback {
94 Callback ():callback_handler(NULL), callback_data(NULL) {}
62e76326 95
96 Callback (STCB *, void *);
90703668 97 bool pending() const;
62e76326 98 STCB *callback_handler;
99 void *callback_data;
2fadd50d 100 } _callback;
c8be6d7b 101};
102
8a648e8d
FC
103void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *);
104store_client* storeClientListAdd(StoreEntry * e, void *data);
105int storeClientCopyPending(store_client *, StoreEntry * e, void *data);
106int storeUnregister(store_client * sc, StoreEntry * e, void *data);
107int storePendingNClients(const StoreEntry * e);
108int storeClientIsThisAClient(store_client * sc, void *someClient);
e87137f1 109
c8be6d7b 110#endif /* SQUID_STORECLIENT_H */
f53969cc 111