source: squid-ssl/trunk/fuentes/src/StoreClient.h @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 2 years ago

Initial release

File size: 2.7 KB
Line 
1/*
2 * Copyright (C) 1996-2015 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
9#ifndef SQUID_STORECLIENT_H
10#define SQUID_STORECLIENT_H
11
12#include "dlink.h"
13#include "StoreIOBuffer.h"
14#include "StoreIOState.h"
15
16typedef void STCB(void *, StoreIOBuffer);   /* store callback */
17
18class StoreEntry;
19
20class StoreClient
21{
22
23public:
24    virtual ~StoreClient () {}
25
26    virtual void created (StoreEntry *newEntry) = 0;
27};
28
29#if USE_DELAY_POOLS
30#include "DelayId.h"
31#endif
32
33/* keep track each client receiving data from that particular StoreEntry */
34
35class store_client
36{
37
38public:
39    store_client(StoreEntry *);
40    ~store_client();
41    bool memReaderHasLowerOffset(int64_t) const;
42    int getType() const;
43    void fail();
44    void callback(ssize_t len, bool error = false);
45    void doCopy (StoreEntry *e);
46    void readHeader(const char *buf, ssize_t len);
47    void readBody(const char *buf, ssize_t len);
48    void copy(StoreEntry *, StoreIOBuffer, STCB *, void *);
49    void dumpStats(MemBuf * output, int clientNumber) const;
50
51    int64_t cmp_offset;
52#if STORE_CLIENT_LIST_DEBUG
53
54    void *owner;
55#endif
56
57    StoreEntry *entry;      /* ptr to the parent StoreEntry, argh! */
58    StoreIOState::Pointer swapin_sio;
59
60    struct {
61        bool disk_io_pending;
62        bool store_copying;
63        bool copy_event_pending;
64    } flags;
65
66#if USE_DELAY_POOLS
67    DelayId delayId;
68    void setDelayId(DelayId delay_id);
69#endif
70
71    dlink_node node;
72    /* Below here is private - do no alter outside storeClient calls */
73    StoreIOBuffer copyInto;
74
75private:
76    bool moreToSend() const;
77
78    void fileRead();
79    void scheduleDiskRead();
80    void scheduleMemRead();
81    void scheduleRead();
82    bool startSwapin();
83    bool unpackHeader(char const *buf, ssize_t len);
84
85    int type;
86    bool object_ok;
87
88    /* Until we finish stuffing code into store_client */
89
90public:
91
92    struct Callback {
93        Callback ():callback_handler(NULL), callback_data(NULL) {}
94
95        Callback (STCB *, void *);
96        bool pending() const;
97        STCB *callback_handler;
98        void *callback_data;
99    } _callback;
100
101private:
102    CBDATA_CLASS2(store_client);
103};
104
105void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *);
106store_client* storeClientListAdd(StoreEntry * e, void *data);
107int storeClientCopyPending(store_client *, StoreEntry * e, void *data);
108int storeUnregister(store_client * sc, StoreEntry * e, void *data);
109int storePendingNClients(const StoreEntry * e);
110int storeClientIsThisAClient(store_client * sc, void *someClient);
111
112#endif /* SQUID_STORECLIENT_H */
113
Note: See TracBrowser for help on using the repository browser.