]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ClientInfo.h
1 #ifndef SQUID__SRC_CLIENTINFO_H
2 #define SQUID__SRC_CLIENTINFO_H
7 #include "ip/Address.h"
19 hash_link hash
; /* must be first */
24 int result_hist
[ LOG_TYPE_MAX
];
36 int n_established
; /* number of current established connections */
39 double writeSpeedLimit
; ///< Write speed limit in bytes per second, can be less than 1, if too close to zero this could result in timeouts from client
40 double prevTime
; ///< previous time when we checked
41 double bucketSize
; ///< how much can be written now
42 double bucketSizeLimit
; ///< maximum bucket size
43 bool writeLimitingActive
; ///< Is write limiter active
44 bool firstTimeConnection
; ///< is this first time connection for this client
46 CommQuotaQueue
* quotaQueue
; ///< clients waiting for more write quota
47 int rationedQuota
; ///< precomputed quota preserving fairness among clients
48 int rationedCount
; ///< number of clients that will receive rationedQuota
49 bool selectWaiting
; ///< is between commSetSelect and commHandleWrite
50 bool eventWaiting
; ///< waiting for commHandleWriteHelper event to fire
52 // all those functions access Comm fd_table and are defined in comm.cc
53 bool hasQueue () const ; ///< whether any clients are waiting for write quota
54 bool hasQueue ( const CommQuotaQueue
*) const ; ///< has a given queue
55 unsigned int quotaEnqueue ( int fd
); ///< client starts waiting in queue; create the queue if necessary
56 int quotaPeekFd () const ; ///< retuns the next fd reservation
57 unsigned int quotaPeekReserv () const ; ///< returns the next reserv. to pop
58 void quotaDequeue (); ///< pops queue head from queue
59 void kickQuotaQueue (); ///< schedule commHandleWriteHelper call
60 int quotaForDequed (); ///< allocate quota for a just dequeued client
61 void refillBucket (); ///< adds bytes to bucket based on rate and time
63 void quotaDumpQueue (); ///< dumps quota queue for debugging
66 * Configure client write limiting (note:"client" here means - IP). It is called
67 * by httpAccept in client_side.cc, where the initial bucket size (anInitialBurst)
68 * computed, using the configured maximum bucket vavlue and configured initial
69 * bucket value(50% by default).
71 * \param writeSpeedLimit is speed limit configured in config for this pool
72 * \param initialBurst is initial bucket size to use for this client(i.e. client can burst at first)
73 * \param highWatermark is maximum bucket value
75 void setWriteLimiter ( const int aWriteSpeedLimit
, const double anInitialBurst
, const double aHighWatermark
);
76 #endif /* USE_DELAY_POOLS */
80 // a queue of Comm clients waiting for I/O quota controlled by delay pools
84 CommQuotaQueue ( ClientInfo
* info
);
87 bool empty () const { return fds
. empty (); }
88 size_t size () const { return fds
. size (); }
89 int front () const { return fds
. front (); }
90 unsigned int enqueue ( int fd
);
93 ClientInfo
* clientInfo
; ///< bucket responsible for quota maintenance
95 // these counters might overflow; that is OK because they are for IDs only
96 int ins
; ///< number of enqueue calls, used to generate a "reservation" ID
97 int outs
; ///< number of dequeue calls, used to check the "reservation" ID
100 // TODO: optimize using a Ring- or List-based store?
101 typedef std :: deque
< int > Store
;
102 Store fds
; ///< descriptor queue
104 CBDATA_CLASS2 ( CommQuotaQueue
);
106 #endif /* USE_DELAY_POOLS */