=== modified file 'src/ClientDelayConfig.h' --- src/ClientDelayConfig.h 2013-05-13 23:32:23 +0000 +++ src/ClientDelayConfig.h 2014-02-10 17:21:16 +0000 @@ -1,50 +1,51 @@ #ifndef SQUID_CLIENTDELAYCONFIG_H #define SQUID_CLIENTDELAYCONFIG_H #include "acl/forward.h" -#include "base/Vector.h" + +#include class StoreEntry; class ConfigParser; /// \ingroup DelayPoolsAPI /* represents one client write limiting delay 'pool' */ class ClientDelayPool { public: ClientDelayPool() : access(NULL), rate(0), highwatermark(0) {} void dump (StoreEntry * entry, unsigned int poolNumberMinusOne) const; acl_access *access; int rate; int64_t highwatermark; }; -typedef Vector ClientDelayPools; +typedef std::vector ClientDelayPools; /* represents configuration of client write limiting delay pools */ class ClientDelayConfig { public: ClientDelayConfig() : initial(50) {} void freePoolCount(); void dumpPoolCount(StoreEntry * entry, const char *name) const; /* parsing of client_delay_pools - number of pools */ void parsePoolCount(); /* parsing of client_delay_parameters lines */ void parsePoolRates(); /* parsing client_delay_access lines */ void parsePoolAccess(ConfigParser &parser); void finalize(); ///< checks pools configuration /* initial bucket level, how fill bucket at startup */ unsigned short initial; ClientDelayPools pools; private: void clean(); }; #endif // SQUID_CLIENTDELAYCONFIG_H === modified file 'src/ConfigOption.cc' --- src/ConfigOption.cc 2014-02-04 16:54:49 +0000 +++ src/ConfigOption.cc 2014-02-10 15:54:49 +0000 @@ -17,49 +17,49 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #include "squid.h" #include "ConfigOption.h" ConfigOptionVector::~ConfigOptionVector() { while (!options.empty()) { delete options.back(); options.pop_back(); } } bool ConfigOptionVector::parse(char const *option, const char *value, int isaReconfig) { - Vector::iterator i = options.begin(); + std::vector::iterator i = options.begin(); while (i != options.end()) { if ((*i)->parse(option,value, isaReconfig)) return true; ++i; } return false; } void ConfigOptionVector::dump(StoreEntry * e) const { - for (Vector::const_iterator i = options.begin(); + for (std::vector::const_iterator i = options.begin(); i != options.end(); ++i) (*i)->dump(e); } === modified file 'src/ConfigOption.h' --- src/ConfigOption.h 2013-05-04 11:50:26 +0000 +++ src/ConfigOption.h 2014-02-10 15:54:34 +0000 @@ -3,82 +3,82 @@ * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_CONFIGOPTION_H #define SQUID_CONFIGOPTION_H -#include "base/Vector.h" +#include class StoreEntry; /* cache option parsers */ class ConfigOption { public: virtual ~ConfigOption() {} virtual bool parse(char const *option, const char *value, int reconfiguring) = 0; virtual void dump(StoreEntry * e) const = 0; }; class ConfigOptionVector : public ConfigOption { public: virtual ~ConfigOptionVector(); virtual bool parse(char const *option, const char *value, int reconfiguring); virtual void dump(StoreEntry * e) const; - Vectoroptions; + std::vectoroptions; }; template class ConfigOptionAdapter : public ConfigOption { public: ConfigOptionAdapter(C& theObject, bool (C::*parseFP)(char const *option, const char *value, int reconfiguring), void (C::*dumpFP)(StoreEntry * e) const) : object(theObject), parser(parseFP), dumper(dumpFP) {} bool parse(char const *option, const char *value, int isaReconf) { if (parser) return (object.*parser)(option, value, isaReconf); return false; } void dump(StoreEntry * e) const { if (dumper) (object.*dumper)(e); } private: C &object; bool (C::*parser)(char const *option, const char *value, int reconfiguring) ; void (C::*dumper)(StoreEntry * e) const; }; #endif /* SQUID_CONFIGOPTION_H */ === modified file 'src/CpuAffinityMap.cc' --- src/CpuAffinityMap.cc 2012-09-01 14:38:36 +0000 +++ src/CpuAffinityMap.cc 2014-02-10 15:40:39 +0000 @@ -1,43 +1,43 @@ /* * DEBUG: section 54 Interprocess Communication * */ #include "squid.h" #include "base/TextException.h" #include "CpuAffinityMap.h" #include "CpuAffinitySet.h" #include "Debug.h" bool -CpuAffinityMap::add(const Vector &aProcesses, const Vector &aCores) +CpuAffinityMap::add(const std::vector &aProcesses, const std::vector &aCores) { if (aProcesses.size() != aCores.size()) return false; for (size_t i = 0; i < aProcesses.size(); ++i) { const int process = aProcesses[i]; const int core = aCores[i]; if (process <= 0 || core <= 0) return false; theProcesses.push_back(process); theCores.push_back(core); } return true; } CpuAffinitySet * CpuAffinityMap::calculateSet(const int targetProcess) const { Must(theProcesses.size() == theCores.size()); int core = 0; for (size_t i = 0; i < theProcesses.size(); ++i) { const int process = theProcesses[i]; if (process == targetProcess) { if (core > 0) { debugs(54, DBG_CRITICAL, "WARNING: conflicting " "'cpu_affinity_map' for process number " << process << ", using the last core seen: " << theCores[i]); } core = theCores[i]; === modified file 'src/CpuAffinityMap.h' --- src/CpuAffinityMap.h 2013-05-04 11:50:26 +0000 +++ src/CpuAffinityMap.h 2014-02-10 15:40:39 +0000 @@ -1,32 +1,32 @@ /* */ #ifndef SQUID_CPU_AFFINITY_MAP_H #define SQUID_CPU_AFFINITY_MAP_H -#include "base/Vector.h" +#include class CpuAffinitySet; /// stores cpu_affinity_map configuration class CpuAffinityMap { public: /// append cpu_affinity_map option - bool add(const Vector &aProcesses, const Vector &aCores); + bool add(const std::vector &aProcesses, const std::vector &aCores); /// calculate CPU set for this process CpuAffinitySet *calculateSet(const int targetProcess) const; /// returns list of process numbers - const Vector &processes() const { return theProcesses; } + const std::vector &processes() const { return theProcesses; } /// returns list of cores - const Vector &cores() const { return theCores; } + const std::vector &cores() const { return theCores; } private: - Vector theProcesses; ///< list of process numbers - Vector theCores; ///< list of cores + std::vector theProcesses; ///< list of process numbers + std::vector theCores; ///< list of cores }; #endif // SQUID_CPU_AFFINITY_MAP_H === modified file 'src/DelayPools.h' --- src/DelayPools.h 2013-05-04 11:50:26 +0000 +++ src/DelayPools.h 2014-02-10 15:36:59 +0000 @@ -5,78 +5,78 @@ * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * * Copyright (c) 2003, Robert Collins */ #ifndef SQUID_DELAYPOOLS_H #define SQUID_DELAYPOOLS_H -#include "base/Vector.h" +#include class DelayPool; class Updateable; class StoreEntry; /** \defgroup DelayPoolsAPI Delay Pools API \ingroup Components */ /// \ingroup DelayPoolsAPI class Updateable { public: virtual ~Updateable() {} virtual void update(int) = 0; }; /// \ingroup DelayPoolsAPI class DelayPools { public: static void Init(); static void Update(void *); static unsigned short pools(); static void pools(unsigned short pools); static void FreePools(); static unsigned char *DelayClasses(); static void registerForUpdates(Updateable *); static void deregisterForUpdates (Updateable *); static long MemoryUsed; static DelayPool *delay_data; private: static void Stats(StoreEntry *); static void InitDelayData(); static time_t LastUpdate; static unsigned short pools_; static void FreeDelayData (); - static Vector toUpdate; + static std::vector toUpdate; static void RegisterWithCacheManager(void); }; #endif /* SQUID_DELAYPOOLS_H */ === modified file 'src/DelayTagged.h' --- src/DelayTagged.h 2013-10-25 00:13:46 +0000 +++ src/DelayTagged.h 2014-02-10 17:41:21 +0000 @@ -10,61 +10,60 @@ * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * * Copyright (c) 2003, Robert Collins */ #ifndef DELAYTAGGED_H #define DELAYTAGGED_H #if USE_DELAY_POOLS #include "auth/Gadgets.h" -#include "base/Vector.h" #include "CompositePoolNode.h" #include "DelayBucket.h" #include "DelayIdComposite.h" #include "DelaySpec.h" #include "splay.h" /// \ingroup DelayPoolsAPI class DelayTaggedBucket : public RefCountable { public: typedef RefCount Pointer; void *operator new(size_t); void operator delete (void *); void stats(StoreEntry *)const; DelayTaggedBucket(String &aTag); ~DelayTaggedBucket(); DelayBucket theBucket; String tag; }; /// \ingroup DelayPoolsAPI class DelayTagged : public CompositePoolNode { public: typedef RefCount Pointer; void *operator new(size_t); void operator delete (void *); === modified file 'src/DelayVector.h' --- src/DelayVector.h 2012-09-01 14:38:36 +0000 +++ src/DelayVector.h 2014-02-10 15:35:25 +0000 @@ -45,44 +45,44 @@ public: void *operator new(size_t); void operator delete (void *); DelayVector(); virtual ~DelayVector(); virtual void stats(StoreEntry * sentry); virtual void dump(StoreEntry *entry) const; virtual void update(int incr); virtual void parse(); virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &); void push_back (CompositePoolNode::Pointer); private: /// \ingroup DelayPoolsInternal class Id:public DelayIdComposite { public: void *operator new(size_t); void operator delete (void *); Id (RefCount,CompositeSelectionDetails &); ~Id(); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); virtual void delayRead(DeferredRead const &); private: RefCount theVector; - Vector ids; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + std::vector ids; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; }; friend class Id; - Vector pools; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + std::vector pools; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; }; #endif /* USE_DELAY_POOLS */ #endif /* SQUID_DELAYVECTOR_H */ === modified file 'src/DiskIO/DiskIOModule.cc' --- src/DiskIO/DiskIOModule.cc 2014-02-04 19:47:14 +0000 +++ src/DiskIO/DiskIOModule.cc 2014-02-10 16:29:19 +0000 @@ -8,106 +8,106 @@ * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * Copyright (c) 2003, Robert Collins */ #include "squid.h" #include "DiskIOModule.h" -Vector *DiskIOModule::_Modules = NULL; +std::vector *DiskIOModule::_Modules = NULL; //DiskIOModule() : initialised (false) {} DiskIOModule::DiskIOModule() { /** We cannot call ModuleAdd(*this) * here as the virtual methods are not yet available. * We leave that to PokeAllModules() later. */ } void DiskIOModule::SetupAllModules() { DiskIOModule::PokeAllModules(); for (iterator i = GetModules().begin(); i != GetModules().end(); ++i) /* Call the FS to set up capabilities and initialize the FS driver */ (*i)->init(); } void DiskIOModule::ModuleAdd(DiskIOModule &instance) { iterator i = GetModules().begin(); while (i != GetModules().end()) { assert(strcmp((*i)->type(), instance.type()) != 0); ++i; } GetModules().push_back (&instance); } -Vector const & +std::vector const & DiskIOModule::Modules() { return GetModules(); } -Vector & +std::vector & DiskIOModule::GetModules() { if (!_Modules) - _Modules = new Vector; + _Modules = new std::vector; return *_Modules; } /** * Called when a graceful shutdown is to occur * of each fs module. */ void DiskIOModule::FreeAllModules() { while (!GetModules().empty()) { DiskIOModule *fs = GetModules().back(); GetModules().pop_back(); fs->gracefulShutdown(); } } DiskIOModule * DiskIOModule::Find(char const *type) { for (iterator i = GetModules().begin(); i != GetModules().end(); ++i) if (strcasecmp(type, (*i)->type()) == 0) return *i; return NULL; } DiskIOModule * DiskIOModule::FindDefault() === modified file 'src/DiskIO/DiskIOModule.h' --- src/DiskIO/DiskIOModule.h 2013-09-03 09:05:02 +0000 +++ src/DiskIO/DiskIOModule.h 2014-02-10 16:29:19 +0000 @@ -5,81 +5,81 @@ * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * Copyright (c) 2003, Robert Collins */ #ifndef SQUID_DISKIOMODULE_H #define SQUID_DISKIOMODULE_H -#include "base/Vector.h" +#include /* forward decls */ class CacheManager; class DiskIOStrategy; class DiskIOModule { public: static void SetupAllModules(); static void ModuleAdd(DiskIOModule &); static void FreeAllModules(); /** Poke all compiled modules for self-setup */ static void PokeAllModules(); static DiskIOModule *Find(char const *type); /** Find *any* usable disk module. This will look for the 'best' * available module for this system. */ static DiskIOModule *FindDefault(); - static Vector const &Modules(); - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + static std::vector const &Modules(); + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; DiskIOModule(); virtual ~DiskIOModule() {} virtual void init() = 0; //virtual void registerWithCacheManager(void); virtual void gracefulShutdown() = 0; virtual DiskIOStrategy *createStrategy() = 0; virtual char const *type () const = 0; // Not implemented DiskIOModule(DiskIOModule const &); DiskIOModule &operator=(DiskIOModule const&); protected: //bool initialised; static void RegisterAllModulesWithCacheManager(void); private: - static Vector &GetModules(); - static Vector *_Modules; + static std::vector &GetModules(); + static std::vector *_Modules; }; #endif /* SQUID_DISKIOMODULE_H */ === modified file 'src/EventLoop.h' --- src/EventLoop.h 2013-11-29 19:47:54 +0000 +++ src/EventLoop.h 2014-02-10 15:31:55 +0000 @@ -4,61 +4,61 @@ * ---------------------------------------------------------- * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_EVENTLOOP_H #define SQUID_EVENTLOOP_H -#include "base/Vector.h" +#include #define EVENT_LOOP_TIMEOUT 1000 /* 1s timeout */ class AsyncEngine; class TimeEngine; /** An event loop. An event loop is the core inner loop of squid. * The event loop can be run until exit, or once. After it finishes control * returns to the caller. If desired it can be run again. \par * The event loop cannot be run once it is running until it has finished. */ class EventLoop { public: EventLoop(); /** register an async engine which will be given the opportunity to perform * in-main-thread tasks each event loop. */ void registerEngine(AsyncEngine *engine); /** start the event loop running. The loop will run until it is stopped by * calling stop(), or when the loop is completely idle - nothing * dispatched in a loop, and all engines idle. */ void run(); /** run the loop once. This may not complete all events! It should therefor @@ -77,40 +77,40 @@ public: */ void setPrimaryEngine(AsyncEngine * engine); /** set the time service. There can be only one time service set at any * time. The time service is invoked on each loop */ void setTimeService(TimeEngine *engine); /** stop the event loop - it will finish the current loop and then return to the * caller of run(). */ void stop(); int errcount; /// the [main program] loop running now; may be nil /// for simplicity, we assume there are no concurrent loops static EventLoop *Running; private: /** setup state variables prior to running */ void prepareToRun(); /** check an individual engine */ void checkEngine(AsyncEngine * engine, bool const primary); /** dispatch calls and events scheduled during checkEngine() */ bool dispatchCalls(); bool last_loop; - typedef Vector engine_vector; + typedef std::vector engine_vector; engine_vector engines; TimeEngine * timeService; AsyncEngine * primaryEngine; int loop_delay; /**< the delay to be given to the primary engine */ bool error; /**< has an error occured in this loop */ bool runOnceResult; /**< the result from runOnce */ }; #endif /* SQUID_EVENTLOOP_H */ === modified file 'src/FadingCounter.h' --- src/FadingCounter.h 2013-05-04 11:50:26 +0000 +++ src/FadingCounter.h 2014-02-10 15:11:53 +0000 @@ -1,32 +1,32 @@ #ifndef SQUID_FADING_COUNTER_H #define SQUID_FADING_COUNTER_H -#include "base/Vector.h" +#include /// Counts events, forgetting old ones. Usefull for "3 errors/minute" limits. class FadingCounter { public: FadingCounter(); /// 0=remember nothing; -1=forget nothing; new value triggers clear() void configure(double horizonSeconds); void clear(); ///< forgets all events int count(int howMany); ///< count fresh, return #events remembered int remembered() const { return total; } ///< possibly stale #events /// read-only memory horizon in seconds; older events are forgotten double horizon; private: const int precision; ///< #counting slots, controls measur. occuracy double delta; ///< sub-interval duration = horizon/precision double lastTime; ///< time of the last update - Vector counters; ///< events per delta (possibly stale) + std::vector counters; ///< events per delta (possibly stale) int total; ///< number of remembered events (possibly stale) }; #endif /* SQUID_FADING_COUNTER_H */ === modified file 'src/FwdState.cc' --- src/FwdState.cc 2014-02-02 09:42:23 +0000 +++ src/FwdState.cc 2014-02-10 17:46:42 +0000 @@ -445,61 +445,61 @@ FwdState::unregister(int fd) assert(fd == serverConnection()->fd); unregister(serverConn); } /** * server-side modules call fwdComplete() when they are done * downloading an object. Then, we either 1) re-forward the * request somewhere else if needed, or 2) call storeComplete() * to finish it off */ void FwdState::complete() { debugs(17, 3, HERE << entry->url() << "\n\tstatus " << entry->getReply()->sline.status()); #if URL_CHECKSUM_DEBUG entry->mem_obj->checkUrlChecksum(); #endif logReplyStatus(n_tries, entry->getReply()->sline.status()); if (reforward()) { debugs(17, 3, HERE << "re-forwarding " << entry->getReply()->sline.status() << " " << entry->url()); if (Comm::IsConnOpen(serverConn)) unregister(serverConn); entry->reset(); // drop the last path off the selection list. try the next one. - serverDestinations.shift(); + serverDestinations.erase(serverDestinations.begin()); startConnectionOrFail(); } else { if (Comm::IsConnOpen(serverConn)) debugs(17, 3, HERE << "server FD " << serverConnection()->fd << " not re-forwarding status " << entry->getReply()->sline.status()); else debugs(17, 3, HERE << "server (FD closed) not re-forwarding status " << entry->getReply()->sline.status()); EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); entry->complete(); if (!Comm::IsConnOpen(serverConn)) completed(); self = NULL; // refcounted } } /**** CALLBACK WRAPPERS ************************************************************/ static void fwdPeerSelectionCompleteWrapper(Comm::ConnectionList * unused, ErrorState *err, void *data) { FwdState *fwd = (FwdState *) data; if (err) fwd->fail(err); fwd->startConnectionOrFail(); } static void fwdServerClosedWrapper(const CommCloseCbParams ¶ms) @@ -584,61 +584,61 @@ FwdState::checkRetry() */ bool FwdState::checkRetriable() { // Optimize: A compliant proxy may retry PUTs, but Squid lacks the [rather // complicated] code required to protect the PUT request body from being // nibbled during the first try. Thus, Squid cannot retry some PUTs today. if (request->body_pipe != NULL) return false; // RFC2616 9.1 Safe and Idempotent Methods return (request->method.isHttpSafe() || request->method.isIdempotent()); } void FwdState::serverClosed(int fd) { debugs(17, 2, HERE << "FD " << fd << " " << entry->url()); retryOrBail(); } void FwdState::retryOrBail() { if (checkRetry()) { debugs(17, 3, HERE << "re-forwarding (" << n_tries << " tries, " << (squid_curtime - start_t) << " secs)"); // we should retry the same destination if it failed due to pconn race if (pconnRace == raceHappened) debugs(17, 4, HERE << "retrying the same destination"); else - serverDestinations.shift(); // last one failed. try another. + serverDestinations.erase(serverDestinations.begin()); // last one failed. try another. startConnectionOrFail(); return; } // TODO: should we call completed() here and move doneWithRetries there? doneWithRetries(); if (self != NULL && !err && shutting_down) { ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, Http::scServiceUnavailable, request); errorAppendEntry(entry, anErr); } self = NULL; // refcounted } // If the Server quits before nibbling at the request body, the body sender // will not know (so that we can retry). Call this if we will not retry. We // will notify the sender so that it does not get stuck waiting for space. void FwdState::doneWithRetries() { if (request && request->body_pipe != NULL) request->body_pipe->expectNoConsumption(); } // called by the server that failed after calling unregister() void FwdState::handleUnregisteredServerEnd() { debugs(17, 2, HERE << "self=" << self << " err=" << err << ' ' << entry->url()); === modified file 'src/FwdState.h' --- src/FwdState.h 2013-10-25 00:13:46 +0000 +++ src/FwdState.h 2014-02-10 17:41:35 +0000 @@ -1,35 +1,34 @@ #ifndef SQUID_FORWARD_H #define SQUID_FORWARD_H #include "base/RefCount.h" -#include "base/Vector.h" #include "comm.h" #include "comm/Connection.h" #include "err_type.h" #include "fde.h" #include "http/StatusCode.h" #include "ip/Address.h" #if USE_SSL #include "ssl/support.h" #endif /* forward decls */ class AccessLogEntry; typedef RefCount AccessLogEntryPointer; class ErrorState; class HttpRequest; #if USE_SSL namespace Ssl { class ErrorDetail; class CertValidationResponse; }; #endif /** * Returns the TOS value that we should be setting on the connection * to the server, based on the ACL. */ tos_t GetTosToServer(HttpRequest * request); === modified file 'src/HttpHdrRange.cc' --- src/HttpHdrRange.cc 2014-02-04 16:54:49 +0000 +++ src/HttpHdrRange.cc 2014-02-10 13:16:04 +0000 @@ -315,130 +315,130 @@ HttpHdrRange::end() HttpHdrRange::const_iterator HttpHdrRange::begin() const { return specs.begin(); } HttpHdrRange::const_iterator HttpHdrRange::end() const { return specs.end(); } void HttpHdrRange::packInto(Packer * packer) const { const_iterator pos = begin(); assert(this); while (pos != end()) { if (pos != begin()) packerAppend(packer, ",", 1); (*pos)->packInto(packer); ++pos; } } void -HttpHdrRange::merge (Vector &basis) +HttpHdrRange::merge (std::vector &basis) { /* reset old array */ specs.clear(); /* merge specs: * take one spec from "goods" and merge it with specs from * "specs" (if any) until there is no overlap */ iterator i = basis.begin(); while (i != basis.end()) { if (specs.size() && (*i)->mergeWith(specs.back())) { /* merged with current so get rid of the prev one */ delete specs.back(); specs.pop_back(); continue; /* re-iterate */ } specs.push_back (*i); ++i; /* progress */ } debugs(64, 3, "HttpHdrRange::merge: had " << basis.size() << " specs, merged " << basis.size() - specs.size() << " specs"); } void -HttpHdrRange::getCanonizedSpecs (Vector ©) +HttpHdrRange::getCanonizedSpecs (std::vector ©) { /* canonize each entry and destroy bad ones if any */ for (iterator pos (begin()); pos != end(); ++pos) { if ((*pos)->canonize(clen)) copy.push_back (*pos); else delete (*pos); } debugs(64, 3, "HttpHdrRange::getCanonizedSpecs: found " << specs.size() - copy.size() << " bad specs"); } #include "HttpHdrContRange.h" /* * canonizes all range specs within a set preserving the order * returns true if the set is valid after canonization; * the set is valid if * - all range specs are valid and * - there is at least one range spec */ int HttpHdrRange::canonize(HttpReply *rep) { assert(this && rep); if (rep->content_range) clen = rep->content_range->elength; else clen = rep->content_length; return canonize (clen); } int HttpHdrRange::canonize (int64_t newClen) { clen = newClen; debugs(64, 3, "HttpHdrRange::canonize: started with " << specs.size() << " specs, clen: " << clen); - Vector goods; + std::vector goods; getCanonizedSpecs(goods); merge (goods); debugs(64, 3, "HttpHdrRange::canonize: finished with " << specs.size() << " specs"); return specs.size() > 0; // fixme, should return bool } /* hack: returns true if range specs are too "complex" for Squid to handle */ /* requires that specs are "canonized" first! */ bool HttpHdrRange::isComplex() const { int64_t offset = 0; assert(this); /* check that all rangers are in "strong" order */ const_iterator pos (begin()); while (pos != end()) { /* Ensure typecasts is safe */ assert ((*pos)->offset >= 0); if ((*pos)->offset < offset) return 1; offset = (*pos)->offset + (*pos)->length; ++pos; } return 0; @@ -552,59 +552,59 @@ HttpHdrRange::offsetLimitExceeded(const /* tail request */ return true; if (limit >= firstOffset()) /* below the limit */ return false; return true; } bool HttpHdrRange::contains(HttpHdrRangeSpec& r) const { assert(r.length >= 0); HttpHdrRangeSpec::HttpRange rrange(r.offset, r.offset + r.length); for (const_iterator i = begin(); i != end(); ++i) { HttpHdrRangeSpec::HttpRange irange((*i)->offset, (*i)->offset + (*i)->length); HttpHdrRangeSpec::HttpRange intersection = rrange.intersection(irange); if (intersection.start == irange.start && intersection.size() == irange.size()) return true; } return false; } const HttpHdrRangeSpec * HttpHdrRangeIter::currentSpec() const { - if (pos.incrementable()) + if (pos != end) return *pos; return NULL; } void HttpHdrRangeIter::updateSpec() { assert (debt_size == 0); assert (valid); - if (pos.incrementable()) { + if (pos != end) { debt(currentSpec()->length); } } int64_t HttpHdrRangeIter::debt() const { debugs(64, 3, "HttpHdrRangeIter::debt: debt is " << debt_size); return debt_size; } void HttpHdrRangeIter::debt(int64_t newDebt) { debugs(64, 3, "HttpHdrRangeIter::debt: was " << debt_size << " now " << newDebt); debt_size = newDebt; } === modified file 'src/HttpHeader.cc' --- src/HttpHeader.cc 2014-02-04 19:47:14 +0000 +++ src/HttpHeader.cc 2014-02-10 14:46:19 +0000 @@ -23,60 +23,62 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */ #include "squid.h" #include "base64.h" #include "globals.h" #include "HttpHdrCc.h" #include "HttpHdrContRange.h" #include "HttpHdrSc.h" #include "HttpHeader.h" #include "HttpHeaderFieldInfo.h" #include "HttpHeaderStat.h" #include "HttpHeaderTools.h" #include "MemBuf.h" #include "mgr/Registration.h" #include "profiler/Profiler.h" #include "rfc1123.h" #include "SquidConfig.h" #include "SquidString.h" #include "StatHist.h" #include "Store.h" #include "StrList.h" #include "TimeOrTag.h" +#include + /* * On naming conventions: * * HTTP/1.1 defines message-header as * * message-header = field-name ":" [ field-value ] CRLF * field-name = token * field-value = *( field-content | LWS ) * * HTTP/1.1 does not give a name name a group of all message-headers in a message. * Squid 1.1 seems to refer to that group _plus_ start-line as "headers". * * HttpHeader is an object that represents all message-headers in a message. * HttpHeader does not manage start-line. * * HttpHeader is implemented as a collection of header "entries". * An entry is a (field_id, field_name, field_value) triplet. */ /* * local constants and vars */ /* * A table with major attributes for every known field. * We calculate name lengths and reorganize this array on start up. * After reorganization, field id can be used as an index to the table. */ static const HttpHeaderFieldAttrs HeadersAttrs[] = { {"Accept", HDR_ACCEPT, ftStr}, @@ -860,117 +862,117 @@ HttpHeader::delById(http_hdr_type id) assert(count); return count; } /* * deletes an entry at pos and leaves a gap; leaving a gap makes it * possible to iterate(search) and delete fields at the same time * NOTE: Does not update the header mask. Caller must follow up with * a call to refreshMask() if headers_deleted was incremented. */ void HttpHeader::delAt(HttpHeaderPos pos, int &headers_deleted) { HttpHeaderEntry *e; assert(pos >= HttpHeaderInitPos && pos < static_cast(entries.size())); e = static_cast(entries[pos]); entries[pos] = NULL; /* decrement header length, allow for ": " and crlf */ len -= e->name.size() + 2 + e->value.size() + 2; assert(len >= 0); delete e; ++headers_deleted; } /* * Compacts the header storage */ void HttpHeader::compact() { - entries.prune(NULL); + std::remove(entries.begin(), entries.end(), static_cast(NULL)); } /* * Refreshes the header mask. Required after delAt() calls. */ void HttpHeader::refreshMask() { httpHeaderMaskInit(&mask, 0); debugs(55, 7, "refreshing the mask in hdr " << this); HttpHeaderPos pos = HttpHeaderInitPos; while (HttpHeaderEntry *e = getEntry(&pos)) { CBIT_SET(mask, e->id); } } /* appends an entry; * does not call e->clone() so one should not reuse "*e" */ void HttpHeader::addEntry(HttpHeaderEntry * e) { assert(e); assert_eid(e->id); assert(e->name.size()); debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size()); if (CBIT_TEST(mask, e->id)) ++ Headers[e->id].stat.repCount; else CBIT_SET(mask, e->id); entries.push_back(e); /* increment header length, allow for ": " and crlf */ len += e->name.size() + 2 + e->value.size() + 2; } /* inserts an entry; * does not call e->clone() so one should not reuse "*e" */ void HttpHeader::insertEntry(HttpHeaderEntry * e) { assert(e); assert_eid(e->id); debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size()); if (CBIT_TEST(mask, e->id)) ++ Headers[e->id].stat.repCount; else CBIT_SET(mask, e->id); - entries.insert(e); + entries.insert(entries.begin(),e); /* increment header length, allow for ": " and crlf */ len += e->name.size() + 2 + e->value.size() + 2; } bool HttpHeader::getList(http_hdr_type id, String *s) const { HttpHeaderEntry *e; HttpHeaderPos pos = HttpHeaderInitPos; debugs(55, 9, this << " joining for id " << id); /* only fields from ListHeaders array can be "listed" */ assert(CBIT_TEST(ListHeadersMask, id)); if (!CBIT_TEST(mask, id)) return false; while ((e = getEntry(&pos))) { if (e->id == id) strListAdd(s, e->value.termedBuf(), ','); } /* * note: we might get an empty (size==0) string if there was an "empty" * header. This results in an empty length String, which may have a NULL * buffer. */ /* temporary warning: remove it? (Is it useful for diagnostics ?) */ if (!s->size()) debugs(55, 3, "empty list header: " << Headers[id].name << "(" << id << ")"); === modified file 'src/HttpHeader.h' --- src/HttpHeader.h 2013-08-07 03:18:08 +0000 +++ src/HttpHeader.h 2014-02-11 07:52:17 +0000 @@ -9,60 +9,62 @@ * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_HTTPHEADER_H #define SQUID_HTTPHEADER_H /* because we pass a spec by value */ #include "HttpHeaderMask.h" #include "MemPool.h" #include "SquidString.h" +#include + /* class forward declarations */ class HttpHdrCc; class HttpHdrContRange; class HttpHdrRange; class HttpHdrSc; class Packer; class StoreEntry; /* constant attributes of http header fields */ /// recognized or "known" header fields; and the RFC which defines them (or not) typedef enum { HDR_BAD_HDR = -1, HDR_ACCEPT = 0, /**< RFC 2608, 2616 */ HDR_ACCEPT_CHARSET, /**< RFC 2608, 2616 */ HDR_ACCEPT_ENCODING, /**< RFC 2608, 2616 */ /*HDR_ACCEPT_FEATURES,*/ /* experimental RFC 2295 */ HDR_ACCEPT_LANGUAGE, /**< RFC 2608, 2616 */ HDR_ACCEPT_RANGES, /**< RFC 2608, 2616 */ HDR_AGE, /**< RFC 2608, 2616 */ HDR_ALLOW, /**< RFC 2608, 2616 */ /*HDR_ALTERNATES,*/ /* deprecated RFC 2068, 2295 */ HDR_AUTHORIZATION, /**< RFC 2608, 2616, 4559 */ HDR_CACHE_CONTROL, /**< RFC 2608, 2616 */ HDR_CONNECTION, /**< RFC 2608, 2616 */ HDR_CONTENT_BASE, /**< RFC 2608 */ HDR_CONTENT_DISPOSITION, /**< RFC 2183, 2616 */ HDR_CONTENT_ENCODING, /**< RFC 2608, 2616 */ HDR_CONTENT_LANGUAGE, /**< RFC 2608, 2616 */ HDR_CONTENT_LENGTH, /**< RFC 2608, 2616 */ @@ -256,59 +258,59 @@ public: void putInt(http_hdr_type id, int number); void putInt64(http_hdr_type id, int64_t number); void putTime(http_hdr_type id, time_t htime); void insertTime(http_hdr_type id, time_t htime); void putStr(http_hdr_type id, const char *str); void putAuth(const char *auth_scheme, const char *realm); void putCc(const HttpHdrCc * cc); void putContRange(const HttpHdrContRange * cr); void putRange(const HttpHdrRange * range); void putSc(HttpHdrSc *sc); void putWarning(const int code, const char *const text); ///< add a Warning header void putExt(const char *name, const char *value); int getInt(http_hdr_type id) const; int64_t getInt64(http_hdr_type id) const; time_t getTime(http_hdr_type id) const; const char *getStr(http_hdr_type id) const; const char *getLastStr(http_hdr_type id) const; HttpHdrCc *getCc() const; HttpHdrRange *getRange() const; HttpHdrSc *getSc() const; HttpHdrContRange *getContRange() const; const char *getAuth(http_hdr_type id, const char *auth_scheme) const; ETag getETag(http_hdr_type id) const; TimeOrTag getTimeOrTag(http_hdr_type id) const; int hasListMember(http_hdr_type id, const char *member, const char separator) const; int hasByNameListMember(const char *name, const char *member, const char separator) const; void removeHopByHopEntries(); inline bool chunked() const; ///< whether message uses chunked Transfer-Encoding /* protected, do not use these, use interface functions instead */ - Vector entries; /**< parsed fields in raw format */ + std::vector entries; /**< parsed fields in raw format */ HttpHeaderMask mask; /**< bit set <=> entry present */ http_hdr_owner_type owner; /**< request or reply */ int len; /**< length when packed, not counting terminating null-byte */ protected: /** \deprecated Public access replaced by removeHopByHopEntries() */ void removeConnectionHeaderEntries(); private: HttpHeaderEntry *findLastEntry(http_hdr_type id) const; }; int httpHeaderParseQuotedString(const char *start, const int len, String *val); int httpHeaderHasByNameListMember(const HttpHeader * hdr, const char *name, const char *member, const char separator); void httpHeaderUpdate(HttpHeader * old, const HttpHeader * fresh, const HttpHeaderMask * denied_mask); void httpHeaderCalcMask(HttpHeaderMask * mask, http_hdr_type http_hdr_type_enums[], size_t count); inline bool HttpHeader::chunked() const { return has(HDR_TRANSFER_ENCODING) && hasListMember(HDR_TRANSFER_ENCODING, "chunked", ','); } void httpHeaderInitModule(void); void httpHeaderCleanModule(void); #endif /* SQUID_HTTPHEADER_H */ === modified file 'src/HttpHeaderRange.h' --- src/HttpHeaderRange.h 2013-05-04 11:50:26 +0000 +++ src/HttpHeaderRange.h 2014-02-11 07:52:17 +0000 @@ -1,133 +1,134 @@ - /* * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_HTTPHEADERRANGE_H #define SQUID_HTTPHEADERRANGE_H -#include "base/Vector.h" #include "MemPool.h" #include "Packer.h" #include "Range.h" #include "SquidString.h" +#include + class HttpReply; /* http byte-range-spec */ class HttpHdrRangeSpec { public: MEMPROXY_CLASS(HttpHdrRangeSpec); typedef Range HttpRange; static int64_t const UnknownPosition; HttpHdrRangeSpec(); static HttpHdrRangeSpec *Create(const char *field, int fieldLen); bool parseInit(const char *field, int flen); int canonize(int64_t clen); void outputInfo( char const *note) const; void packInto(Packer * p) const; bool mergeWith(const HttpHdrRangeSpec * donor); int64_t offset; int64_t length; }; MEMPROXY_CLASS_INLINE(HttpHdrRangeSpec); /** * There may be more than one byte range specified in the request. * This object holds all range specs in order of their appearence * in the request because we SHOULD preserve that order. */ class HttpHdrRange { public: MEMPROXY_CLASS(HttpHdrRange); static size_t ParsedCount; /* Http Range Header Field */ static HttpHdrRange *ParseCreate(const String * range_spec); HttpHdrRange(); HttpHdrRange(HttpHdrRange const &); ~HttpHdrRange(); HttpHdrRange &operator= (HttpHdrRange const &); - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; iterator begin(); const_iterator begin () const; iterator end(); const_iterator end() const; /* adjust specs after the length is known */ int canonize(int64_t); int canonize(HttpReply *rep); /* returns true if ranges are valid; inits HttpHdrRange */ bool parseInit(const String * range_spec); void packInto(Packer * p) const; /* other */ bool isComplex() const; bool willBeComplex() const; int64_t firstOffset() const; int64_t lowestOffset(int64_t) const; bool offsetLimitExceeded(const int64_t limit) const; bool contains(HttpHdrRangeSpec& r) const; - Vector specs; + std::vector specs; private: - void getCanonizedSpecs (Vector ©); - void merge (Vector &basis); + void getCanonizedSpecs (std::vector ©); + void merge (std::vector &basis); int64_t clen; }; MEMPROXY_CLASS_INLINE(HttpHdrRange); /** * Data for iterating thru range specs */ class HttpHdrRangeIter { public: HttpHdrRange::iterator pos; + HttpHdrRange::iterator end; const HttpHdrRangeSpec *currentSpec() const; void updateSpec(); int64_t debt() const; void debt(int64_t); int64_t debt_size; /* bytes left to send from the current spec */ String boundary; /* boundary for multipart responses */ bool valid; }; #endif /* SQUID_HTTPHEADERRANGE_H */ === modified file 'src/Notes.cc' --- src/Notes.cc 2014-02-02 18:19:59 +0000 +++ src/Notes.cc 2014-02-10 12:43:49 +0000 @@ -135,126 +135,126 @@ Notes::dump(StoreEntry *entry, const cha for (AMLI m = notes.begin(); m != notes.end(); ++m) { typedef Note::Values::iterator VLI; for (VLI v =(*m)->values.begin(); v != (*m)->values.end(); ++v ) { storeAppendPrintf(entry, "%s " SQUIDSTRINGPH " %s", key, SQUIDSTRINGPRINT((*m)->key), ConfigParser::QuoteString((*v)->value)); dump_acl_list(entry, (*v)->aclList); storeAppendPrintf(entry, "\n"); } } } void Notes::clean() { notes.clear(); } NotePairs::~NotePairs() { while (!entries.empty()) { delete entries.back(); entries.pop_back(); } } const char * NotePairs::find(const char *noteKey) const { static String value; value.clean(); - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(noteKey) == 0) { if (value.size()) value.append(", "); value.append(ConfigParser::QuoteString((*i)->value)); } } return value.size() ? value.termedBuf() : NULL; } const char * NotePairs::toString(const char *sep) const { static String value; value.clean(); - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { value.append((*i)->name); value.append(": "); value.append(ConfigParser::QuoteString((*i)->value)); value.append(sep); } return value.size() ? value.termedBuf() : NULL; } const char * NotePairs::findFirst(const char *noteKey) const { - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(noteKey) == 0) return (*i)->value.termedBuf(); } return NULL; } void NotePairs::add(const char *key, const char *note) { entries.push_back(new NotePairs::Entry(key, note)); } void NotePairs::addStrList(const char *key, const char *values) { String strValues(values); const char *item; const char *pos = NULL; int ilen = 0; while (strListGetItem(&strValues, ',', &item, &ilen, &pos)) { String v; v.append(item, ilen); entries.push_back(new NotePairs::Entry(key, v.termedBuf())); } } bool NotePairs::hasPair(const char *key, const char *value) const { - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(key) == 0 && (*i)->value.cmp(value) == 0) return true; } return false; } void NotePairs::append(const NotePairs *src) { - for (Vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { + for (std::vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { entries.push_back(new NotePairs::Entry((*i)->name.termedBuf(), (*i)->value.termedBuf())); } } void NotePairs::appendNewOnly(const NotePairs *src) { - for (Vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { + for (std::vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { if (!hasPair((*i)->name.termedBuf(), (*i)->value.termedBuf())) entries.push_back(new NotePairs::Entry((*i)->name.termedBuf(), (*i)->value.termedBuf())); } } NotePairs & SyncNotes(AccessLogEntry &ale, HttpRequest &request) { // XXX: auth code only has access to HttpRequest being authenticated // so we must handle the case where HttpRequest is set without ALE being set. if (!ale.notes) { if (!request.notes) request.notes = new NotePairs; ale.notes = request.notes; } else { assert(ale.notes == request.notes); } return *ale.notes; } === modified file 'src/Notes.h' --- src/Notes.h 2014-02-02 09:42:23 +0000 +++ src/Notes.h 2014-02-10 12:42:52 +0000 @@ -1,103 +1,103 @@ #ifndef SQUID_NOTES_H #define SQUID_NOTES_H #include "acl/forward.h" #include "base/RefCount.h" -#include "base/Vector.h" #include "CbDataList.h" #include "format/Format.h" #include "MemPool.h" #include "SquidString.h" #include "typedefs.h" #if HAVE_STRING #include #endif +#include class HttpRequest; class HttpReply; typedef RefCount AccessLogEntryPointer; /** * Used to store a note configuration. The notes are custom key:value * pairs ICAP request headers or ECAP options used to pass * custom transaction-state related meta information to squid * internal subsystems or to adaptation services. */ class Note: public RefCountable { public: typedef RefCount Pointer; /// Stores a value for the note. class Value: public RefCountable { public: typedef RefCount Pointer; String value; ///< Configured annotation value, possibly with %macros ACLList *aclList; ///< The access list used to determine if this value is valid for a request /// Compiled annotation value format Format::Format *valueFormat; explicit Value(const String &aVal) : value(aVal), aclList(NULL), valueFormat(NULL) {} ~Value(); }; - typedef Vector Values; + typedef std::vector Values; explicit Note(const String &aKey): key(aKey) {} /** * Adds a value to the note and returns a pointer to the * related Value object. */ Value::Pointer addValue(const String &value); /** * Walks through the possible values list of the note and selects * the first value which matches the given HttpRequest and HttpReply * or NULL if none matches. * If an AccessLogEntry given and Value::valueFormat is not null, the * formatted value returned. */ const char *match(HttpRequest *request, HttpReply *reply, const AccessLogEntryPointer &al); String key; ///< The note key Values values; ///< The possible values list for the note }; class ConfigParser; /** * Used to store a notes configuration list. */ class Notes { public: - typedef Vector NotesList; + typedef std::vector NotesList; typedef NotesList::iterator iterator; ///< iterates over the notes list typedef NotesList::const_iterator const_iterator; ///< iterates over the notes list Notes(const char *aDescr, const char **metasBlacklist, bool allowFormatted = false): descr(aDescr), blacklisted(metasBlacklist), formattedValues(allowFormatted) {} Notes(): descr(NULL), blacklisted(NULL) {} ~Notes() { notes.clear(); } /** * Parse a notes line and returns a pointer to the * parsed Note object. */ Note::Pointer parse(ConfigParser &parser); /** * Dump the notes list to the given StoreEntry object. */ void dump(StoreEntry *entry, const char *name); void clean(); /// clean the notes list /// points to the first argument iterator begin() { return notes.begin(); } /// points to the end of list iterator end() { return notes.end(); } /// return true if the notes list is empty bool empty() { return notes.empty(); } NotesList notes; ///< The Note::Pointer objects array list const char *descr; ///< A short description for notes list const char **blacklisted; ///< Null terminated list of blacklisted note keys bool formattedValues; ///< Whether the formatted values are supported private: @@ -157,46 +157,46 @@ public: /** * Adds a note key and value to the notes list. * If the key name already exists in list, add the given value to its set * of values. */ void add(const char *key, const char *value); /** * Adds a note key and values strList to the notes list. * If the key name already exists in list, add the new values to its set * of values. */ void addStrList(const char *key, const char *values); /** * Return true if the key/value pair is already stored */ bool hasPair(const char *key, const char *value) const; /** * Convert NotePairs list to a string consist of "Key: Value" * entries separated by sep string. */ const char *toString(const char *sep = "\r\n") const; /** * True if there are not entries in the list */ bool empty() const {return entries.empty();} - Vector entries; ///< The key/value pair entries + std::vector entries; ///< The key/value pair entries private: NotePairs &operator = (NotePairs const &); // Not implemented NotePairs(NotePairs const &); // Not implemented }; MEMPROXY_CLASS_INLINE(NotePairs::Entry); class AccessLogEntry; /** * Keep in sync HttpRequest and the corresponding AccessLogEntry objects */ NotePairs &SyncNotes(AccessLogEntry &ale, HttpRequest &request); #endif === modified file 'src/PeerSelectState.h' --- src/PeerSelectState.h 2013-12-06 14:59:47 +0000 +++ src/PeerSelectState.h 2014-02-10 17:41:52 +0000 @@ -8,61 +8,60 @@ * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * Copyright (c) 2003, Robert Collins */ #ifndef SQUID_PEERSELECTSTATE_H #define SQUID_PEERSELECTSTATE_H #include "AccessLogEntry.h" #include "acl/Checklist.h" -#include "base/Vector.h" #include "cbdata.h" #include "comm/forward.h" #include "hier_code.h" #include "ip/Address.h" #include "PingData.h" class HttpRequest; class StoreEntry; class ErrorState; typedef void PSC(Comm::ConnectionList *, ErrorState *, void *); void peerSelect(Comm::ConnectionList *, HttpRequest *, AccessLogEntry::Pointer const&, StoreEntry *, PSC *, void *data); void peerSelectInit(void); /** * A CachePeer which has been selected as a possible destination. * Listed as pointers here so as to prevent duplicates being added but will * be converted to a set of IP address path options before handing back out * to the caller. * * Certain connection flags and outgoing settings will also be looked up and * set based on the received request and CachePeer settings before handing back. */ class FwdServer { public: CachePeer *_peer; /* NULL --> origin server */ hier_code code; FwdServer *next; === modified file 'src/StoreFileSystem.cc' --- src/StoreFileSystem.cc 2014-02-04 19:47:14 +0000 +++ src/StoreFileSystem.cc 2014-02-10 12:55:31 +0000 @@ -8,93 +8,93 @@ * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * Copyright (c) 2003, Robert Collins */ #include "squid.h" #include "StoreFileSystem.h" -Vector *StoreFileSystem::_FileSystems = NULL; +std::vector *StoreFileSystem::_FileSystems = NULL; void StoreFileSystem::RegisterAllFsWithCacheManager(void) { for (iterator i = GetFileSystems().begin(); i != GetFileSystems().end(); ++i) (*i)->registerWithCacheManager(); } void StoreFileSystem::SetupAllFs() { for (iterator i = GetFileSystems().begin(); i != GetFileSystems().end(); ++i) /* Call the FS to set up capabilities and initialize the FS driver */ (*i)->setup(); } void StoreFileSystem::FsAdd(StoreFileSystem &instance) { iterator i = GetFileSystems().begin(); while (i != GetFileSystems().end()) { assert(strcmp((*i)->type(), instance.type()) != 0); ++i; } GetFileSystems().push_back (&instance); } -Vector const & +std::vector const & StoreFileSystem::FileSystems() { return GetFileSystems(); } -Vector & +std::vector & StoreFileSystem::GetFileSystems() { if (!_FileSystems) - _FileSystems = new Vector; + _FileSystems = new std::vector; return *_FileSystems; } /* * called when a graceful shutdown is to occur * of each fs module. */ void StoreFileSystem::FreeAllFs() { while (!GetFileSystems().empty()) { StoreFileSystem *fs = GetFileSystems().back(); GetFileSystems().pop_back(); fs->done(); } } /* no filesystem is required to export statistics */ void StoreFileSystem::registerWithCacheManager(void) {} === modified file 'src/StoreFileSystem.h' --- src/StoreFileSystem.h 2013-09-30 12:30:50 +0000 +++ src/StoreFileSystem.h 2014-02-10 17:37:36 +0000 @@ -4,61 +4,61 @@ * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * Copyright (c) 2003, Robert Collins */ #ifndef SQUID_STOREFILESYSTEM_H #define SQUID_STOREFILESYSTEM_H -#include "base/Vector.h" +#include /* ****** DOCUMENTATION ***** */ /** \defgroup FileSystems Storage Filesystems * \section Introduction Introduction \par * Traditionally, Squid has always used the Unix filesystem (\link UFS UFS\endlink) * to store cache objects on disk. Over the years, the * poor performance of \link UFS UFS\endlink has become very obvious. In most * cases, \link UFS UFS\endlink limits Squid to about 30-50 requests per second. * Our work indicates that the poor performance is mostly * due to the synchronous nature of open() and unlink() * system calls, and perhaps thrashing of inode/buffer caches. * \par * We want to try out our own, customized filesystems with Squid. * In order to do that, we need a well-defined interface * for the bits of Squid that access the permanent storage * devices. We also require tighter control of the replacement * policy by each storage module, rather than a single global * replacement policy. * \section BuildStructure Build structure \par * The storage types live in \em src/fs/. Each subdirectory corresponds * to the name of the storage type. When a new storage type is implemented * configure.ac must be updated to autogenerate a Makefile in * \em src/fs/foo/ from a Makefile.in file. @@ -89,59 +89,59 @@ * \par * Each open object has associated with it a storeIOState object. The * storeIOState object is used to record the state of the current * object. Each storeIOState can have a storage module specific data * structure containing information private to the storage module. * \par * Each SwapDir has the concept of a maximum object size. This is used * as a basic hint to the storage layer in first choosing a suitable * SwapDir. The checkobj function is then called for suitable * candidate SwapDirs to find out whether it wants to store a * given StoreEntry. A maxobjsize of -1 means 'any size'. */ class SwapDir; /** \ingroup FileSystems * * The core API for storage modules this class provides all the hooks * squid uses to interact with a filesystem IO module. */ class StoreFileSystem { public: static void SetupAllFs(); static void FsAdd(StoreFileSystem &); static void FreeAllFs(); - static Vector const &FileSystems(); - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + static std::vector const &FileSystems(); + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; StoreFileSystem() : initialised(false) {} virtual ~StoreFileSystem() {} virtual char const *type () const = 0; virtual SwapDir *createSwapDir() = 0; virtual void done() = 0; virtual void setup() = 0; // Not implemented StoreFileSystem(StoreFileSystem const &); StoreFileSystem &operator=(StoreFileSystem const&); protected: bool initialised; virtual void registerWithCacheManager(void); private: - static Vector &GetFileSystems(); - static Vector *_FileSystems; + static std::vector &GetFileSystems(); + static std::vector *_FileSystems; static void RegisterAllFsWithCacheManager(void); }; // TODO: Kill this typedef! typedef StoreFileSystem storefs_entry_t; #endif /* SQUID_STOREFILESYSTEM_H */ === modified file 'src/StoreHashIndex.h' --- src/StoreHashIndex.h 2012-10-16 00:18:09 +0000 +++ src/StoreHashIndex.h 2014-02-10 12:53:55 +0000 @@ -90,37 +90,37 @@ private: class StoreHashIndexEntry : public StoreEntry {}; class StoreSearchHashIndex : public StoreSearch { public: StoreSearchHashIndex(RefCount sd); StoreSearchHashIndex(StoreSearchHashIndex const &); virtual ~StoreSearchHashIndex(); /* Iterator API - garh, wrong place */ /* callback the client when a new StoreEntry is available * or an error occurs */ virtual void next(void (callback)(void *cbdata), void *cbdata); /* return true if a new StoreEntry is immediately available */ virtual bool next(); virtual bool error() const; virtual bool isDone() const; virtual StoreEntry *currentItem(); RefCount sd; private: void copyBucket(); void (*callback)(void *cbdata); void *cbdata; bool _done; int bucket; - Vector entries; + std::vector entries; // keep this last. it plays with private/public CBDATA_CLASS2(StoreSearchHashIndex); }; #endif /* SQUID_STOREHASHINDEX_H */ === modified file 'src/acl/Acl.cc' --- src/acl/Acl.cc 2014-01-06 20:55:13 +0000 +++ src/acl/Acl.cc 2014-02-10 12:38:47 +0000 @@ -14,60 +14,62 @@ * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #include "squid.h" #include "acl/Acl.h" #include "acl/Checklist.h" #include "acl/Gadgets.h" #include "anyp/PortCfg.h" #include "cache_cf.h" #include "ConfigParser.h" #include "Debug.h" #include "dlink.h" #include "globals.h" #include "profiler/Profiler.h" #include "SquidConfig.h" +#include + const ACLFlag ACLFlags::NoFlags[1] = {ACL_F_END}; const char *AclMatchedName = NULL; bool ACLFlags::supported(const ACLFlag f) const { if (f == ACL_F_REGEX_CASE) return true; return (supported_.find(f) != std::string::npos); } void ACLFlags::parseFlags() { char *nextToken; while ((nextToken = ConfigParser::PeekAtToken()) != NULL && nextToken[0] == '-') { (void)ConfigParser::NextToken(); //Get token from cfg line //if token is the "--" break flag if (strcmp(nextToken, "--") == 0) break; for (const char *flg = nextToken+1; *flg!='\0'; flg++ ) { if (supported(*flg)) { makeSet(*flg); } else { debugs(28, 0, HERE << "Flag '" << *flg << "' not supported"); self_destruct(); } } } @@ -378,85 +380,85 @@ aclCacheMatchFlush(dlink_list * cache) bool ACL::requiresReply() const { return false; } bool ACL::requiresRequest() const { return false; } /*********************/ /* Destroy functions */ /*********************/ ACL::~ACL() { debugs(28, 3, "ACL::~ACL: '" << cfgline << "'"); safe_free(cfgline); AclMatchedName = NULL; // in case it was pointing to our name } ACL::Prototype::Prototype() : prototype (NULL), typeString (NULL) {} ACL::Prototype::Prototype (ACL const *aPrototype, char const *aType) : prototype (aPrototype), typeString (aType) { registerMe (); } -Vector * ACL::Prototype::Registry; +std::vector * ACL::Prototype::Registry; void *ACL::Prototype::Initialized; bool ACL::Prototype::Registered(char const *aType) { debugs(28, 7, "ACL::Prototype::Registered: invoked for type " << aType); for (iterator i = Registry->begin(); i != Registry->end(); ++i) if (!strcmp (aType, (*i)->typeString)) { debugs(28, 7, "ACL::Prototype::Registered: yes"); return true; } debugs(28, 7, "ACL::Prototype::Registered: no"); return false; } void ACL::Prototype::registerMe () { if (!Registry || (Initialized != ((char *)Registry - 5)) ) { /* TODO: extract this */ /* Not initialised */ - Registry = new Vector ; + Registry = new std::vector; Initialized = (char *)Registry - 5; } if (Registered (typeString)) fatalf ("Attempt to register %s twice", typeString); Registry->push_back (this); } ACL::Prototype::~Prototype() { // TODO: unregister me } ACL * ACL::Prototype::Factory (char const *typeToClone) { debugs(28, 4, "ACL::Prototype::Factory: cloning an object for type '" << typeToClone << "'"); for (iterator i = Registry->begin(); i != Registry->end(); ++i) if (!strcmp (typeToClone, (*i)->typeString)) { ACL *A = (*i)->prototype->clone(); A->flags = (*i)->prototype->flags; return A; } debugs(28, 4, "ACL::Prototype::Factory: cloning failed, no type '" << typeToClone << "' available"); return NULL; } === modified file 'src/acl/Acl.h' --- src/acl/Acl.h 2014-01-11 01:35:50 +0000 +++ src/acl/Acl.h 2014-02-10 12:38:47 +0000 @@ -7,72 +7,72 @@ * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * * Copyright (c) 2003, Robert Collins */ #ifndef SQUID_ACL_H #define SQUID_ACL_H #include "acl/forward.h" -#include "base/Vector.h" #include "cbdata.h" #include "defines.h" #include "dlink.h" #include "MemPool.h" #if HAVE_OSTREAM #include #endif #if HAVE_STRING #include #endif +#include class ConfigParser; typedef char ACLFlag; // ACLData Flags #define ACL_F_REGEX_CASE 'i' #define ACL_F_NO_LOOKUP 'n' #define ACL_F_STRICT 's' #define ACL_F_END '\0' /** * \ingroup ACLAPI * Used to hold a list of one-letter flags which can be passed as parameters * to acls (eg '-i', '-n' etc) */ class ACLFlags { public: explicit ACLFlags(const ACLFlag flags[]) : supported_(flags), flags_(0) {} ACLFlags() : flags_(0) {} bool supported(const ACLFlag f) const; ///< True if the given flag supported void makeSet(const ACLFlag f) { flags_ |= flagToInt(f); } ///< Set the given flag /// Return true if the given flag is set bool isSet(const ACLFlag f) const { return flags_ & flagToInt(f);} /// Parse optional flags given in the form -[A..Z|a..z] void parseFlags(); const char *flagsStr() const; ///< Convert the flags to a string representation private: /// Convert a flag to a 64bit unsigned integer. @@ -130,64 +130,64 @@ public: virtual bool valid() const; int cacheMatchAcl(dlink_list * cache, ACLChecklist *); virtual int matchForCache(ACLChecklist *checklist); virtual void prepareForUse() {} char name[ACL_NAME_SZ]; char *cfgline; ACL *next; // XXX: remove or at least use refcounting ACLFlags flags; ///< The list of given ACL flags bool registered; ///< added to the global list of ACLs via aclRegister() public: class Prototype { public: Prototype(); Prototype(ACL const *, char const *); ~Prototype(); static bool Registered(char const *); static ACL *Factory(char const *); private: ACL const *prototype; char const *typeString; private: - static Vector * Registry; + static std::vector * Registry; static void *Initialized; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; void registerMe(); }; private: /// Matches the actual data in checklist against this ACL. virtual int match(ACLChecklist *checklist) = 0; // XXX: missing const /// whether our (i.e. shallow) match() requires checklist to have a request virtual bool requiresRequest() const; /// whether our (i.e. shallow) match() requires checklist to have a reply virtual bool requiresReply() const; }; /// \ingroup ACLAPI typedef enum { // Authorization ACL result states ACCESS_DENIED, ACCESS_ALLOWED, ACCESS_DUNNO, // Authentication ACL result states ACCESS_AUTH_REQUIRED, // Missing Credentials } aclMatchCode; /// \ingroup ACLAPI /// ACL check answer; TODO: Rename to Acl::Answer class allow_t { public: // not explicit: allow "aclMatchCode to allow_t" conversions (for now) === modified file 'src/acl/NoteData.cc' --- src/acl/NoteData.cc 2013-10-31 19:13:17 +0000 +++ src/acl/NoteData.cc 2014-02-10 12:44:48 +0000 @@ -2,61 +2,61 @@ #include "acl/Acl.h" #include "acl/Checklist.h" #include "acl/NoteData.h" #include "acl/StringData.h" #include "cache_cf.h" #include "ConfigParser.h" #include "Debug.h" #include "HttpRequest.h" #include "Notes.h" #include "wordlist.h" ACLNoteData::ACLNoteData() : values(new ACLStringData) {} ACLNoteData::~ACLNoteData() { delete values; } bool ACLNoteData::matchNotes(NotePairs *note) { if (note == NULL) return false; debugs(28, 3, "Checking " << name); if (values->empty()) return (note->findFirst(name.termedBuf()) != NULL); - for (Vector::iterator i = note->entries.begin(); i!= note->entries.end(); ++i) { + for (std::vector::iterator i = note->entries.begin(); i!= note->entries.end(); ++i) { if ((*i)->name.cmp(name.termedBuf()) == 0) { if (values->match((*i)->value.termedBuf())) return true; } } return false; } bool ACLNoteData::match(HttpRequest *request) { if (request->notes != NULL && matchNotes(request->notes.getRaw())) return true; #if USE_ADAPTATION const Adaptation::History::Pointer ah = request->adaptLogHistory(); if (ah != NULL && ah->metaHeaders != NULL && matchNotes(ah->metaHeaders.getRaw())) return true; #endif return false; } wordlist * ACLNoteData::dump() { wordlist *W = NULL; wordlistAdd(&W, name.termedBuf()); wordlist * dumpR = values->dump(); wordlistAddWl(&W, dumpR); wordlistDestroy(&dumpR); return W; === modified file 'src/adaptation/AccessCheck.cc' --- src/adaptation/AccessCheck.cc 2014-02-02 08:57:20 +0000 +++ src/adaptation/AccessCheck.cc 2014-02-10 16:06:10 +0000 @@ -104,106 +104,106 @@ Adaptation::AccessCheck::check() debugs(93, 5, HERE << "check: rule '" << r->id << "' is a candidate"); candidates.push_back(r->id); } } checkCandidates(); } // XXX: Here and everywhere we call FindRule(topCandidate()): // Once we identified the candidate, we should not just ignore it // if reconfigure changes rules. We should either lock the rule to // prevent reconfigure from stealing it or restart the check with // new rules. Throwing an exception may also be appropriate. void Adaptation::AccessCheck::checkCandidates() { debugs(93, 4, HERE << "has " << candidates.size() << " rules"); while (!candidates.empty()) { if (AccessRule *r = FindRule(topCandidate())) { /* BUG 2526: what to do when r->acl is empty?? */ // XXX: we do not have access to conn->rfc931 here. acl_checklist = new ACLFilledChecklist(r->acl, filter.request, dash_str); if ((acl_checklist->reply = filter.reply)) HTTPMSGLOCK(acl_checklist->reply); acl_checklist->al = filter.al; acl_checklist->nonBlockingCheck(AccessCheckCallbackWrapper, this); return; } - candidates.shift(); // the rule apparently went away (reconfigure) + candidates.erase(candidates.begin()); // the rule apparently went away (reconfigure) } debugs(93, 4, HERE << "NO candidates left"); callBack(NULL); Must(done()); } void Adaptation::AccessCheck::AccessCheckCallbackWrapper(allow_t answer, void *data) { debugs(93, 8, HERE << "callback answer=" << answer); AccessCheck *ac = (AccessCheck*)data; /** \todo AYJ 2008-06-12: If answer == ACCESS_AUTH_REQUIRED * we should be kicking off an authentication before continuing * with this request. see bug 2400 for details. */ // convert to async call to get async call protections and features typedef UnaryMemFunT MyDialer; AsyncCall::Pointer call = asyncCall(93,7, "Adaptation::AccessCheck::noteAnswer", MyDialer(ac, &Adaptation::AccessCheck::noteAnswer, answer)); ScheduleCallHere(call); } /// process the results of the ACL check void Adaptation::AccessCheck::noteAnswer(allow_t answer) { Must(!candidates.empty()); // the candidate we were checking must be there debugs(93,5, HERE << topCandidate() << " answer=" << answer); if (answer == ACCESS_ALLOWED) { // the rule matched ServiceGroupPointer g = topGroup(); if (g != NULL) { // the corresponding group found callBack(g); Must(done()); return; } } // no match or the group disappeared during reconfiguration - candidates.shift(); + candidates.erase(candidates.begin()); checkCandidates(); } /// call back with a possibly nil group; the job ends here because all failures /// at this point are fatal to the access check process void Adaptation::AccessCheck::callBack(const ServiceGroupPointer &g) { debugs(93,3, HERE << g); CallJobHere1(93, 5, theInitiator, Adaptation::Initiator, noteAdaptationAclCheckDone, g); mustStop("done"); // called back or will never be able to call back } Adaptation::ServiceGroupPointer Adaptation::AccessCheck::topGroup() const { ServiceGroupPointer g; if (candidates.size()) { if (AccessRule *r = FindRule(topCandidate())) { g = FindGroup(r->groupId); debugs(93,5, HERE << "top group for " << r->id << " is " << g); } else { debugs(93,5, HERE << "no rule for " << topCandidate()); } } else { debugs(93,5, HERE << "no candidates"); // should not happen } return g; === modified file 'src/adaptation/AccessCheck.h' --- src/adaptation/AccessCheck.h 2014-02-08 13:36:42 +0000 +++ src/adaptation/AccessCheck.h 2014-02-10 16:02:57 +0000 @@ -12,58 +12,58 @@ class HttpRequest; class HttpReply; class ACLFilledChecklist; namespace Adaptation { class AccessRule; // checks adaptation_access rules to find a matching adaptation service class AccessCheck: public virtual AsyncJob { public: typedef void AccessCheckCallback(ServiceGroupPointer group, void *data); // use this to start async ACL checks; returns true if started static bool Start(Method method, VectPoint vp, HttpRequest *req, HttpReply *rep, AccessLogEntry::Pointer &al, Adaptation::Initiator *initiator); protected: // use Start to start adaptation checks AccessCheck(const ServiceFilter &aFilter, Adaptation::Initiator *); ~AccessCheck(); private: const ServiceFilter filter; CbcPointer theInitiator; ///< the job which ordered this access check ACLFilledChecklist *acl_checklist; typedef int Candidate; - typedef Vector Candidates; + typedef std::vector Candidates; Candidates candidates; Candidate topCandidate() const { return *candidates.begin(); } ServiceGroupPointer topGroup() const; // may return nil void callBack(const ServiceGroupPointer &g); bool isCandidate(AccessRule &r); public: void checkCandidates(); static void AccessCheckCallbackWrapper(allow_t, void*); void noteAnswer(allow_t answer); protected: // AsyncJob API virtual void start(); virtual bool doneAll() const { return false; } /// not done until mustStop bool usedDynamicRules(); void check(); private: CBDATA_CLASS2(AccessCheck); }; } // namespace Adaptation #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */ === modified file 'src/adaptation/AccessRule.h' --- src/adaptation/AccessRule.h 2013-05-13 22:48:23 +0000 +++ src/adaptation/AccessRule.h 2014-02-11 07:52:17 +0000 @@ -1,44 +1,46 @@ #ifndef SQUID_ADAPTATION__ACCESS_RULE_H #define SQUID_ADAPTATION__ACCESS_RULE_H #include "acl/forward.h" #include "adaptation/forward.h" #include "SquidString.h" +#include + class ConfigParser; namespace Adaptation { // manages adaptation_access configuration by associating an acl with // an adaptation service group class AccessRule { public: AccessRule(const String &groupId); ~AccessRule(); void parse(ConfigParser &parser); void finalize(); // service group consisting of one or more services ServiceGroupPointer group(); public: typedef int Id; const Id id; String groupId; acl_access *acl; private: static Id LastId; }; -typedef Vector AccessRules; +typedef std::vector AccessRules; AccessRules &AllRules(); AccessRule *FindRule(const AccessRule::Id &id); AccessRule *FindRuleByGroupId(const String &groupId); } // namespace Adaptation #endif /* SQUID_ADAPTATION__ACCESS_RULE_H */ === modified file 'src/adaptation/Config.cc' --- src/adaptation/Config.cc 2014-02-02 09:42:23 +0000 +++ src/adaptation/Config.cc 2014-02-10 17:39:03 +0000 @@ -9,148 +9,149 @@ * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #include "squid.h" #include "acl/FilledChecklist.h" #include "acl/Gadgets.h" #include "adaptation/AccessRule.h" #include "adaptation/Config.h" #include "adaptation/History.h" #include "adaptation/Service.h" #include "adaptation/ServiceGroups.h" -#include "base/Vector.h" #include "ConfigParser.h" #include "globals.h" #include "HttpReply.h" #include "HttpRequest.h" #include "Store.h" +#include + bool Adaptation::Config::Enabled = false; char *Adaptation::Config::masterx_shared_name = NULL; int Adaptation::Config::service_iteration_limit = 16; int Adaptation::Config::send_client_ip = false; int Adaptation::Config::send_username = false; int Adaptation::Config::use_indirect_client = true; const char *metasBlacklist[] = { "Methods", "Service", "ISTag", "Encapsulated", "Opt-body-type", "Max-Connections", "Options-TTL", "Date", "Service-ID", "Allow", "Preview", "Transfer-Preview", "Transfer-Ignore", "Transfer-Complete", NULL }; Notes Adaptation::Config::metaHeaders("ICAP header", metasBlacklist, true); bool Adaptation::Config::needHistory = false; Adaptation::ServiceConfig* Adaptation::Config::newServiceConfig() const { return new ServiceConfig(); } void Adaptation::Config::removeService(const String& service) { removeRule(service); const Groups& groups = AllGroups(); for (unsigned int i = 0; i < groups.size(); ) { const ServiceGroupPointer group = groups[i]; const ServiceGroup::Store& services = group->services; typedef ServiceGroup::Store::const_iterator SGSI; for (SGSI it = services.begin(); it != services.end(); ++it) { if (*it == service) { group->removedServices.push_back(service); - group->services.prune(service); - debugs(93, 5, HERE << "adaptation service " << service << + std::remove(group->services.begin(),group->services.end(),service); + debugs(93, 5, "adaptation service " << service << " removed from group " << group->id); break; } } if (services.empty()) { removeRule(group->id); - AllGroups().prune(group); + std::remove(AllGroups().begin(),AllGroups().end(),group); } else { ++i; } } } Adaptation::ServiceConfigPointer Adaptation::Config::findServiceConfig(const String &service) { typedef ServiceConfigs::const_iterator SCI; const ServiceConfigs& configs = serviceConfigs; for (SCI cfg = configs.begin(); cfg != configs.end(); ++cfg) { if ((*cfg)->key == service) return *cfg; } return NULL; } void Adaptation::Config::removeRule(const String& id) { typedef AccessRules::const_iterator ARI; const AccessRules& rules = AllRules(); for (ARI it = rules.begin(); it != rules.end(); ++it) { AccessRule* rule = *it; if (rule->groupId == id) { - debugs(93, 5, HERE << "removing access rules for:" << id); - AllRules().prune(rule); + debugs(93, 5, "removing access rules for:" << id); + std::remove(AllRules().begin(),AllRules().end(),rule); delete (rule); break; } } } void Adaptation::Config::clear() { debugs(93, 3, HERE << "rules: " << AllRules().size() << ", groups: " << AllGroups().size() << ", services: " << serviceConfigs.size()); typedef ServiceConfigs::const_iterator SCI; const ServiceConfigs& configs = serviceConfigs; for (SCI cfg = configs.begin(); cfg != configs.end(); ++cfg) removeService((*cfg)->key); serviceConfigs.clear(); debugs(93, 3, HERE << "rules: " << AllRules().size() << ", groups: " << AllGroups().size() << ", services: " << serviceConfigs.size()); } void Adaptation::Config::parseService() { ServiceConfigPointer cfg = newServiceConfig(); if (!cfg->parse()) { fatalf("%s:%d: malformed adaptation service configuration", cfg_filename, config_lineno); } serviceConfigs.push_back(cfg); } === modified file 'src/adaptation/Config.h' --- src/adaptation/Config.h 2013-11-12 14:48:50 +0000 +++ src/adaptation/Config.h 2014-02-10 16:04:26 +0000 @@ -24,61 +24,61 @@ public: static void ParseServiceSet(void); static void ParseServiceChain(void); static void ParseAccess(ConfigParser &parser); static void FreeAccess(void); static void DumpAccess(StoreEntry *, const char *); friend class AccessCheck; public: static bool Enabled; // true if at least one adaptation mechanism is // these are global squid.conf options, documented elsewhere static char *masterx_shared_name; // global TODO: do we need TheConfig? static int service_iteration_limit; static int send_client_ip; static int send_username; static int use_indirect_client; // Options below are accessed via Icap::TheConfig or Ecap::TheConfig // TODO: move ICAP-specific options to Icap::Config and add TheConfig int onoff; int service_failure_limit; time_t oldest_service_failure; int service_revival_delay; static Notes metaHeaders; ///< The list of configured meta headers static bool needHistory; ///< HttpRequest adaptation history should recorded - typedef Vector ServiceConfigs; + typedef std::vector ServiceConfigs; ServiceConfigs serviceConfigs; Config(); virtual ~Config(); void parseService(void); void freeService(void); void dumpService(StoreEntry *, const char *) const; ServiceConfigPointer findServiceConfig(const String&); /** * Creates and starts the adaptation services. In the case the adaptation * mechanism is disabled then removes any reference to the services from * access rules and service groups, and returns false. * \return true if the services are ready and running, false otherwise */ virtual bool finalize(); protected: /// Removes any reference to the services from configuration virtual void clear(); /// creates service configuration object that will parse and keep cfg info virtual ServiceConfig *newServiceConfig() const; /// Removes the given service from all service groups. void removeService(const String& service); /// Removes access rules of the given service or group void removeRule(const String& id); === modified file 'src/adaptation/DynamicGroupCfg.h' --- src/adaptation/DynamicGroupCfg.h 2013-05-04 11:50:26 +0000 +++ src/adaptation/DynamicGroupCfg.h 2014-02-10 16:31:03 +0000 @@ -1,34 +1,35 @@ #ifndef SQUID_ADAPTATION__DYNAMIC_GROUP_CFG_H #define SQUID_ADAPTATION__DYNAMIC_GROUP_CFG_H -#include "base/Vector.h" #include "SquidString.h" +#include + namespace Adaptation { /// DynamicServiceGroup configuration to remember future dynamic chains class DynamicGroupCfg { public: - typedef Vector Store; + typedef std::vector Store; typedef String Id; Id id; ///< group id Store services; ///< services in the group bool empty() const { return services.empty(); } ///< no services added void add(const String &item); ///< updates group id and services void clear(); ///< makes the config empty }; inline std::ostream &operator <<(std::ostream &os, const DynamicGroupCfg &cfg) { return os << cfg.id; } } // namespace Adaptation #endif /* SQUID_ADAPTATION__DYNAMIC_GROUP_CFG_H */ === modified file 'src/adaptation/History.h' --- src/adaptation/History.h 2013-11-12 14:48:50 +0000 +++ src/adaptation/History.h 2014-02-10 17:39:09 +0000 @@ -1,103 +1,102 @@ #ifndef SQUID_ADAPT_HISTORY_H #define SQUID_ADAPT_HISTORY_H #include "adaptation/DynamicGroupCfg.h" #include "base/RefCount.h" -#include "base/Vector.h" #include "HttpHeader.h" #include "Notes.h" #include "SBuf.h" #include "SquidString.h" namespace Adaptation { /// collects information about adaptations related to a master transaction class History: public RefCountable { public: typedef RefCount Pointer; History(); /// record the start of a xact, return xact history ID int recordXactStart(const String &serviceId, const timeval &when, bool retrying); /// record the end of a xact identified by its history ID void recordXactFinish(int hid); /// dump individual xaction times to a string void allLogString(const char *serviceId, String &buf); /// dump xaction times, merging retried and retry times together void sumLogString(const char *serviceId, String &buf); /// sets or resets a cross-transactional database record void updateXxRecord(const char *name, const String &value); /// returns true and fills the record fields iff there is a db record bool getXxRecord(String &name, String &value) const; /// sets or resets next services for the Adaptation::Iterator to notice void updateNextServices(const String &services); /// returns true, fills the value, and resets iff next services were set bool extractNextServices(String &value); /// store the last meta header fields received from the adaptation service void recordMeta(const HttpHeader *lm); void recordAdaptationService(SBuf &srvId); public: /// Last received meta header (REQMOD or RESPMOD, whichever comes last). HttpHeader lastMeta; /// All REQMOD and RESPMOD meta headers merged. Last field wins conflicts. HttpHeader allMeta; /// key:value pairs set by adaptation_meta, to be added to /// AccessLogEntry::notes when ALE becomes available NotePairs::Pointer metaHeaders; - typedef Vector AdaptationServices; + typedef std::vector AdaptationServices; AdaptationServices theAdaptationServices; ///< The service groups used /// sets future services for the Adaptation::AccessCheck to notice void setFutureServices(const DynamicGroupCfg &services); /// returns true, fills the value, and resets iff future services were set bool extractFutureServices(DynamicGroupCfg &services); private: /// single Xaction stats (i.e., a historical record entry) class Entry { public: Entry(const String &serviceId, const timeval &when); Entry(); // required by Vector<> void stop(); ///< updates stats on transaction end int rptm(); ///< returns response time [msec], calculates it if needed String service; ///< adaptation service ID timeval start; ///< when the xaction was started private: int theRptm; ///< calculated and cached response time value in msec public: bool retried; ///< whether the xaction was replaced by another }; - typedef Vector Entries; + typedef std::vector Entries; Entries theEntries; ///< historical record, in the order of xact starts // theXx* will become a map, but we only support one record String theXxName; ///< name part of the cross-transactional database record String theXxValue; ///< value part of the cross-xactional database record String theNextServices; ///< services Adaptation::Iterator must use next DynamicGroupCfg theFutureServices; ///< services AccessCheck must use }; } // namespace Adaptation #endif === modified file 'src/adaptation/Service.h' --- src/adaptation/Service.h 2013-12-05 11:04:45 +0000 +++ src/adaptation/Service.h 2014-02-10 16:31:43 +0000 @@ -34,40 +34,40 @@ public: virtual Initiate *makeXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp) = 0; bool wants(const ServiceFilter &filter) const; // the methods below can only be called on an up() service virtual bool wantsUrl(const String &urlPath) const = 0; // called by transactions to report service failure virtual void noteFailure() = 0; const ServiceConfig &cfg() const { return *theConfig; } virtual void finalize(); // called after creation /// called when removed from the config; the service will be /// auto-destroyed when the last refcounting user leaves virtual void detach() = 0; /// whether detached() was called virtual bool detached() const = 0; protected: ServiceConfig &writeableCfg() { return *theConfig; } private: ServiceConfigPointer theConfig; }; typedef Service::Pointer ServicePointer; -typedef Vector Services; +typedef std::vector Services; Services &AllServices(); ServicePointer FindService(const Service::Id &key); /// detach all adaptation services from current configuration void DetachServices(); } // namespace Adaptation #endif /* SQUID_ADAPTATION__SERVICE_H */ === modified file 'src/adaptation/ServiceGroups.h' --- src/adaptation/ServiceGroups.h 2013-10-25 00:13:46 +0000 +++ src/adaptation/ServiceGroups.h 2014-02-10 16:34:45 +0000 @@ -1,52 +1,53 @@ #ifndef SQUID_ADAPTATION__SERVICE_GROUPS_H #define SQUID_ADAPTATION__SERVICE_GROUPS_H #include "adaptation/Elements.h" #include "adaptation/forward.h" #include "base/RefCount.h" -#include "base/Vector.h" #include "SquidString.h" +#include + namespace Adaptation { // Interface for grouping adaptation services together. // Specific groups differ in how the first and the next services are selected class ServiceGroup: public RefCountable { public: typedef RefCount Pointer; - typedef Vector Store; + typedef std::vector Store; typedef String Id; - typedef unsigned int Pos; // Vector<>::poistion_type + typedef unsigned int Pos; // vector<>::position_type friend class ServicePlan; public: ServiceGroup(const String &aKind, bool areAllServicesSame); virtual ~ServiceGroup(); virtual void parse(); virtual void finalize(); // called after all are parsed bool wants(const ServiceFilter &filter) const; protected: ///< whether this group has a service at the specified pos bool has(const Pos pos) const { // does not check that the service at pos still exists return pos < services.size(); // unsigned pos is never negative } /// these methods control group iteration; used by ServicePlan /// find next to try after failure, starting with pos bool findReplacement(const ServiceFilter &filter, Pos &pos) const; /// find next to link after success, starting with pos bool findLink(const ServiceFilter &filter, Pos &pos) const; private: ServicePointer at(const Pos pos) const; bool findService(const ServiceFilter &filter, Pos &pos) const; void checkUniqueness(const Pos checkedPos) const; @@ -86,66 +87,66 @@ protected: virtual bool advance(Pos &pos) const { return false; } }; /// a group of services that must be used one after another class ServiceChain: public ServiceGroup { public: ServiceChain(); protected: virtual bool replace(Pos &pos) const { return false; } virtual bool advance(Pos &pos) const { return has(++pos); } }; /// a temporary service chain built upon another service request class DynamicServiceChain: public ServiceChain { public: DynamicServiceChain(const DynamicGroupCfg &cfg, const ServiceFilter &f); /// separates dynamic services matching current location from future ones static void Split(const ServiceFilter &filter, const String &ids, DynamicGroupCfg ¤t, DynamicGroupCfg &future); }; /** iterates services stored in a group; iteration is not linear because we need to both replace failed services and advance to the next chain link */ class ServicePlan { public: - typedef unsigned int Pos; // Vector<>::poistion_type + typedef unsigned int Pos; // vector<>::position_type public: ServicePlan(); explicit ServicePlan(const ServiceGroupPointer &g, const ServiceFilter &filter); ///< true iff there are no more services planned bool exhausted() const { return atEof; } /// returns nil if the plan is complete ServicePointer current() const; ///< current service ServicePointer replacement(const ServiceFilter &filter); ///< next to try after failure ServicePointer next(const ServiceFilter &filter); ///< next in chain after success std::ostream &print(std::ostream &os) const; private: ServiceGroupPointer group; ///< the group we are iterating Pos pos; ///< current service position within the group bool atEof; ///< cached information for better performance }; inline std::ostream &operator <<(std::ostream &os, const ServicePlan &p) { return p.print(os); } -typedef Vector Groups; +typedef std::vector Groups; Groups &AllGroups(); ServiceGroupPointer FindGroup(const ServiceGroup::Id &id); } // namespace Adaptation #endif /* SQUID_ADAPTATION__SERVICE_GROUPS_H */ === modified file 'src/adaptation/icap/Config.cc' --- src/adaptation/icap/Config.cc 2013-10-25 00:13:46 +0000 +++ src/adaptation/icap/Config.cc 2014-02-10 16:03:37 +0000 @@ -6,61 +6,60 @@ * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * * Copyright (c) 2003, Robert Collins */ #include "squid.h" #include "adaptation/icap/Config.h" #include "adaptation/icap/ServiceRep.h" -#include "base/Vector.h" #include "ConfigParser.h" #include "HttpReply.h" #include "HttpRequest.h" #include "SquidConfig.h" #include "Store.h" #include "wordlist.h" Adaptation::Icap::Config Adaptation::Icap::TheConfig; Adaptation::Icap::Config::Config() : preview_enable(0), preview_size(0), allow206_enable(0), connect_timeout_raw(0), io_timeout_raw(0), reuse_connections(0), client_username_header(NULL), client_username_encode(0), repeat(NULL), repeat_limit(0) { } Adaptation::Icap::Config::~Config() { // no need to free client_username_header, it's done in cf_parser.cci:free_all } Adaptation::ServicePointer Adaptation::Icap::Config::createService(const ServiceConfigPointer &cfg) { return new Adaptation::Icap::ServiceRep(cfg); } time_t Adaptation::Icap::Config::connect_timeout(bool bypassable) const { === modified file 'src/adaptation/icap/Options.h' --- src/adaptation/icap/Options.h 2012-09-01 14:38:36 +0000 +++ src/adaptation/icap/Options.h 2014-02-10 12:51:56 +0000 @@ -44,61 +44,61 @@ namespace Icap /* Maintains options supported by a given ICAP service. * See RFC 3507, Section "4.10.2 OPTIONS Response". */ class Options { public: typedef void GetCallback(void *data, Options *options); static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data); public: Options(); ~Options(); void configure(const HttpReply *reply); bool valid() const; bool fresh() const; int ttl() const; time_t expire() const; time_t timestamp() const { return theTimestamp; }; typedef enum { xferNone, xferPreview, xferIgnore, xferComplete } TransferKind; TransferKind transferKind(const String &urlPath) const; public: const char *error; // human-readable information; set iff !valid() // ICAP server MUST supply this info - Vector methods; + std::vector methods; String istag; // ICAP server MAY supply this info. If not, Squid supplies defaults. String service; String serviceId; int max_connections; bool allow204; bool allow206; int preview; protected: // Transfer-* extension list representation // maintains wordlist and does parsing/matching class TransferList { public: TransferList(); ~TransferList(); bool matches(const String &urlPath) const; void parse(const String &buf, bool &foundStar); void add(const char *extension); void report(int level, const char *prefix) const; public: wordlist *extensions; // TODO: optimize with a hash of some sort const char *name; // header name, mostly for debugging TransferKind kind; // to simplify caller's life }; === modified file 'src/adaptation/icap/ServiceRep.cc' --- src/adaptation/icap/ServiceRep.cc 2014-02-04 19:47:14 +0000 +++ src/adaptation/icap/ServiceRep.cc 2014-02-10 12:51:56 +0000 @@ -443,61 +443,61 @@ void Adaptation::Icap::ServiceRep::chang delete theOptions; theOptions = newOptions; theSessionFailures.clear(); isSuspended = 0; theLastUpdate = squid_curtime; checkOptions(); announceStatusChange("down after an options fetch failure", true); } void Adaptation::Icap::ServiceRep::checkOptions() { if (theOptions == NULL) return; if (!theOptions->valid()) { debugs(93, DBG_IMPORTANT, "WARNING: Squid got an invalid ICAP OPTIONS response " << "from service " << cfg().uri << "; error: " << theOptions->error); return; } /* * Issue a warning if the ICAP server returned methods in the * options response that don't match the method from squid.conf. */ if (!theOptions->methods.empty()) { bool method_found = false; String method_list; - Vector ::iterator iter = theOptions->methods.begin(); + std::vector ::iterator iter = theOptions->methods.begin(); while (iter != theOptions->methods.end()) { if (*iter == cfg().method) { method_found = true; break; } method_list.append(ICAP::methodStr(*iter)); method_list.append(" ", 1); ++iter; } if (!method_found) { debugs(93, DBG_IMPORTANT, "WARNING: Squid is configured to use ICAP method " << cfg().methodStr() << " for service " << cfg().uri << " but OPTIONS response declares the methods are " << method_list); } } /* * Check the ICAP server's date header for clock skew */ const int skew = (int)(theOptions->timestamp() - squid_curtime); if (abs(skew) > theOptions->ttl()) { // TODO: If skew is negative, the option will be considered down // because of stale options. We should probably change this. debugs(93, DBG_IMPORTANT, "ICAP service's clock is skewed by " << skew << " seconds: " << cfg().uri); === modified file 'src/adaptation/icap/ServiceRep.h' --- src/adaptation/icap/ServiceRep.h 2014-01-11 01:35:50 +0000 +++ src/adaptation/icap/ServiceRep.h 2014-02-10 16:02:04 +0000 @@ -113,61 +113,61 @@ public: void noteConnectionFailed(const char *comment); void noteFailure(); // called by transactions to report service failure void noteNewWaiter() {theAllWaiters++;} ///< New xaction waiting for service to be up or available void noteGoneWaiter(); ///< An xaction is not waiting any more for service to be available bool existWaiters() const {return (theAllWaiters > 0);} ///< if there are xactions waiting for the service to be available //AsyncJob virtual methods virtual bool doneAll() const { return Adaptation::Initiator::doneAll() && false;} virtual void callException(const std::exception &e); virtual void detach(); virtual bool detached() const; public: // treat these as private, they are for callbacks only void noteTimeToUpdate(); void noteTimeToNotify(); // receive either an ICAP OPTIONS response header or an abort message virtual void noteAdaptationAnswer(const Answer &answer); private: // stores Prepare() callback info struct Client { Pointer service; // one for each client to preserve service AsyncCall::Pointer callback; }; - typedef Vector Clients; + typedef std::vector Clients; // TODO: rename to theUpWaiters Clients theClients; // all clients waiting for a call back Options *theOptions; CbcPointer theOptionsFetcher; // pending ICAP OPTIONS transaction time_t theLastUpdate; // time the options were last updated /// FIFO queue of xactions waiting for a connection slot and not yet notified /// about it; xaction is removed when notification is scheduled std::deque theNotificationWaiters; int theBusyConns; ///< number of connections given to active transactions /// number of xactions waiting for a connection slot (notified and not) /// the number is decreased after the xaction receives notification int theAllWaiters; int theMaxConnections; ///< the maximum allowed connections to the service // TODO: use a better type like the FadingCounter for connOverloadReported mutable bool connOverloadReported; ///< whether we reported exceeding theMaxConnections IdleConnList *theIdleConns; ///< idle persistent connection pool FadingCounter theSessionFailures; const char *isSuspended; // also stores suspension reason for debugging bool notifying; // may be true in any state except for the initial bool updateScheduled; // time-based options update has been scheduled private: ICAP::Method parseMethod(const char *) const; ICAP::VectPoint parseVectPoint(const char *) const; void suspend(const char *reason); === modified file 'src/auth/Config.h' --- src/auth/Config.h 2014-02-10 11:08:58 +0000 +++ src/auth/Config.h 2014-02-10 16:40:30 +0000 @@ -123,38 +123,38 @@ public: * Responsible for writing to the StoreEntry the configuration parameters that a user * would put in a config file to recreate the running configuration. */ virtual void dump(StoreEntry *, const char *, Config *); /** add headers as needed when challenging for auth */ virtual void fixHeader(UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *) = 0; /// Find any existing user credentials in the authentication cache by name and type. virtual Auth::User::Pointer findUserInCache(const char *nameKey, Auth::Type type); /** prepare to handle requests */ virtual void init(Config *) = 0; /** expose any/all statistics to a CacheManager */ virtual void registerWithCacheManager(void); /** parse config options */ virtual void parse(Config *, int, char *); /** the http string id */ virtual const char * type() const = 0; public: HelperChildConfig authenticateChildren; wordlist *authenticateProgram; ///< Helper program to run, includes all parameters String keyExtrasLine; ///< The format of the request to the auth helper Format::Format *keyExtras; ///< The compiled request format }; -typedef Vector ConfigVector; +typedef std::vector ConfigVector; extern ConfigVector TheConfig; } // namespace Auth #endif /* USE_AUTH */ #endif /* SQUID_AUTHCONFIG_H */ === modified file 'src/auth/Scheme.cc' --- src/auth/Scheme.cc 2013-10-25 00:13:46 +0000 +++ src/auth/Scheme.cc 2014-02-10 16:42:15 +0000 @@ -10,83 +10,83 @@ * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * Copyright (c) 2004, Robert Collins */ #include "squid.h" #include "auth/Config.h" #include "auth/Gadgets.h" #include "auth/Scheme.h" #include "globals.h" -Vector *Auth::Scheme::_Schemes = NULL; +std::vector *Auth::Scheme::_Schemes = NULL; void Auth::Scheme::AddScheme(Auth::Scheme::Pointer instance) { iterator i = GetSchemes().begin(); while (i != GetSchemes().end()) { assert(strcmp((*i)->type(), instance->type()) != 0); ++i; } GetSchemes().push_back(instance); } Auth::Scheme::Pointer Auth::Scheme::Find(const char *typestr) { for (iterator i = GetSchemes().begin(); i != GetSchemes().end(); ++i) { if (strcmp((*i)->type(), typestr) == 0) return *i; } return Auth::Scheme::Pointer(NULL); } -Vector & +std::vector & Auth::Scheme::GetSchemes() { if (!_Schemes) - _Schemes = new Vector; + _Schemes = new std::vector; return *_Schemes; } /** * Called when a graceful shutdown is to occur of each scheme module. * On completion the auth components are to be considered deleted. * None will be available globally. Some may remain around for their * currently active connections to close, but only those active * connections will retain pointers to them. */ void Auth::Scheme::FreeAll() { assert(shutting_down); while (GetSchemes().size()) { Auth::Scheme::Pointer scheme = GetSchemes().back(); GetSchemes().pop_back(); scheme->shutdownCleanup(); } } === modified file 'src/auth/Scheme.h' --- src/auth/Scheme.h 2013-10-25 00:13:46 +0000 +++ src/auth/Scheme.h 2014-02-10 16:43:24 +0000 @@ -7,102 +7,103 @@ * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_AUTH_SCHEME_H #define SQUID_AUTH_SCHEME_H #if USE_AUTH #include "base/RefCount.h" -#include "base/Vector.h" + +#include /** \defgroup AuthSchemeAPI Authentication Scheme API \ingroup AuthAPI */ namespace Auth { class Config; /** * \ingroup AuthAPI * \ingroup AuthSchemeAPI * \par * I represent an authentication scheme. For now my children * store the scheme metadata. * \par * Should we need multiple configs of a single scheme, * a new class should be made, and the config specific calls on Auth::Scheme moved to it. */ class Scheme : public RefCountable { public: typedef RefCount Pointer; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; public: Scheme() : initialised (false) {}; virtual ~Scheme() {}; static void AddScheme(Scheme::Pointer); /** * Final termination of all authentication components. * To be used only on shutdown. All global pointers are released. * After this all schemes will appear completely unsupported * until a call to InitAuthModules(). * Release the Auth::TheConfig handles instead to disable authentication * without terminiating all support. */ static void FreeAll(); /** * Locate an authentication scheme component by Name. */ static Scheme::Pointer Find(const char *); /* per scheme methods */ virtual char const *type() const = 0; virtual void shutdownCleanup() = 0; virtual Auth::Config *createConfig() = 0; // Not implemented Scheme(Scheme const &); Scheme &operator=(Scheme const&); - static Vector &GetSchemes(); + static std::vector &GetSchemes(); protected: bool initialised; private: - static Vector *_Schemes; + static std::vector *_Schemes; }; } // namespace Auth #endif /* USE_AUTH */ #endif /* SQUID_AUTH_SCHEME_H */ === modified file 'src/base/Vector.h' --- src/base/Vector.h 2014-02-07 15:37:11 +0000 +++ src/base/Vector.h 2014-02-10 17:40:20 +0000 @@ -5,61 +5,61 @@ * ---------------------------------------------------------- * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef SQUID_ARRAY_H #define SQUID_ARRAY_H /** - \todo CLEANUP: this file should be called Vector.h at least, and probably be replaced by STL Vector + \todo remove this after replacing with STL */ #include "fatal.h" #include "util.h" /* users of this template also need assert() */ #include "compat/assert.h" /* iterator support */ #include template class VectorIteratorBase { public: typedef typename C::value_type value_type; typedef std::forward_iterator_tag iterator_category; typedef typename C::pointer pointer; typedef typename C::reference reference; typedef typename C::difference_type difference_type; VectorIteratorBase(); VectorIteratorBase(C &); VectorIteratorBase(size_t, C &); VectorIteratorBase & operator =(VectorIteratorBase const &); bool operator != (VectorIteratorBase const &rhs) const; bool operator == (VectorIteratorBase const &rhs) const; VectorIteratorBase & operator ++(); VectorIteratorBase operator ++(int); typename C::value_type & operator *() const { === modified file 'src/cache_cf.cc' --- src/cache_cf.cc 2014-02-10 09:59:19 +0000 +++ src/cache_cf.cc 2014-02-10 15:51:55 +0000 @@ -223,61 +223,61 @@ static void free_denyinfo(AclDenyInfoLis #if USE_WCCPv2 static void parse_IpAddress_list(Ip::Address_list **); static void dump_IpAddress_list(StoreEntry *, const char *, const Ip::Address_list *); static void free_IpAddress_list(Ip::Address_list **); #if CURRENTLY_UNUSED static int check_null_IpAddress_list(const Ip::Address_list *); #endif /* CURRENTLY_UNUSED */ #endif /* USE_WCCPv2 */ static void parsePortCfg(AnyP::PortCfg **, const char *protocol); #define parse_PortCfg(l) parsePortCfg((l), token) static void dump_PortCfg(StoreEntry *, const char *, const AnyP::PortCfg *); static void free_PortCfg(AnyP::PortCfg **); #if USE_SSL static void parse_sslproxy_cert_sign(sslproxy_cert_sign **cert_sign); static void dump_sslproxy_cert_sign(StoreEntry *entry, const char *name, sslproxy_cert_sign *cert_sign); static void free_sslproxy_cert_sign(sslproxy_cert_sign **cert_sign); static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt **cert_adapt); static void dump_sslproxy_cert_adapt(StoreEntry *entry, const char *name, sslproxy_cert_adapt *cert_adapt); static void free_sslproxy_cert_adapt(sslproxy_cert_adapt **cert_adapt); static void parse_sslproxy_ssl_bump(acl_access **ssl_bump); static void dump_sslproxy_ssl_bump(StoreEntry *entry, const char *name, acl_access *ssl_bump); static void free_sslproxy_ssl_bump(acl_access **ssl_bump); #endif /* USE_SSL */ static void parse_b_size_t(size_t * var); static void parse_b_int64_t(int64_t * var); -static bool parseNamedIntList(const char *data, const String &name, Vector &list); +static bool parseNamedIntList(const char *data, const String &name, std::vector &list); static void parse_CpuAffinityMap(CpuAffinityMap **const cpuAffinityMap); static void dump_CpuAffinityMap(StoreEntry *const entry, const char *const name, const CpuAffinityMap *const cpuAffinityMap); static void free_CpuAffinityMap(CpuAffinityMap **const cpuAffinityMap); static int parseOneConfigFile(const char *file_name, unsigned int depth); static void parse_configuration_includes_quoted_values(bool *recognizeQuotedValues); static void dump_configuration_includes_quoted_values(StoreEntry *const entry, const char *const name, bool recognizeQuotedValues); static void free_configuration_includes_quoted_values(bool *recognizeQuotedValues); /* * LegacyParser is a parser for legacy code that uses the global * approach. This is static so that it is only exposed to cache_cf. * Other modules needing access to a ConfigParser should have it * provided to them in their parserFOO methods. */ static ConfigParser LegacyParser = ConfigParser(); void self_destruct(void) { LegacyParser.destruct(); } static void update_maxobjsize(void) { int64_t ms = -1; @@ -463,61 +463,61 @@ parseOneConfigFile(const char *file_name int tmp_line_len = 0; int err_count = 0; int is_pipe = 0; debugs(3, DBG_IMPORTANT, "Processing Configuration File: " << file_name << " (depth " << depth << ")"); if (depth > 16) { fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name); return 1; } if (file_name[0] == '!' || file_name[0] == '|') { fp = popen(file_name + 1, "r"); is_pipe = 1; } else { fp = fopen(file_name, "r"); } if (fp == NULL) fatalf("Unable to open configuration file: %s: %s", file_name, xstrerror()); #if _SQUID_WINDOWS_ setmode(fileno(fp), O_TEXT); #endif SetConfigFilename(file_name, bool(is_pipe)); memset(config_input_line, '\0', BUFSIZ); config_lineno = 0; - Vector if_states; + std::vector if_states; while (fgets(config_input_line, BUFSIZ, fp)) { ++config_lineno; if ((token = strchr(config_input_line, '\n'))) *token = '\0'; if ((token = strchr(config_input_line, '\r'))) *token = '\0'; // strip any prefix whitespace off the line. const char *p = skip_ws(config_input_line); if (config_input_line != p) memmove(config_input_line, p, strlen(p)+1); if (strncmp(config_input_line, "#line ", 6) == 0) { static char new_file_name[1024]; static char *file; static char new_lineno; token = config_input_line + 6; new_lineno = strtol(token, &file, 0) - 1; if (file == token) continue; /* Not a valid #line directive, may be a comment */ while (*file && xisspace((unsigned char) *file)) ++file; if (*file) { if (*file != '"') continue; /* Not a valid #line directive, may be a comment */ @@ -4234,94 +4234,94 @@ dump_access_log(StoreEntry * entry, cons } if (log->aclList) dump_acl_list(entry, log->aclList); storeAppendPrintf(entry, "\n"); } } static void free_access_log(CustomLog ** definitions) { while (*definitions) { CustomLog *log = *definitions; *definitions = log->next; log->logFormat = NULL; log->type = Log::Format::CLF_UNKNOWN; if (log->aclList) aclDestroyAclList(&log->aclList); safe_free(log->filename); xfree(log); } } /// parses list of integers form name=N1,N2,N3,... static bool -parseNamedIntList(const char *data, const String &name, Vector &list) +parseNamedIntList(const char *data, const String &name, std::vector &list) { if (data && (strncmp(data, name.rawBuf(), name.size()) == 0)) { data += name.size(); if (*data == '=') { while (true) { ++data; int value = 0; if (!StringToInt(data, value, &data, 10)) break; list.push_back(value); if (*data == '\0' || *data != ',') break; } } } return data && *data == '\0'; } static void parse_CpuAffinityMap(CpuAffinityMap **const cpuAffinityMap) { #if !HAVE_CPU_AFFINITY debugs(3, DBG_CRITICAL, "FATAL: Squid built with no CPU affinity " << "support, do not set 'cpu_affinity_map'"); self_destruct(); #endif /* HAVE_CPU_AFFINITY */ if (!*cpuAffinityMap) *cpuAffinityMap = new CpuAffinityMap; const char *const pToken = ConfigParser::NextToken(); const char *const cToken = ConfigParser::NextToken(); - Vector processes, cores; + std::vector processes, cores; if (!parseNamedIntList(pToken, "process_numbers", processes)) { debugs(3, DBG_CRITICAL, "FATAL: bad 'process_numbers' parameter " << "in 'cpu_affinity_map'"); self_destruct(); } else if (!parseNamedIntList(cToken, "cores", cores)) { debugs(3, DBG_CRITICAL, "FATAL: bad 'cores' parameter in " << "'cpu_affinity_map'"); self_destruct(); } else if (!(*cpuAffinityMap)->add(processes, cores)) { debugs(3, DBG_CRITICAL, "FATAL: bad 'cpu_affinity_map'; " << "process_numbers and cores lists differ in length or " << "contain numbers <= 0"); self_destruct(); } } static void dump_CpuAffinityMap(StoreEntry *const entry, const char *const name, const CpuAffinityMap *const cpuAffinityMap) { if (cpuAffinityMap) { storeAppendPrintf(entry, "%s process_numbers=", name); for (size_t i = 0; i < cpuAffinityMap->processes().size(); ++i) { storeAppendPrintf(entry, "%s%i", (i ? "," : ""), cpuAffinityMap->processes()[i]); } storeAppendPrintf(entry, " cores="); for (size_t i = 0; i < cpuAffinityMap->cores().size(); ++i) { storeAppendPrintf(entry, "%s%i", (i ? "," : ""), cpuAffinityMap->cores()[i]); } === modified file 'src/client_side.cc' --- src/client_side.cc 2014-02-10 09:59:19 +0000 +++ src/client_side.cc 2014-02-10 13:16:04 +0000 @@ -1686,61 +1686,61 @@ ClientSocketContext::keepaliveNextReques } } void clientUpdateSocketStats(LogTags logType, size_t size) { if (size == 0) return; kb_incr(&statCounter.client_http.kbytes_out, size); if (logTypeIsATcpHit(logType)) kb_incr(&statCounter.client_http.hit_kbytes_out, size); } /** * increments iterator "i" * used by clientPackMoreRanges * \retval true there is still data available to pack more ranges \retval false */ bool ClientSocketContext::canPackMoreRanges() const { /** first update iterator "i" if needed */ if (!http->range_iter.debt()) { debugs(33, 5, HERE << "At end of current range spec for " << clientConnection); - if (http->range_iter.pos.incrementable()) + if (http->range_iter.pos != http->range_iter.end) ++http->range_iter.pos; http->range_iter.updateSpec(); } assert(!http->range_iter.debt() == !http->range_iter.currentSpec()); /* paranoid sync condition */ /* continue condition: need_more_data */ debugs(33, 5, "ClientSocketContext::canPackMoreRanges: returning " << (http->range_iter.currentSpec() ? true : false)); return http->range_iter.currentSpec() ? true : false; } int64_t ClientSocketContext::getNextRangeOffset() const { if (http->request->range) { /* offset in range specs does not count the prefix of an http msg */ debugs (33, 5, "ClientSocketContext::getNextRangeOffset: http offset " << http->out.offset); /* check: reply was parsed and range iterator was initialized */ assert(http->range_iter.valid); /* filter out data according to range specs */ assert (canPackMoreRanges()); { int64_t start; /* offset of still missing data */ assert(http->range_iter.currentSpec()); start = http->range_iter.currentSpec()->offset + http->range_iter.currentSpec()->length - http->range_iter.debt(); debugs(33, 3, "clientPackMoreRanges: in: offset: " << http->out.offset); debugs(33, 3, "clientPackMoreRanges: out:" " start: " << start << === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2013-12-06 23:52:26 +0000 +++ src/client_side_request.cc 2014-02-10 13:16:04 +0000 @@ -1112,60 +1112,61 @@ clientInterpretRequestHeaders(ClientHttp #if USE_HTTP_VIOLATIONS if (Config.onoff.reload_into_ims) request->flags.nocacheHack = true; else if (refresh_nocache_hack) request->flags.nocacheHack = true; else #endif request->flags.noCache = true; } /* ignore range header in non-GETs or non-HEADs */ if (request->method == Http::METHOD_GET || request->method == Http::METHOD_HEAD) { // XXX: initialize if we got here without HttpRequest::parseHeader() if (!request->range) request->range = req_hdr->getRange(); if (request->range) { request->flags.isRanged = true; clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->data; /* XXX: This is suboptimal. We should give the stream the range set, * and thereby let the top of the stream set the offset when the * size becomes known. As it is, we will end up requesting from 0 * for evey -X range specification. * RBC - this may be somewhat wrong. We should probably set the range * iter up at this point. */ node->readBuffer.offset = request->range->lowestOffset(0); http->range_iter.pos = request->range->begin(); + http->range_iter.end = request->range->end(); http->range_iter.valid = true; } } /* Only HEAD and GET requests permit a Range or Request-Range header. * If these headers appear on any other type of request, delete them now. */ else { req_hdr->delById(HDR_RANGE); req_hdr->delById(HDR_REQUEST_RANGE); delete request->range; request->range = NULL; } if (req_hdr->has(HDR_AUTHORIZATION)) request->flags.auth = true; clientCheckPinning(http); if (request->login[0] != '\0') request->flags.auth = true; if (req_hdr->has(HDR_VIA)) { String s = req_hdr->getList(HDR_VIA); /* * ThisCache cannot be a member of Via header, "1.1 ThisCache" can. * Note ThisCache2 has a space prepended to the hostname so we don't * accidentally match super-domains. */ === modified file 'src/comm/AcceptLimiter.cc' --- src/comm/AcceptLimiter.cc 2013-03-26 10:38:20 +0000 +++ src/comm/AcceptLimiter.cc 2014-02-10 16:51:58 +0000 @@ -20,39 +20,40 @@ Comm::AcceptLimiter::defer(const Comm::T debugs(5, 5, afd->conn << " x" << afd->isLimited); deferred_.push_back(afd); } void Comm::AcceptLimiter::removeDead(const Comm::TcpAcceptor::Pointer &afd) { uint64_t abandonedClients = 0; for (unsigned int i = 0; i < deferred_.size() && afd->isLimited > 0; ++i) { if (deferred_[i] == afd) { -- deferred_[i]->isLimited; deferred_[i] = NULL; // fast. kick() will skip empty entries later. debugs(5, 5, afd->conn << " x" << afd->isLimited); ++abandonedClients; } } debugs(5,4, "Abandoned " << abandonedClients << " client TCP SYN by closing socket: " << afd->conn); } void Comm::AcceptLimiter::kick() { // TODO: this could be optimized further with an iterator to search // looking for first non-NULL, followed by dumping the first N // with only one shift()/pop_front operation // OR, by reimplementing as a list instead of Vector. debugs(5, 5, "size=" << deferred_.size()); while (deferred_.size() > 0 && fdNFree() >= RESERVED_FD) { /* NP: shift() is equivalent to pop_front(). Giving us a FIFO queue. */ - TcpAcceptor::Pointer temp = deferred_.shift(); + TcpAcceptor::Pointer temp = deferred_.front(); + deferred_.erase(deferred_.begin()); if (temp.valid()) { debugs(5, 5, "doing one."); -- temp->isLimited; temp->acceptNext(); break; } } } === modified file 'src/comm/AcceptLimiter.h' --- src/comm/AcceptLimiter.h 2013-05-04 11:50:26 +0000 +++ src/comm/AcceptLimiter.h 2014-02-10 16:50:44 +0000 @@ -1,55 +1,56 @@ #ifndef _SQUID_SRC_COMM_ACCEPT_LIMITER_H #define _SQUID_SRC_COMM_ACCEPT_LIMITER_H -#include "base/Vector.h" #include "comm/TcpAcceptor.h" +#include + namespace Comm { /** * FIFO Queue holding listener socket handlers which have been activated * ready to dupe their FD and accept() a new client connection. * But when doing so there were not enough FD available to handle the * new connection. These handlers are awaiting some FD to become free. * * defer - used only by Comm layer ConnAcceptor adding themselves when FD are limited. * removeDead - used only by Comm layer ConnAcceptor to remove themselves when dying. * kick - used by Comm layer when FD are closed. */ /* TODO this algorithm can be optimized further: * * 1) reduce overheads by only pushing one entry per port to the list? * use TcpAcceptor::isLimited as a flag whether to re-list when kick()'ing * or to NULL an entry while scanning the list for empty spaces. * Side effect: TcpAcceptor->kick() becomes allowed to pull off multiple accept()'s in bunches * - * 2) re-implement as a list instead of vector? + * 2) re-implement as a std::queue instead of std::vector * storing head/tail pointers for fast push/pop and avoiding the whole shift() overhead */ class AcceptLimiter { public: /** retrieve the global instance of the queue. */ static AcceptLimiter &Instance(); /** delay accepting a new client connection. */ void defer(const TcpAcceptor::Pointer &afd); /** remove all records of an acceptor. Only to be called by the ConnAcceptor::swanSong() */ void removeDead(const TcpAcceptor::Pointer &afd); /** try to accept and begin processing any delayed client connections. */ void kick(); private: static AcceptLimiter Instance_; /** FIFO queue */ - Vector deferred_; + std::vector deferred_; }; }; // namepace Comm #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */ === modified file 'src/comm/forward.h' --- src/comm/forward.h 2013-10-25 00:13:46 +0000 +++ src/comm/forward.h 2014-02-10 17:09:55 +0000 @@ -1,20 +1,21 @@ #ifndef _SQUID_COMM_FORWARD_H #define _SQUID_COMM_FORWARD_H #include "base/RefCount.h" -#include "base/Vector.h" + +#include namespace Comm { class Connection; typedef RefCount ConnectionPointer; -typedef Vector ConnectionList; +typedef std::vector ConnectionList; bool IsConnOpen(const Comm::ConnectionPointer &conn); }; // namespace Comm #endif /* _SQUID_COMM_FORWARD_H */ === modified file 'src/delay_pools.cc' --- src/delay_pools.cc 2013-10-25 00:13:46 +0000 +++ src/delay_pools.cc 2014-02-10 15:37:37 +0000 @@ -15,61 +15,60 @@ * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * * Copyright (c) 2003, Robert Collins */ /** \defgroup DelayPoolsInternal Delay Pools Internal \ingroup DelayPoolsAPI */ #include "squid.h" #if USE_DELAY_POOLS -#include "base/Vector.h" #include "client_side_request.h" #include "comm/Connection.h" #include "CommonPool.h" #include "CompositePoolNode.h" #include "ConfigParser.h" #include "DelayBucket.h" #include "DelayId.h" #include "DelayPool.h" #include "DelayPools.h" #include "DelaySpec.h" #include "DelayTagged.h" #include "DelayUser.h" #include "DelayVector.h" #include "event.h" #include "ip/Address.h" #include "MemObject.h" #include "mgr/Registration.h" #include "NullDelayId.h" #include "SquidString.h" #include "SquidTime.h" #include "Store.h" #include "StoreClient.h" /// \ingroup DelayPoolsInternal long DelayPools::MemoryUsed = 0; /// \ingroup DelayPoolsInternal class Aggregate : public CompositePoolNode { @@ -565,100 +564,100 @@ DelayPools::InitDelayData() DelayPools::MemoryUsed += pools() * sizeof(DelayPool); eventAdd("DelayPools::Update", DelayPools::Update, NULL, 1.0, 1); } void DelayPools::FreeDelayData() { eventDelete(DelayPools::Update, NULL); delete[] DelayPools::delay_data; DelayPools::MemoryUsed -= pools() * sizeof(*DelayPools::delay_data); pools_ = 0; } void DelayPools::Update(void *unused) { if (!pools()) return; eventAdd("DelayPools::Update", Update, NULL, 1.0, 1); int incr = squid_curtime - LastUpdate; if (incr < 1) return; LastUpdate = squid_curtime; - Vector::iterator pos = toUpdate.begin(); + std::vector::iterator pos = toUpdate.begin(); while (pos != toUpdate.end()) { (*pos)->update(incr); ++pos; } } void DelayPools::registerForUpdates(Updateable *anObject) { /* Assume no doubles */ toUpdate.push_back(anObject); } void DelayPools::deregisterForUpdates (Updateable *anObject) { - Vector::iterator pos = toUpdate.begin(); + std::vector::iterator pos = toUpdate.begin(); while (pos != toUpdate.end() && *pos != anObject) { ++pos; } if (pos != toUpdate.end()) { /* move all objects down one */ - Vector::iterator temp = pos; + std::vector::iterator temp = pos; ++pos; while (pos != toUpdate.end()) { *temp = *pos; ++temp; ++pos; } toUpdate.pop_back(); } } -Vector DelayPools::toUpdate; +std::vector DelayPools::toUpdate; void DelayPools::Stats(StoreEntry * sentry) { unsigned short i; storeAppendPrintf(sentry, "Delay pools configured: %d\n\n", DelayPools::pools()); for (i = 0; i < DelayPools::pools(); ++i) { if (DelayPools::delay_data[i].theComposite().getRaw()) { storeAppendPrintf(sentry, "Pool: %d\n\tClass: %s\n\n", i + 1, DelayPools::delay_data[i].pool->theClassTypeLabel()); DelayPools::delay_data[i].theComposite()->stats (sentry); } else storeAppendPrintf(sentry, "\tMisconfigured pool.\n\n"); } storeAppendPrintf(sentry, "Memory Used: %d bytes\n", (int) DelayPools::MemoryUsed); } void DelayPools::FreePools() { if (!DelayPools::pools()) return; FreeDelayData(); } unsigned short DelayPools::pools() === modified file 'src/errorpage.cc' --- src/errorpage.cc 2014-02-07 16:14:42 +0000 +++ src/errorpage.cc 2014-02-10 15:33:31 +0000 @@ -92,61 +92,61 @@ typedef struct { /** \ingroup ErrorPageInternal * \note hard coded error messages are not appended with %S * automagically to give you more control on the format */ static const struct { int type; /* and page_id */ const char *text; } error_hard_text[] = { { ERR_SQUID_SIGNATURE, "\n
\n" "
\n" "
\n" "Generated %T by %h (%s)\n" "
\n" "\n" }, { TCP_RESET, "reset" } }; /// \ingroup ErrorPageInternal -static Vector ErrorDynamicPages; +static std::vector ErrorDynamicPages; /* local prototypes */ /// \ingroup ErrorPageInternal static const int error_hard_text_count = sizeof(error_hard_text) / sizeof(*error_hard_text); /// \ingroup ErrorPageInternal static char **error_text = NULL; /// \ingroup ErrorPageInternal static int error_page_count = 0; /// \ingroup ErrorPageInternal static MemBuf error_stylesheet; static const char *errorFindHardText(err_type type); static ErrorDynamicPageInfo *errorDynamicPageInfoCreate(int id, const char *page_name); static void errorDynamicPageInfoDestroy(ErrorDynamicPageInfo * info); static IOCB errorSendComplete; /// \ingroup ErrorPageInternal /// manages an error page template class ErrorPageFile: public TemplateFile { public: ErrorPageFile(const char *name, const err_type code): TemplateFile(name,code) { textBuf.init();} /// The template text data read from disk const char *text() { return textBuf.content(); } === modified file 'src/esi/CustomParser.cc' --- src/esi/CustomParser.cc 2014-02-10 09:19:56 +0000 +++ src/esi/CustomParser.cc 2014-02-10 16:26:30 +0000 @@ -5,66 +5,68 @@ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * * Squid is the result of efforts by numerous individuals from * the Internet community; see the CONTRIBUTORS file for full * details. Many organizations have provided support for Squid's * development; see the SPONSORS file for full details. Squid is * Copyrighted (C) 2001 by the Regents of the University of * California; see the COPYRIGHT file for full details. Squid * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #include "squid.h" -#include "base/Vector.h" #include "Debug.h" #include "esi/CustomParser.h" +#include "fatal.h" #include "libTrie/Trie.h" #include "libTrie/TrieCharTransform.h" +#include + Trie *ESICustomParser::SearchTrie=NULL; EsiParserDefinition(ESICustomParser); Trie * ESICustomParser::GetTrie() { if (SearchTrie) return SearchTrie; SearchTrie = new Trie(new TrieCaseless); static const ESITAG_t ESITAG_value = ESITAG; assert (SearchTrie->add ("add ("add ("