]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceFormat Enforcement
authorAutomatic source maintenance <squidadm@squid-cache.org>
Tue, 26 Oct 2010 00:17:17 +0000 (18:17 -0600)
committerAutomatic source maintenance <squidadm@squid-cache.org>
Tue, 26 Oct 2010 00:17:17 +0000 (18:17 -0600)
src/ClientDelayConfig.cc
src/ClientDelayConfig.h
src/ClientInfo.h
src/client_db.cc
src/client_side.cc
src/comm.cc

index 12366f2f0657ef37c9ed35d15f3b9a66e5bcc918..d2c1369947871414ac165e24c98518ed696afbfe 100644 (file)
@@ -23,10 +23,10 @@ ClientDelayConfig::finalize()
         /* pools require explicit 'allow' to assign a client into them */
         if (!pools[i].access) {
             debugs(77, DBG_IMPORTANT, "client_delay_pool #" << (i+1) <<
-               " has no client_delay_access configured. " <<
-               "No client will ever use it.");
-               }
-       }
+                   " has no client_delay_access configured. " <<
+                   "No client will ever use it.");
+        }
+    }
 }
 
 void ClientDelayConfig::freePoolCount()
@@ -51,8 +51,7 @@ void ClientDelayConfig::parsePoolCount()
     }
     u_short pools_;
     ConfigParser::ParseUShort(&pools_);
-    for (int i = 0; i < pools_; i++)
-    {
+    for (int i = 0; i < pools_; i++) {
         pools.push_back(ClientDelayPool());
     }
 }
