]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayPool.cc
Summary: Remove the unneeded 'deleteSelf' idiom.
[thirdparty/squid.git] / src / DelayPool.cc
1
2 /*
3 * $Id: DelayPool.cc,v 1.5 2003/08/04 22:14:40 robertc Exp $
4 *
5 * DEBUG: section 77 Delay Pools
6 * AUTHOR: Robert Collins <robertc@squid-cache.org>
7 * Based upon original delay pools code by
8 * David Luyer <david@luyer.net>
9 *
10 * SQUID Web Proxy Cache http://www.squid-cache.org/
11 * ----------------------------------------------------------
12 *
13 * Squid is the result of efforts by numerous individuals from
14 * the Internet community; see the CONTRIBUTORS file for full
15 * details. Many organizations have provided support for Squid's
16 * development; see the SPONSORS file for full details. Squid is
17 * Copyrighted (C) 2001 by the Regents of the University of
18 * California; see the COPYRIGHT file for full details. Squid
19 * incorporates software developed and/or copyrighted by other
20 * sources; see the CREDITS file for full details.
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
35 *
36 *
37 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
38 */
39
40 #include "config.h"
41
42 #if DELAY_POOLS
43 #include "DelayPool.h"
44 #include "CommonPool.h"
45 #include "ACL.h"
46 #include "Store.h"
47
48 DelayPool::DelayPool() : pool (NULL), access (NULL)
49 {
50 pool = CommonPool::Factory(0, theComposite_);
51 }
52
53 DelayPool::~DelayPool()
54 {
55 if (pool)
56 freeData();
57
58 if (access)
59 aclDestroyAccessList(&access);
60 }
61
62 void
63 DelayPool::parse()
64 {
65 assert (theComposite().getRaw());
66 theComposite()->parse();
67 }
68
69 void
70 DelayPool::dump (StoreEntry *entry, unsigned int i) const
71 {
72 if (!theComposite().getRaw())
73 return;
74
75 storeAppendPrintf(entry, "delay_class %d %s\n", i + 1, pool->theClassTypeLabel());
76
77 LOCAL_ARRAY(char, nom, 32);
78
79 snprintf(nom, 32, "delay_access %d", i + 1);
80
81 dump_acl_access(entry, nom, access);
82
83 storeAppendPrintf(entry, "delay_parameters %d", i + 1);
84
85 theComposite()->dump (entry);
86
87 storeAppendPrintf(entry, "\n");
88 }
89
90 void
91 DelayPool::createPool(u_char delay_class)
92 {
93 if (pool)
94 freeData();
95
96 pool = CommonPool::Factory(delay_class, theComposite_);
97 }
98
99 void
100 DelayPool::freeData()
101 {
102 delete pool;
103 pool = NULL;
104 }
105
106 /* XXX create DelayIdComposite.cc */
107 void
108 CompositePoolNode::delayRead(DeferredRead const &aRead)
109 {
110 deferredReads.delayRead(aRead);
111 }
112
113 #include "comm.h"
114
115 void
116 CompositePoolNode::kickReads()
117 {
118 /* we only start one, because delay pools may have **many** attached connections,
119 * and kicking them all off would be chaotic.
120 * This may need to be reviewed.
121 */
122 deferredReads.kickReads(1);
123 }
124
125 #endif