#include <ClientInfo.h>

Inheritance diagram for ClientInfo:
Collaboration diagram for ClientInfo:

Classes

struct  Cutoff
 
struct  Protocol
 

Public Member Functions

 ClientInfo (const Ip::Address &)
 
 ~ClientInfo () override
 
bool hasQueue () const
 whether any clients are waiting for write quota More...
 
bool hasQueue (const CommQuotaQueue *) const
 has a given queue More...
 
unsigned int quotaEnqueue (int fd)
 client starts waiting in queue; create the queue if necessary More...
 
int quotaPeekFd () const
 returns the next fd reservation More...
 
unsigned int quotaPeekReserv () const
 returns the next reserv. to pop More...
 
void quotaDequeue ()
 pops queue head from queue More...
 
void kickQuotaQueue ()
 
void writeOrDequeue ()
 either selects the head descriptor for writing or calls quotaDequeue() More...
 
int quota () override
 allocate quota for a just dequeued client More...
 
bool applyQuota (int &nleft, Comm::IoCallback *state) override
 
void scheduleWrite (Comm::IoCallback *state) override
 Will plan another write call. More...
 
void onFdClosed () override
 Performs cleanup when the related file descriptor becomes closed. More...
 
void reduceBucket (int len) override
 Decreases the bucket level. More...
 
void quotaDumpQueue ()
 dumps quota queue for debugging More...
 
void setWriteLimiter (const int aWriteSpeedLimit, const double anInitialBurst, const double aHighWatermark)
 
bool noLimit () const
 Whether this bucket will not do bandwidth limiting. More...
 

Static Public Member Functions

static BandwidthBucketSelectBucket (fde *f)
 

Public Attributes

Ip::Address addr
 
struct ClientInfo::Protocol Http
 
struct ClientInfo::Protocol Icp
 
struct ClientInfo::Cutoff cutoff
 
int n_established
 
time_t last_seen
 
bool writeLimitingActive
 Is write limiter active. More...
 
bool firstTimeConnection
 is this first time connection for this client More...
 
CommQuotaQueuequotaQueue
 clients waiting for more write quota More...
 
int rationedQuota
 precomputed quota preserving fairness among clients More...
 
int rationedCount
 number of clients that will receive rationedQuota More...
 
bool eventWaiting
 waiting for commHandleWriteHelper event to fire More...
 
void * key
 
hash_linknext
 
double bucketLevel
 how much can be written now More...
 
bool selectWaiting
 is between commSetSelect and commHandleWrite More...
 

Protected Member Functions

void refillBucket ()
 Increases the bucket level with the writeSpeedLimit speed. More...
 

Protected Attributes

double prevTime
 previous time when we checked More...
 
double writeSpeedLimit
 Write speed limit in bytes per second. More...
 
double bucketSizeLimit
 maximum bucket size More...
 

Private Member Functions

 MEMPROXY_CLASS (ClientInfo)
 

Detailed Description

Definition at line 30 of file ClientInfo.h.

Constructor & Destructor Documentation

◆ ClientInfo()

ClientInfo::ClientInfo ( const Ip::Address ip)
explicit

Definition at line 54 of file client_db.cc.

References addr, debugs, hash_link::key, MAX_IPSTRLEN, Ip::Address::toStr(), and xmalloc.

◆ ~ClientInfo()

ClientInfo::~ClientInfo ( )
override

Definition at line 335 of file client_db.cc.

References debugs, hash_link::key, quotaQueue, and safe_free.

Member Function Documentation

◆ applyQuota()

bool ClientInfo::applyQuota ( int nleft,
Comm::IoCallback state 
)
overridevirtual

Adjusts nleft to not exceed the current bucket quota value, if needed.

Reimplemented from BandwidthBucket.

Definition at line 1336 of file comm.cc.

References BandwidthBucket::applyQuota(), assert, Comm::IoCallback::conn, Comm::Connection::fd, hasQueue(), kickQuotaQueue(), quotaDequeue(), quotaEnqueue(), quotaPeekFd(), and Comm::IoCallback::quotaQueueReserv.

◆ hasQueue() [1/2]

bool ClientInfo::hasQueue ( ) const

Definition at line 1246 of file comm.cc.

References assert, CommQuotaQueue::empty(), and quotaQueue.

Referenced by applyQuota(), commHandleWriteHelper(), and kickQuotaQueue().

◆ hasQueue() [2/2]

bool ClientInfo::hasQueue ( const CommQuotaQueue q) const

Definition at line 1253 of file comm.cc.

References assert, and quotaQueue.

◆ kickQuotaQueue()

void ClientInfo::kickQuotaQueue ( )

◆ MEMPROXY_CLASS()

ClientInfo::MEMPROXY_CLASS ( ClientInfo  )
private

◆ noLimit()

bool BandwidthBucket::noLimit ( ) const
inlineinherited

◆ onFdClosed()

void ClientInfo::onFdClosed ( )
overridevirtual

Reimplemented from BandwidthBucket.

Definition at line 1359 of file comm.cc.

References kickQuotaQueue(), and BandwidthBucket::onFdClosed().

◆ quota()

int ClientInfo::quota ( )
overridevirtual

calculates how much to write for a single dequeued client

Implements BandwidthBucket.

Definition at line 1305 of file comm.cc.

References BandwidthBucket::bucketLevel, debugs, last_seen, quotaQueue, rationedCount, rationedQuota, BandwidthBucket::refillBucket(), CommQuotaQueue::size(), and squid_curtime.

