~yolanda.robla/+junk/squid3_fresh_branch

« back to all changes in this revision

Viewing changes to src/DelayPool.cc

  • Committer: yolanda.robla at canonical
  • Date: 2013-05-27 10:52:43 UTC
  • Revision ID: yolanda.robla@canonical.com-20130527105243-mcd0nscika17sl4w
first branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id$
 
3
 *
 
4
 * DEBUG: section 77    Delay Pools
 
5
 * AUTHOR: Robert Collins <robertc@squid-cache.org>
 
6
 * Based upon original delay pools code by
 
7
 *   David Luyer <david@luyer.net>
 
8
 *
 
9
 * SQUID Web Proxy Cache          http://www.squid-cache.org/
 
10
 * ----------------------------------------------------------
 
11
 *
 
12
 *  Squid is the result of efforts by numerous individuals from
 
13
 *  the Internet community; see the CONTRIBUTORS file for full
 
14
 *  details.   Many organizations have provided support for Squid's
 
15
 *  development; see the SPONSORS file for full details.  Squid is
 
16
 *  Copyrighted (C) 2001 by the Regents of the University of
 
17
 *  California; see the COPYRIGHT file for full details.  Squid
 
18
 *  incorporates software developed and/or copyrighted by other
 
19
 *  sources; see the CREDITS file for full details.
 
20
 *
 
21
 *  This program is free software; you can redistribute it and/or modify
 
22
 *  it under the terms of the GNU General Public License as published by
 
23
 *  the Free Software Foundation; either version 2 of the License, or
 
24
 *  (at your option) any later version.
 
25
 *
 
26
 *  This program is distributed in the hope that it will be useful,
 
27
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
28
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
29
 *  GNU General Public License for more details.
 
30
 *
 
31
 *  You should have received a copy of the GNU General Public License
 
32
 *  along with this program; if not, write to the Free Software
 
33
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
 
34
 *
 
35
 *
 
36
 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
 
37
 */
 
38
 
 
39
#include "config.h"
 
40
 
 
41
#if DELAY_POOLS
 
42
#include "DelayPool.h"
 
43
#include "CommonPool.h"
 
44
#include "acl/Acl.h"
 
45
#include "acl/Gadgets.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() != NULL);
 
66
    theComposite()->parse();
 
67
}
 
68
 
 
69
void
 
70
DelayPool::dump(StoreEntry *entry, unsigned int i) const
 
71
{
 
72
    if (theComposite() == NULL)
 
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
/** \todo 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
    deferredReads.kickReads(-1);
 
119
}
 
120
 
 
121
#endif