@@ -90,8 +89,7 @@ void ClientDelayConfig::parsePoolAccess(ConfigParser &parser)
 
 void ClientDelayConfig::clean()
 {
-    for (unsigned int i = 0; i < pools.size(); i++)
-    {
+    for (unsigned int i = 0; i < pools.size(); i++) {
         aclDestroyAccessList(&pools[i].access);
     }
 }
index 8694869b1ca6d10998ddb7d12e8dff8e52ec8aaa..d48f93d60093c8eba6b35d57c6725c124f9a45c6 100644 (file)
@@ -13,8 +13,7 @@ class ClientDelayPool
 {
 public:
     ClientDelayPool()
-    :   access(NULL), rate(0), highwatermark(0)
-    {}
+            :   access(NULL), rate(0), highwatermark(0) {}
     void dump (StoreEntry * entry, unsigned int poolNumberMinusOne) const;
     acl_access *access;
     int rate;
@@ -28,8 +27,7 @@ class ClientDelayConfig
 {
 public:
     ClientDelayConfig()
-        :   initial(50)
-    {}
+            :   initial(50) {}
     void freePoolCount();
     void dumpPoolCount(StoreEntry * entry, const char *name) const;
     /* parsing of client_delay_pools - number of pools */
index e9a75963c085150fe8dcd77698260676354bfcca..f95fa55e7b86011641f447b31adb95737546580c 100644 (file)
@@ -35,11 +35,11 @@ public:
     int n_established;          /* number of current established connections */
     time_t last_seen;
 #if DELAY_POOLS
-    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 
-    double prevTime; ///< previous time when we checked 
+    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
+    double prevTime; ///< previous time when we checked
     double bucketSize; ///< how much can be written now
     double bucketSizeLimit;  ///< maximum bucket size
-    bool writeLimitingActive; ///< Is write limiter active 
+    bool writeLimitingActive; ///< Is write limiter active
     bool firstTimeConnection;///< is this first time connection for this client
 
     CommQuotaQueue *quotaQueue; ///< clients waiting for more write quota
@@ -60,17 +60,17 @@ public:
     void refillBucket(); ///< adds bytes to bucket based on rate and time
 
     void quotaDumpQueue(); ///< dumps quota queue for debugging
-   
-/**
- * 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 vavlue and configured initial 
- * bucket value(50% by default).
- *
- * \param  writeSpeedLimit is speed limit configured in config for this pool
- * \param  initialBurst is initial bucket size to use for this client(i.e. client can burst at first)
- *  \param highWatermark is maximum bucket value
- */
+
+    /**
    * 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 vavlue and configured initial
    * bucket value(50% by default).
    *
    * \param  writeSpeedLimit is speed limit configured in config for this pool
    * \param  initialBurst is initial bucket size to use for this client(i.e. client can burst at first)
    *  \param highWatermark is maximum bucket value
    */
     void setWriteLimiter(const int aWriteSpeedLimit, const double anInitialBurst, const double aHighWatermark);
 #endif
 };
@@ -88,7 +88,7 @@ public:
     int front() const { return fds.front(); }
     unsigned int enqueue(int fd);
     void dequeue();
-    
+
     ClientInfo *clientInfo; ///< bucket responsible for quota maintenance
 
     // these counters might overflow; that is OK because they are for IDs only
index 10312c9eda53375e918f49b5c577c95e426a4124..aec780da227ebd7746ef22299f74a57f2a9531f7 100644 (file)
@@ -135,8 +135,7 @@ ClientInfo * clientdbGetInfo(const Ip::Address &addr)
     addr.NtoA(key,MAX_IPSTRLEN);
 
     c = (ClientInfo *) hash_lookup(client_table, key);
-    if (c==NULL)
-    {
+    if (c==NULL) {
         debugs(77,1,"Client db does not contain information for given IP address "<<(const char*)key);
         return NULL;
     }
@@ -353,7 +352,7 @@ clientdbFreeItem(void *data)
         q->clientInfo = NULL;
         delete q; // invalidates cbdata, cancelling any pending kicks
         cbdataReferenceDone(q);
-       }
+    }
 #endif
 
     memFree(c, MEM_CLIENT_INFO);
index a738bf47e68b5926abdb31d8bfa56dc12f7f048e..5c70177abe1b4d4f74a91fbbcf8c1e7d4ffb8b16 100644 (file)
@@ -3155,8 +3155,7 @@ httpAccept(int sock, int newfd, ConnectionDetail *details,
 #if DELAY_POOLS
     fd_table[newfd].clientInfo = NULL;
 
-    if (Config.onoff.client_db)
-    {
+    if (Config.onoff.client_db) {
         /* it was said several times that client write limiter does not work if client_db is disabled */
 
         ClientDelayPools& pools(Config.ClientDelay.pools);
@@ -3168,7 +3167,7 @@ httpAccept(int sock, int newfd, ConnectionDetail *details,
 
             ACLFilledChecklist ch(pools[pool].access, NULL, NULL);
 
-            // TODO: we check early to limit error response bandwith but we 
+            // TODO: we check early to limit error response bandwith but we
             // should recheck when we can honor delay_pool_uses_indirect
 
             ch.src_addr = details->peer;
@@ -3186,7 +3185,7 @@ httpAccept(int sock, int newfd, ConnectionDetail *details,
 
                 /* setup write limiter for this request */
                 const double burst = floor(0.5 +
-                    (pools[pool].highwatermark * Config.ClientDelay.initial)/100.0);
+                                           (pools[pool].highwatermark * Config.ClientDelay.initial)/100.0);
                 cli->setWriteLimiter(pools[pool].rate, burst, pools[pool].highwatermark);
                 break;
             }
index 60eade943529b8274c8a796096cb782123e21018..f6ddba52736956079a93d588260966dc2b81272f 100644 (file)
@@ -1617,7 +1617,7 @@ _comm_close(int fd, char const *file, int line)
             // kick queue or it will get stuck as commWriteHandle is not called
             clientInfo->kickQuotaQueue();
         }
-     }
+    }
 #endif
 
     commCallCloseHandlers(fd);
@@ -1977,7 +1977,7 @@ commHandleWriteHelper(void * data)
     ClientInfo *clientInfo = queue->clientInfo;
     // ClientInfo invalidates queue if freed, so if we got here through,
     // evenAdd cbdata protections, everything should be valid and consistent
-    assert(clientInfo); 
+    assert(clientInfo);
     assert(clientInfo->hasQueue());
     assert(clientInfo->hasQueue(queue));
     assert(!clientInfo->selectWaiting);
@@ -1990,17 +1990,17 @@ commHandleWriteHelper(void * data)
         comm_io_callback_t *ccb = COMMIO_FD_WRITECB(head);
 
         if (fd_table[head].clientInfo == clientInfo &&
-            clientInfo->quotaPeekReserv() == ccb->quotaQueueReserv &&
-            !fd_table[head].closing()) {
+                clientInfo->quotaPeekReserv() == ccb->quotaQueueReserv &&
+                !fd_table[head].closing()) {
 
             // wait for the head descriptor to become ready for writing
             commSetSelect(head, COMM_SELECT_WRITE, commHandleWrite, ccb, 0);
             clientInfo->selectWaiting = true;
             return;
-         }
+        }
 
-         clientInfo->quotaDequeue(); // remove the no longer relevant descriptor
-         // and continue looking for a relevant one
+        clientInfo->quotaDequeue(); // remove the no longer relevant descriptor
+        // and continue looking for a relevant one
     } while (clientInfo->hasQueue());
 
     debugs(77,3, HERE << "emptied queue");
@@ -2059,7 +2059,7 @@ ClientInfo::kickQuotaQueue()
         // wait at least a second if the bucket is empty
         const double delay = (bucketSize < 1.0) ? 1.0 : 0.0;
         eventAdd("commHandleWriteHelper", &commHandleWriteHelper,
-            quotaQueue, delay, 0, true);
+                 quotaQueue, delay, 0, true);
         eventWaiting = true;
     }
 }