◆ quotaDequeue()

void ClientInfo::quotaDequeue ( )

removes queue head

Definition at line 1285 of file comm.cc.

References assert, CommQuotaQueue::dequeue(), and quotaQueue.

Referenced by applyQuota().

◆ quotaDumpQueue()

void ClientInfo::quotaDumpQueue ( )

◆ quotaEnqueue()

unsigned int ClientInfo::quotaEnqueue ( int  fd)

queues a given fd, creating the queue if necessary; returns reservation ID

Definition at line 1277 of file comm.cc.

References assert, CommQuotaQueue::enqueue(), and quotaQueue.

Referenced by applyQuota(), and scheduleWrite().

◆ quotaPeekFd()

int ClientInfo::quotaPeekFd ( ) const

returns the first descriptor to be dequeued

Definition at line 1261 of file comm.cc.

References assert, CommQuotaQueue::front(), and quotaQueue.

Referenced by applyQuota(), and writeOrDequeue().

◆ quotaPeekReserv()

unsigned int ClientInfo::quotaPeekReserv ( ) const

returns the reservation ID of the first descriptor to be dequeued

Definition at line 1269 of file comm.cc.

References assert, CommQuotaQueue::outs, and quotaQueue.

◆ reduceBucket()

void ClientInfo::reduceBucket ( int  len)
overridevirtual

Reimplemented from BandwidthBucket.

Definition at line 1367 of file comm.cc.

References kickQuotaQueue(), and BandwidthBucket::reduceBucket().

◆ refillBucket()

◆ scheduleWrite()

void ClientInfo::scheduleWrite ( Comm::IoCallback state)
overridevirtual

◆ SelectBucket()

BandwidthBucket * BandwidthBucket::SelectBucket ( fde f)
staticinherited

◆ setWriteLimiter()

void ClientInfo::setWriteLimiter ( const int  aWriteSpeedLimit,
const double  anInitialBurst,
const double  aHighWatermark 
)

Configure client write limiting (note:"client" here means - IP). It is called by httpAccept in client_side.cc, where the initial bucket size (anInitialBurst) computed, using the configured maximum bucket value and configured initial bucket value(50% by default).

Parameters
writeSpeedLimitis speed limit configured in config for this pool
initialBurstis initial bucket size to use for this client(i.e. client can burst at first)
highWatermarkis maximum bucket value

Definition at line 1376 of file comm.cc.

References assert, BandwidthBucket::bucketLevel, BandwidthBucket::bucketSizeLimit, current_dtime, debugs, firstTimeConnection, hash_link::key, BandwidthBucket::prevTime, quotaQueue, BandwidthBucket::selectWaiting, writeLimitingActive, and BandwidthBucket::writeSpeedLimit.

Referenced by ConnStateData::whenClientIpKnown().

◆ writeOrDequeue()

void ClientInfo::writeOrDequeue ( )

Definition at line 1224 of file comm.cc.

References assert, CallBack(), fd_table, head, quotaPeekFd(), and BandwidthBucket::selectWaiting.

Referenced by commHandleWriteHelper().

Member Data Documentation

◆ addr

Ip::Address ClientInfo::addr

Definition at line 45 of file ClientInfo.h.

Referenced by ClientInfo(), client_entry(), clientdbDump(), and snmp_meshCtblFn().

◆ bucketLevel

double BandwidthBucket::bucketLevel
inherited

◆ bucketSizeLimit

double BandwidthBucket::bucketSizeLimit
protectedinherited

Definition at line 54 of file BandwidthBucket.h.

Referenced by BandwidthBucket::refillBucket(), and setWriteLimiter().

◆ cutoff

struct ClientInfo::Cutoff ClientInfo::cutoff

Referenced by clientdbCutoffDenied().

◆ eventWaiting

bool ClientInfo::eventWaiting

Definition at line 75 of file ClientInfo.h.

Referenced by commHandleWriteHelper(), and kickQuotaQueue().

◆ firstTimeConnection

bool ClientInfo::firstTimeConnection

Definition at line 70 of file ClientInfo.h.

Referenced by setWriteLimiter().

◆ Http

◆ Icp

◆ key

void* hash_link::key
inherited

◆ last_seen

time_t ClientInfo::last_seen

Definition at line 67 of file ClientInfo.h.

Referenced by clientdbGC(), clientdbUpdate(), and quota().

◆ n_established

int ClientInfo::n_established

Definition at line 66 of file ClientInfo.h.

Referenced by clientdbDump(), clientdbEstablished(), and clientdbGC().

◆ next

◆ prevTime

double BandwidthBucket::prevTime
protectedinherited

◆ quotaQueue

◆ rationedCount

int ClientInfo::rationedCount

Definition at line 74 of file ClientInfo.h.

Referenced by quota().

◆ rationedQuota

int ClientInfo::rationedQuota

Definition at line 73 of file ClientInfo.h.

Referenced by quota().

◆ selectWaiting

bool BandwidthBucket::selectWaiting
inherited

◆ writeLimitingActive

bool ClientInfo::writeLimitingActive

Definition at line 69 of file ClientInfo.h.

Referenced by scheduleWrite(), BandwidthBucket::SelectBucket(), and setWriteLimiter().

◆ writeSpeedLimit

double BandwidthBucket::writeSpeedLimit
protectedinherited

The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors