]> git.ipfire.org Git - thirdparty/squid.git/blame - src/DiskIO/DiskIOModule.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / DiskIO / DiskIOModule.cc
CommitLineData
b9ae18aa 1/*
b9ae18aa 2 *
3 * DEBUG: section 92 Storage File System
4 * AUTHOR: Robert Collins
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
26ac0430 22 *
b9ae18aa 23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
26ac0430 27 *
b9ae18aa 28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
33 */
34
f7f3304a 35#include "squid-old.h"
b9ae18aa 36#include "DiskIOModule.h"
37
38Vector<DiskIOModule*> *DiskIOModule::_Modules = NULL;
39
40//DiskIOModule() : initialised (false) {}
09c5ae5a 41
b9ae18aa 42DiskIOModule::DiskIOModule()
43{
09c5ae5a
AJ
44 /** We cannot call ModuleAdd(*this)
45 * here as the virtual methods are not yet available.
46 * We leave that to PokeAllModules() later.
b9ae18aa 47 */
48}
49
50void
51DiskIOModule::SetupAllModules()
52{
09c5ae5a
AJ
53 DiskIOModule::PokeAllModules();
54
b9ae18aa 55 for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
56 /* Call the FS to set up capabilities and initialize the FS driver */
57 (*i)->init();
58}
59
60void
61DiskIOModule::ModuleAdd(DiskIOModule &instance)
62{
63 iterator i = GetModules().begin();
64
65 while (i != GetModules().end()) {
66 assert(strcmp((*i)->type(), instance.type()) != 0);
67 ++i;
68 }
69
70 GetModules().push_back (&instance);
71}
72
73Vector<DiskIOModule *> const &
74DiskIOModule::Modules()
75{
76 return GetModules();
77}
78
79Vector<DiskIOModule*> &
80DiskIOModule::GetModules()
81{
82 if (!_Modules)
83 _Modules = new Vector<DiskIOModule *>;
84
85 return *_Modules;
86}
87
09c5ae5a
AJ
88/**
89 * Called when a graceful shutdown is to occur
b9ae18aa 90 * of each fs module.
91 */
92void
93DiskIOModule::FreeAllModules()
94{
95 while (GetModules().size()) {
96 DiskIOModule *fs = GetModules().back();
97 GetModules().pop_back();
98 fs->shutdown();
99 }
100}
101
102DiskIOModule *
103DiskIOModule::Find(char const *type)
104{
105 for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
106 if (strcasecmp(type, (*i)->type()) == 0)
107 return *i;
108
109 return NULL;
110}
62ee09ca 111
b7717b61 112DiskIOModule *
113DiskIOModule::FindDefault()
114{
09c5ae5a 115 /** Best IO options are in order: */
b7717b61 116 DiskIOModule * result;
117 result = Find("DiskThreads");
118 if (NULL == result)
119 result = Find("DiskDaemon");
120 if (NULL == result)
121 result = Find("AIO");
122 if (NULL == result)
123 result = Find("Blocking");
124 return result;
125}