@@ -2084,12 +2084,12 @@ ClientInfo::quotaForDequed()
         // negative bucket sizes after write with rationedCount=1.
         rationedQuota = static_cast<int>(floor(bucketSize/rationedCount));
         debugs(77,5, HERE << "new rationedQuota: " << rationedQuota <<
-            '*' << rationedCount);
+               '*' << rationedCount);
     }
 
     --rationedCount;
     debugs(77,7, HERE << "rationedQuota: " << rationedQuota <<
-        " rations remaining: " << rationedCount);
+           " rations remaining: " << rationedCount);
 
     // update 'last seen' time to prevent clientdb GC from dropping us
     last_seen = squid_curtime;
@@ -2104,27 +2104,27 @@ ClientInfo::refillBucket()
     const double currTime = current_dtime;
     const double timePassed = currTime - prevTime;
 
-    // Calculate allowance for the time passed. Use double to avoid 
+    // Calculate allowance for the time passed. Use double to avoid
     // accumulating rounding errors for small intervals. For example, always
     // adding 1 byte instead of 1.4 results in 29% bandwidth allocation error.
     const double gain = timePassed * writeSpeedLimit;
 
     debugs(77,5, HERE << currTime << " clt" << (const char*)hash.key << ": " <<
-        bucketSize << " + (" << timePassed << " * " << writeSpeedLimit <<
-        " = " << gain << ')');
+           bucketSize << " + (" << timePassed << " * " << writeSpeedLimit <<
+           " = " << gain << ')');
 
     // to further combat error accumulation during micro updates,
     // quit before updating time if we cannot add at least one byte
     if (gain < 1.0)
-       return;
+        return;
 
     prevTime = currTime;
 
     // for "first" connections, drain initial fat before refilling but keep
     // updating prevTime to avoid bursts after the fat is gone
     if (bucketSize > bucketSizeLimit) {
-       debugs(77,4, HERE << "not refilling while draining initial fat");
-       return;
+        debugs(77,4, HERE << "not refilling while draining initial fat");
+        return;
     }
 
     bucketSize += gain;
@@ -2134,12 +2134,12 @@ ClientInfo::refillBucket()
         bucketSize = bucketSizeLimit;
 }
 
-void 
+void
 ClientInfo::setWriteLimiter(const int aWriteSpeedLimit, const double anInitialBurst, const double aHighWatermark)
 {
-    debugs(77,5, HERE << "Write limits for " << (const char*)hash.key << 
-        " speed=" << aWriteSpeedLimit << " burst=" << anInitialBurst <<
-        " highwatermark=" << aHighWatermark);
+    debugs(77,5, HERE << "Write limits for " << (const char*)hash.key <<
+           " speed=" << aWriteSpeedLimit << " burst=" << anInitialBurst <<
+           " highwatermark=" << aHighWatermark);
 
     // set or possibly update traffic shaping parameters
     writeLimitingActive = true;
@@ -2161,7 +2161,7 @@ ClientInfo::setWriteLimiter(const int aWriteSpeedLimit, const double anInitialBu
 }
 
 CommQuotaQueue::CommQuotaQueue(ClientInfo *info): clientInfo(info),
-    ins(0), outs(0)
+        ins(0), outs(0)
 {
     assert(clientInfo);
 }
@@ -2176,7 +2176,7 @@ unsigned int
 CommQuotaQueue::enqueue(int fd)
 {
     debugs(77,5, HERE << "clt" << (const char*)clientInfo->hash.key <<
-        ": FD " << fd << " with qqid" << (ins+1) << ' ' << fds.size());
+           ": FD " << fd << " with qqid" << (ins+1) << ' ' << fds.size());
     fds.push_back(fd);
     return ++ins;
 }
@@ -2187,8 +2187,8 @@ CommQuotaQueue::dequeue()
 {
     assert(!fds.empty());
     debugs(77,5, HERE << "clt" << (const char*)clientInfo->hash.key <<
-        ": FD " << fds.front() << " with qqid" << (outs+1) << ' ' <<
-        fds.size());
+           ": FD " << fds.front() << " with qqid" << (outs+1) << ' ' <<
+           fds.size());
     fds.pop_front();
     ++outs;
 }
@@ -2237,7 +2237,7 @@ commHandleWrite(int fd, void *data)
             const int nleft_corrected = min(nleft, quota);
             if (nleft != nleft_corrected) {
                 debugs(5, 5, HERE << "FD " << fd << " writes only " <<
-                    nleft_corrected << " out of " << nleft);
+                       nleft_corrected << " out of " << nleft);
                 nleft = nleft_corrected;
             }
 
@@ -2255,15 +2255,14 @@ commHandleWrite(int fd, void *data)
         if (len > 0) {
             /* we wrote data - drain them from bucket */
             clientInfo->bucketSize -= len;
-            if (clientInfo->bucketSize < 0.0)
-            {
+            if (clientInfo->bucketSize < 0.0) {
                 debugs(5,1, HERE << "drained too much"); // should not happen
                 clientInfo->bucketSize = 0;
             }
-         }
+        }
 
-         // even if we wrote nothing, we were served; give others a chance
-         clientInfo->kickQuotaQueue();
+        // even if we wrote nothing, we were served; give others a chance
+        clientInfo->kickQuotaQueue();
     }
 #endif