]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayUser.cc
3 * $Id: DelayUser.cc,v 1.2 2003/02/06 09:57:36 robertc Exp $
5 * DEBUG: section 77 Delay Pools
6 * AUTHOR: Robert Collins <robertc@squid-cache.org>
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
35 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
42 #include "DelayUser.h"
43 #include "authenticate.h"
44 #include "NullDelayId.h"
48 DelayUser::operator new(size_t size
)
50 DelayPools::MemoryUsed
+= sizeof (DelayUser
);
51 return ::operator new (size
);
55 DelayUser::operator delete (void *address
)
57 DelayPools::MemoryUsed
-= sizeof (DelayUser
);
58 ::operator delete (address
);
62 DelayUser::deleteSelf() const
67 DelayUser::DelayUser()
69 DelayPools::registerForUpdates (this);
72 DelayUser::~DelayUser()
74 DelayPools::deregisterForUpdates (this);
78 DelayUser::stats(StoreEntry
* sentry
)
80 spec
.stats (sentry
, "Per User");
81 if (spec
.restore_bps
== -1)
83 storeAppendPrintf(sentry
, "\t\tCurrent: ");
84 if (!buckets
.size()) {
85 storeAppendPrintf (sentry
, "Not used yet.\n\n");
88 iterator pos
= buckets
.begin();
89 while (pos
!= buckets
.end()) {
90 (*pos
)->stats(sentry
);
93 storeAppendPrintf(sentry
, "\n\n");
97 DelayUser::dump(StoreEntry
*entry
) const
103 DelayUser::update(int incr
)
105 iterator pos
= buckets
.begin();
106 while (pos
!= buckets
.end()) {
107 (*pos
)->theBucket
.update(spec
, incr
);
118 DelayIdComposite::Pointer
119 DelayUser::id(struct in_addr
&src_addr
, AuthUserRequest
*authRequest
)
122 return new NullDelayId
;
123 return new Id(this, authRequest
->auth_user
);
127 DelayUser::Id::operator new(size_t size
)
129 DelayPools::MemoryUsed
+= sizeof (Id
);
130 return ::operator new (size
);
134 DelayUser::Id::operator delete (void *address
)
136 DelayPools::MemoryUsed
-= sizeof (Id
);
137 ::operator delete (address
);
141 DelayUser::Id::deleteSelf() const
147 DelayUserBucket::operator new(size_t size
)
149 DelayPools::MemoryUsed
+= sizeof (DelayUserBucket
);
150 return ::operator new (size
);
154 DelayUserBucket::operator delete (void *address
)
156 DelayPools::MemoryUsed
-= sizeof (DelayUserBucket
);
157 ::operator delete (address
);
160 DelayUserBucket::DelayUserBucket(AuthUser
*aUser
) : authUser (aUser
)
162 debug (77,3) ("DelayUserBucket::DelayUserBucket\n");
163 authenticateAuthUserLock (authUser
);
166 DelayUserBucket::~DelayUserBucket()
168 authenticateAuthUserUnlock(authUser
);
169 debug (77,3) ("DelayUserBucket::~DelayUserBucket\n");
173 DelayUserBucket::stats (StoreEntry
*entry
) const
175 storeAppendPrintf(entry
, " %s:", authUser
->username());
176 theBucket
.stats (entry
);
179 DelayUser::Id::Id(DelayUser::Pointer aDelayUser
,AuthUser
*aUser
) : theUser(aDelayUser
)
181 DelayUser::iterator pos
= theUser
->buckets
.begin();
182 while (pos
!= theUser
->buckets
.end()) {
183 if ((*pos
)->authUser
== aUser
) {
190 theBucket
= new DelayUserBucket(aUser
);
191 theBucket
->theBucket
.init(theUser
->spec
);
192 theUser
->buckets
.push_back (theBucket
);
197 debug (77,3) ("DelayUser::Id::~Id\n");
201 DelayUser::Id::bytesWanted (int min
, int max
) const
203 return theBucket
->theBucket
.bytesWanted(min
,max
);
207 DelayUser::Id::bytesIn(int qty
)
209 theBucket
->theBucket
.bytesIn(qty
);