=== modified file 'src/DiskIO/IpcIo/IpcIoFile.cc' --- src/DiskIO/IpcIo/IpcIoFile.cc 2013-10-25 00:13:46 +0000 +++ src/DiskIO/IpcIo/IpcIoFile.cc 2013-11-05 11:13:14 +0000 @@ -78,72 +78,72 @@ Must(i != IpcIoFiles.end()); Must(i->second == this); IpcIoFiles.erase(i); } } void IpcIoFile::configure(const Config &cfg) { DiskFile::configure(cfg); config = cfg; } void IpcIoFile::open(int flags, mode_t mode, RefCount callback) { ioRequestor = callback; Must(diskId < 0); // we do not know our disker yet if (!queue.get()) - queue.reset(new Queue(ShmLabel, IamWorkerProcess() ? Queue::groupA : Queue::groupB, KidIdentifier)); + queue.reset(new Queue(String(ShmLabel), IamWorkerProcess() ? Queue::groupA : Queue::groupB, KidIdentifier)); if (IamDiskProcess()) { error_ = !DiskerOpen(dbName, flags, mode); if (error_) return; diskId = KidIdentifier; const bool inserted = IpcIoFiles.insert(std::make_pair(diskId, this)).second; Must(inserted); queue->localRateLimit() = static_cast(config.ioRate); Ipc::HereIamMessage ann(Ipc::StrandCoord(KidIdentifier, getpid())); ann.strand.tag = dbName; Ipc::TypedMsgHdr message; ann.pack(message); - SendMessage(Ipc::coordinatorAddr, message); + SendMessage(String(Ipc::coordinatorAddr), message); ioRequestor->ioCompletedNotification(); return; } Ipc::StrandSearchRequest request; request.requestorId = KidIdentifier; request.tag = dbName; Ipc::TypedMsgHdr msg; request.pack(msg); - Ipc::SendMessage(Ipc::coordinatorAddr, msg); + Ipc::SendMessage(String(Ipc::coordinatorAddr), msg); WaitingForOpen.push_back(this); eventAdd("IpcIoFile::OpenTimeout", &IpcIoFile::OpenTimeout, this, Timeout, 0, false); // "this" pointer is used as id } void IpcIoFile::openCompleted(const Ipc::StrandSearchResponse *const response) { Must(diskId < 0); // we do not know our disker yet if (!response) { debugs(79, DBG_IMPORTANT, HERE << "error: timeout"); error_ = true; } else { diskId = response->strand.kidId; if (diskId >= 0) { const bool inserted = IpcIoFiles.insert(std::make_pair(diskId, this)).second; @@ -886,30 +886,30 @@ public: /* RegisteredRunner API */ IpcIoRr(): owner(NULL) {} virtual ~IpcIoRr(); protected: virtual void create(const RunnerRegistry &); private: Ipc::FewToFewBiQueue::Owner *owner; }; RunnerRegistrationEntry(rrAfterConfig, IpcIoRr); void IpcIoRr::create(const RunnerRegistry &) { if (Config.cacheSwap.n_strands <= 0) return; Must(!owner); - owner = Ipc::FewToFewBiQueue::Init(ShmLabel, Config.workers, 1, + owner = Ipc::FewToFewBiQueue::Init(String(ShmLabel), Config.workers, 1, Config.cacheSwap.n_strands, 1 + Config.workers, sizeof(IpcIoMsg), QueueCapacity); } IpcIoRr::~IpcIoRr() { delete owner; } === modified file 'src/LoadableModules.cc' --- src/LoadableModules.cc 2012-08-14 11:53:07 +0000 +++ src/LoadableModules.cc 2013-11-05 11:13:14 +0000 @@ -1,26 +1,27 @@ #include "squid.h" #include "Debug.h" #include "LoadableModule.h" #include "LoadableModules.h" #include "wordlist.h" static void LoadModule(const char *fname) { - debugs(1, DBG_IMPORTANT, "Loading Squid module from '" << fname << "'"); + String theName(fname); + debugs(1, DBG_IMPORTANT, "Loading Squid module from '" << theName << "'"); - LoadableModule *m = new LoadableModule(fname); + LoadableModule *m = new LoadableModule(theName); m->load(); - debugs(1, 2, "Loaded Squid module from '" << fname << "'"); + debugs(1, 2, "Loaded Squid module from '" << theName << "'"); //TODO: TheModules.push_back(m); } void LoadableModulesConfigure(const wordlist *names) { int count = 0; for (const wordlist *i = names; i; i = i->next, ++count) LoadModule(i->key); debugs(1, DBG_IMPORTANT, "Squid plugin modules loaded: " << count); } === modified file 'src/Makefile.am' --- src/Makefile.am 2013-11-15 16:56:59 +0000 +++ src/Makefile.am 2013-11-05 11:13:14 +0000 @@ -5,41 +5,44 @@ # include $(top_srcdir)/src/Common.am AUTOMAKE_OPTIONS = subdir-objects DNSSOURCE = \ dns_internal.cc \ SquidDns.h \ DnsLookupDetails.h \ DnsLookupDetails.cc SBUF_SOURCE= \ base/InstanceId.h \ MemBlob.h \ MemBlob.cc \ OutOfBoundsException.h \ SBuf.h \ SBuf.cc \ SBufExceptions.h \ - SBufExceptions.cc + SBufExceptions.cc \ + SquidString.h \ + String.cc \ + String.cci STOREMETA_SOURCE = \ StoreMeta.cc \ StoreMeta.h \ StoreMetaMD5.cc \ StoreMetaMD5.h \ StoreMetaSTD.cc \ StoreMetaSTD.h \ StoreMetaSTDLFS.cc \ StoreMetaSTDLFS.h \ StoreMetaObjSize.h \ StoreMetaURL.cc \ StoreMetaURL.h \ StoreMetaVary.cc \ StoreMetaVary.h LOADABLE_MODULES_SOURCES = \ LoadableModule.h \ LoadableModule.cc \ LoadableModules.h \ @@ -477,41 +480,40 @@ refresh.h \ refresh.cc \ RemovalPolicy.cc \ RemovalPolicy.h \ send-announce.h \ send-announce.cc \ $(SBUF_SOURCE) \ SBufStatsAction.h \ SBufStatsAction.cc \ $(SNMP_SOURCE) \ SquidMath.h \ SquidMath.cc \ SquidNew.cc \ IoStats.h \ stat.h \ stat.cc \ StatCounters.h \ StatCounters.cc \ StatHist.h \ StatHist.cc \ - String.cc \ StrList.h \ StrList.cc \ stmem.cc \ stmem.h \ repl_modules.h \ store.cc \ Store.h \ StoreFileSystem.cc \ StoreFileSystem.h \ StoreHashIndex.h \ store_io.cc \ StoreIOBuffer.h \ StoreIOState.cc \ StoreIOState.h \ store_client.cc \ StoreClient.h \ store_digest.h \ store_digest.cc \ store_dir.cc \ store_key_md5.h \ @@ -569,42 +571,40 @@ ConfigOption.h \ $(DELAY_POOL_ALL_SOURCE) \ htcp.cc \ htcp.h \ ipc.cc \ ipc_win32.cc \ ProfStats.cc \ LeakFinder.cc \ LeakFinder.h \ $(SNMP_ALL_SOURCE) \ $(UNLINKDSOURCE) \ $(WIN32_ALL_SOURCE) \ $(LOADABLE_MODULES_SOURCES) noinst_HEADERS = \ client_side_request.cci \ MemBuf.cci \ MemBuf.h \ Store.cci \ StoreEntryStream.h \ - String.cci \ - SquidString.h \ SquidTime.h BUILT_SOURCES = \ cf_gen_defines.cci \ cf_parser.cci \ err_type.cc \ err_detail_type.cc \ globals.cc \ hier_code.cc \ icp_opcode.cc \ LogTags.cc \ lookup_t.cc \ repl_modules.cc \ swap_log_op.cc CLEANFILES += $(BUILT_SOURCES) nodist_squid_SOURCES = \ $(DISKIO_GEN_SOURCE) \ $(BUILT_SOURCES) @@ -708,45 +708,45 @@ ## snmp_core wants ACLStringData ## SwapDir wants ConfigOption ## tools.cc wants ip/libip.la ## client_side.cc wants ip/libip.la ## mem.cc wants ClientInfo.h ## libbase.la wants cbdata.* ## libbase.la wants MemBuf.* ufsdump_SOURCES = \ ClientInfo.h \ cbdata.h \ cbdata.cc \ debug.cc \ int.h \ int.cc \ Mem.h \ mem.cc \ MemBuf.cc \ MemBuf.cci \ MemBuf.h \ Parsing.h \ + $(SBUF_SOURCE) \ store_key_md5.h \ store_key_md5.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ - String.cc \ SquidNew.cc \ tests/stub_time.cc \ ufsdump.cc \ dlink.h \ dlink.cc \ HelperChildConfig.h \ tests/stub_HelperChildConfig.cc \ HttpRequestMethod.cc \ RemovalPolicy.cc \ $(WIN32_SOURCE) \ fd.h \ tests/stub_fd.cc ufsdump_LDADD = \ ident/libident.la \ acl/libacls.la \ eui/libeui.la \ acl/libstate.la \ acl/libapi.la \ base/libbase.la \ libsquid.la \ @@ -1135,43 +1135,42 @@ HttpHeaderFieldInfo.h \ HttpHeaderTools.h \ HttpHeaderTools.cc \ HttpControlMsg.h \ HttpMsg.cc \ HttpMsg.h \ HttpReply.cc \ HttpReply.h \ Mem.h \ tests/stub_mem.cc \ RegexList.h \ RegexList.cc \ MemBuf.cc \ MemBuf.h \ mime_header.h \ mime_header.cc \ Notes.h \ Notes.cc \ Packer.cc \ Packer.h \ - SquidString.h \ + $(SBUF_SOURCE) \ SquidTime.h \ - String.cc \ StrList.h \ StrList.cc \ log/access_log.h \ tests/stub_access_log.cc \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_debug.cc \ tests/stub_errorpage.cc \ tests/stub_HelperChildConfig.cc \ tests/stub_libformat.cc \ tests/stub_libauth.cc \ StatCounters.h \ StatCounters.cc \ StatHist.h \ tests/stub_StatHist.cc \ repl_modules.h \ tests/stub_store.cc \ tests/stub_store_stats.cc \ @@ -1233,49 +1232,49 @@ HttpHdrRange.cc \ HttpHeaderFieldStat.h \ HttpHdrCc.h \ HttpHdrCc.cc \ HttpHdrCc.cci \ HttpHdrSc.cc \ HttpHdrScTarget.cc \ HttpMsg.cc \ HttpRequestMethod.cc \ int.h \ int.cc \ MasterXaction.cc \ MasterXaction.h \ Notes.cc \ Notes.h \ SquidList.h \ SquidList.cc \ mem_node.cc \ Packer.cc \ Parsing.cc \ + $(SBUF_SOURCE) \ SquidMath.cc \ StatCounters.cc \ StatCounters.h \ StatHist.h \ StrList.h \ StrList.cc \ tests/stub_StatHist.cc \ stmem.cc \ - String.cc \ store_dir.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ store_key_md5.h \ store_key_md5.cc \ swap_log_op.cc \ swap_log_op.h \ tests/stub_SwapDir.cc \ SwapDir.h \ log/access_log.h \ tests/stub_access_log.cc \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_client_side.cc \ tests/stub_debug.cc \ tests/stub_DelayId.cc \ tests/stub_DiskIOModule.cc \ @@ -1360,41 +1359,40 @@ $(SQUID_CPPUNIT_LIBS) \ $(SSLLIB) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testBoilerplate_LDFLAGS = $(LIBADD_DL) tests_testBoilerplate_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) ## Tests of the CacheManager module. tests_testCacheManager_SOURCES = \ AccessLogEntry.cc \ debug.cc \ HttpParser.cc \ HttpParser.h \ RequestFlags.h \ RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ Mem.h \ tests/stub_mem.cc \ - String.cc \ tests/testCacheManager.cc \ tests/testCacheManager.h \ tests/testMain.cc \ tests/stub_main_cc.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_store_stats.cc \ time.cc \ BodyPipe.cc \ cache_manager.cc \ cache_cf.h \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ cache_cf.cc \ CacheDigest.h \ tests/stub_CacheDigest.cc \ carp.h \ tests/stub_carp.cc \ cbdata.cc \ @@ -1652,59 +1650,59 @@ int.h \ int.cc \ SquidList.h \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ MemBuf.cc \ MemObject.cc \ mem_node.cc \ Mem.h \ tests/stub_mem.cc \ Notes.h \ Notes.cc \ Packer.cc \ Parsing.cc \ refresh.h \ refresh.cc \ RemovalPolicy.cc \ RequestFlags.h \ RequestFlags.cc \ + $(SBUF_SOURCE) \ StatCounters.h \ StatCounters.cc \ StatHist.h \ tests/stub_StatHist.cc \ stmem.cc \ StoreFileSystem.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ store_dir.cc \ store_io.cc \ store_key_md5.h \ store_key_md5.cc \ store_swapout.cc \ store_swapmeta.cc \ repl_modules.h \ store.cc \ - String.cc \ StrList.h \ StrList.cc \ tests/stub_SwapDir.cc \ log/access_log.h \ tests/stub_access_log.cc \ tests/stub_acl.cc \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_client_db.cc \ client_side_request.h \ tests/stub_client_side_request.cc \ tests/stub_debug.cc \ tests/stub_errorpage.cc \ tests/stub_helper.cc \ tests/stub_HelperChildConfig.cc \ tests/stub_HttpRequest.cc \ tests/stub_http.cc \ tests/stub_icp.cc \ @@ -1940,41 +1938,40 @@ store_client.cc \ store_digest.h \ tests/stub_store_digest.cc \ store_dir.cc \ store_io.cc \ store_key_md5.h \ store_key_md5.cc \ store_log.h \ store_log.cc \ store_rebuild.h \ store_rebuild.cc \ store_swapin.h \ store_swapin.cc \ store_swapmeta.cc \ store_swapout.cc \ StoreFileSystem.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ - String.cc \ tests/stub_SwapDir.cc \ tests/CapturingStoreEntry.h \ tests/testEvent.cc \ tests/testEvent.h \ tests/testMain.cc \ tests/stub_main_cc.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_libauth_acls.cc \ tests/stub_libauth.cc \ tests/stub_libeui.cc \ tests/stub_store_stats.cc \ time.cc \ tools.h \ tools.cc \ tests/stub_tunnel.cc \ MemStore.cc \ $(UNLINKDSOURCE) \ url.cc \ URLScheme.cc \ urn.h \ @@ -2183,41 +2180,40 @@ store_client.cc \ store_digest.h \ tests/stub_store_digest.cc \ store_dir.cc \ store_io.cc \ store_key_md5.h \ store_key_md5.cc \ store_log.h \ store_log.cc \ store_rebuild.h \ store_rebuild.cc \ store_swapin.h \ store_swapin.cc \ store_swapmeta.cc \ store_swapout.cc \ StoreFileSystem.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ - String.cc \ StrList.h \ StrList.cc \ tests/stub_SwapDir.cc \ tests/testEventLoop.cc \ tests/testEventLoop.h \ tests/testMain.cc \ tests/stub_main_cc.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_libauth_acls.cc \ tests/stub_libauth.cc \ tests/stub_libeui.cc \ tests/stub_store_stats.cc \ time.cc \ tools.h \ tools.cc \ tests/stub_tunnel.cc \ MemStore.cc \ $(UNLINKDSOURCE) \ url.cc \ URLScheme.cc \ @@ -2422,41 +2418,40 @@ store_client.cc \ store_digest.h \ tests/stub_store_digest.cc \ store_dir.cc \ store_key_md5.h \ store_key_md5.cc \ store_io.cc \ store_log.h \ store_log.cc \ store_rebuild.h \ store_rebuild.cc \ store_swapin.h \ store_swapin.cc \ store_swapmeta.cc \ store_swapout.cc \ StoreFileSystem.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ - String.cc \ StrList.h \ StrList.cc \ tests/stub_SwapDir.cc \ tests/test_http_range.cc \ tests/stub_external_acl.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_libeui.cc \ tests/stub_main_cc.cc \ tests/stub_MemStore.cc \ tests/stub_store_stats.cc \ time.cc \ tools.h \ tools.cc \ tests/stub_tunnel.cc \ $(UNLINKDSOURCE) \ url.cc \ URLScheme.cc \ urn.h \ urn.cc \ wccp2.h \ @@ -2498,41 +2493,41 @@ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_test_http_range_LDFLAGS = $(LIBADD_DL) tests_test_http_range_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) tests_testHttpParser_SOURCES = \ Debug.h \ HttpParser.cc \ HttpParser.h \ MemBuf.cc \ MemBuf.h \ Mem.h \ tests/stub_mem.cc \ - String.cc \ + $(SBUF_SOURCE) \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_debug.cc \ tests/stub_event.cc \ tests/stub_HelperChildConfig.cc \ tools.h \ tests/stub_tools.cc \ tests/testHttpParser.cc \ tests/testHttpParser.h \ tests/testMain.cc \ tests/stub_time.cc \ wordlist.h \ wordlist.cc nodist_tests_testHttpParser_SOURCES = \ $(TESTSOURCES) tests_testHttpParser_LDADD= \ http/libsquid-http.la \ SquidConfig.o \ @@ -2540,41 +2535,40 @@ ip/libip.la \ $(top_builddir)/lib/libmiscutil.la \ $(SQUID_CPPUNIT_LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testHttpParser_LDFLAGS = $(LIBADD_DL) tests_testHttpParser_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) ## Tests of the HttpRequest module. tests_testHttpRequest_SOURCES = \ AccessLogEntry.cc \ HttpParser.cc \ HttpParser.h \ RequestFlags.h \ RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ Mem.h \ tests/stub_mem.cc \ - String.cc \ tests/testHttpRequest.h \ tests/testHttpRequest.cc \ tests/testHttpRequestMethod.h \ tests/testHttpRequestMethod.cc \ tests/testMain.cc \ tests/stub_DiskIOModule.cc \ tests/stub_libauth.cc \ tests/stub_main_cc.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_libeui.cc \ tests/stub_store_stats.cc \ time.cc \ BodyPipe.cc \ cache_manager.cc \ cache_cf.h \ AuthReg.h \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ cache_cf.cc \ @@ -2823,57 +2817,57 @@ RequestFlags.cc \ RequestFlags.h \ int.h \ int.cc \ SquidList.h \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ Mem.h \ tests/stub_mem.cc \ mem_node.cc \ MemBuf.cc \ MemObject.cc \ Notes.h \ Notes.cc \ Packer.cc \ Parsing.cc \ RemovalPolicy.cc \ refresh.h \ refresh.cc \ + $(SBUF_SOURCE) \ StatCounters.h \ StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ repl_modules.h \ store.cc \ store_dir.cc \ store_io.cc \ store_swapout.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ store_key_md5.h \ store_key_md5.cc \ - String.cc \ StrList.h \ StrList.cc \ SwapDir.cc \ tests/CapturingStoreEntry.h \ log/access_log.h \ tests/stub_access_log.cc \ tests/stub_acl.cc \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_client_side_request.cc \ tests/stub_comm.cc \ tests/stub_debug.cc \ tests/stub_DiskIOModule.cc \ tests/stub_errorpage.cc \ fd.h \ fde.h \ tests/stub_fd.cc \ tests/stub_helper.cc \ @@ -2943,41 +2937,41 @@ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SSLLIB) \ CommCalls.o \ DnsLookupDetails.o \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testStore_LDFLAGS = $(LIBADD_DL) tests_testStore_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) ## string needs mem.cc. ## mem.cc needs ClientInfo.h ## libsquid pulls in SquidConfig and children. stub them. tests_testString_SOURCES = \ ClientInfo.h \ Mem.h \ tests/stub_mem.cc \ MemBuf.cc \ - String.cc \ + $(SBUF_SOURCE) \ tests/testMain.cc \ tests/testString.cc \ tests/testString.h \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_debug.cc \ tests/stub_HelperChildConfig.cc \ tools.h \ tests/stub_tools.cc \ tests/stub_time.cc \ wordlist.h \ wordlist.cc nodist_tests_testString_SOURCES = \ $(TESTSOURCES) tests_testString_LDADD = \ base/libbase.la \ libsquid.la \ ip/libip.la \ @@ -3028,81 +3022,81 @@ tests/stub_store_rebuild.cc \ tests/stub_store_stats.cc \ fatal.h \ tests/stub_fatal.cc \ fd.h \ fd.cc \ fde.h \ fde.cc \ client_db.h \ disk.h \ disk.cc \ FileMap.h \ filemap.cc \ HttpBody.h \ HttpBody.cc \ HttpReply.cc \ int.h \ int.cc \ RequestFlags.h \ RequestFlags.cc \ + $(SBUF_SOURCE) \ SquidList.h \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ MemObject.cc \ Notes.h \ Notes.cc \ StoreSwapLogData.cc \ StoreIOState.cc \ StoreMetaUnpacker.cc \ $(STOREMETA_SOURCE) \ StoreFileSystem.cc \ store_io.cc \ store_swapout.cc \ store_swapmeta.cc \ $(UNLINKDSOURCE) \ $(WIN32_SOURCE) \ event.cc \ $(DELAY_POOL_SOURCE) \ CacheDigest.h \ tests/stub_CacheDigest.cc \ ConfigParser.cc \ EventLoop.cc \ HttpMsg.cc \ RemovalPolicy.cc \ store_dir.cc \ repl_modules.h \ store.cc \ HttpRequestMethod.cc \ store_key_md5.h \ store_key_md5.cc \ Parsing.cc \ ConfigOption.cc \ SwapDir.cc \ tests/stub_acl.cc \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_helper.cc \ cbdata.cc \ - String.cc \ tests/stub_debug.cc \ tests/stub_client_side_request.cc \ tests/stub_http.cc \ tests/stub_libauth.cc \ mem_node.cc \ stmem.cc \ mime.h \ tests/stub_mime.cc \ HttpHeaderFieldInfo.h \ HttpHeaderTools.h \ HttpHeaderTools.cc \ HttpHeader.h \ HttpHeader.cc \ Mem.h \ mem.cc \ ClientInfo.h \ MemBuf.cc \ HttpHdrContRange.cc \ Packer.cc \ HttpHeaderFieldStat.h \ @@ -3228,59 +3222,59 @@ HttpReply.cc \ HttpRequestMethod.cc \ int.h \ int.cc \ SquidList.h \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ Mem.h \ mem.cc \ MemBuf.cc \ MemObject.cc \ mem_node.cc \ Notes.h \ Notes.cc \ Packer.cc \ Parsing.cc \ RemovalPolicy.cc \ RequestFlags.cc \ RequestFlags.h \ + $(SBUF_SOURCE) \ StatCounters.h \ StatCounters.cc \ StatHist.h \ tests/stub_StatHist.cc \ stmem.cc \ repl_modules.h \ store.cc \ StoreFileSystem.cc \ StoreIOState.cc \ StoreMetaUnpacker.cc \ $(STOREMETA_SOURCE) \ StoreSwapLogData.cc \ store_dir.cc \ store_io.cc \ store_key_md5.h \ store_key_md5.cc \ store_swapmeta.cc \ store_swapout.cc \ - String.cc \ StrList.h \ StrList.cc \ SwapDir.cc \ tests/testRock.cc \ tests/testMain.cc \ tests/testRock.h \ tests/testStoreSupport.cc \ tests/testStoreSupport.h \ log/access_log.h \ tests/stub_access_log.cc \ cache_cf.h \ YesNoNone.h \ tests/stub_cache_cf.cc \ client_db.h \ tests/stub_cache_manager.cc \ tests/stub_client_db.cc \ tests/stub_client_side_request.cc \ tests/stub_debug.cc \ tests/stub_errorpage.cc \ tests/stub_HelperChildConfig.cc \ @@ -3500,41 +3494,40 @@ store_client.cc \ store_digest.h \ tests/stub_store_digest.cc \ store_dir.cc \ store_io.cc \ store_key_md5.h \ store_key_md5.cc \ store_log.h \ store_log.cc \ store_rebuild.h \ store_rebuild.cc \ store_swapin.h \ store_swapin.cc \ store_swapmeta.cc \ store_swapout.cc \ StoreFileSystem.cc \ StoreIOState.cc \ tests/stub_StoreMeta.cc \ StoreMetaUnpacker.cc \ StoreSwapLogData.cc \ - String.cc \ StrList.h \ StrList.cc \ tests/stub_SwapDir.cc \ MemStore.cc \ tests/stub_debug.cc \ tests/stub_DiskIOModule.cc \ tests/stub_libauth_acls.cc \ tests/stub_libauth.cc \ tests/stub_main_cc.cc \ tests/stub_ipc_Forwarder.cc \ tests/stub_store_stats.cc \ tests/testURL.cc \ tests/testURL.h \ tests/testURLScheme.cc \ tests/testURLScheme.h \ tests/testMain.cc \ tests/stub_time.cc \ tools.h \ tools.cc \ tests/stub_tunnel.cc \ @@ -3593,121 +3586,120 @@ $(SQUID_CPPUNIT_LA) tests_testSBuf_SOURCES= \ tests/testSBuf.h \ tests/testSBuf.cc \ tests/testMain.cc \ tests/SBufFindTest.h \ tests/SBufFindTest.cc \ $(SBUF_SOURCE) \ SBufStream.h \ tests/stub_time.cc \ mem.cc \ tests/stub_debug.cc \ tests/stub_fatal.cc \ tests/stub_HelperChildConfig.cc \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_store.cc \ tests/stub_store_stats.cc \ tests/stub_tools.cc \ - SquidString.h \ - String.cc \ tests/stub_wordlist.cc \ tests/stub_MemBuf.cc nodist_tests_testSBuf_SOURCES=$(TESTSOURCES) tests_testSBuf_LDFLAGS = $(LIBADD_DL) tests_testSBuf_LDADD=\ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(COMPAT_LIB) \ libsquid.la \ ip/libip.la \ mgr/libmgr.la \ base/libbase.la \ $(top_builddir)/lib/libmiscutil.la \ $(COMMON_LIBS) tests_testSBuf_DEPENDENCIES= $(SQUID_CPPUNIT_LA) tests_testConfigParser_SOURCES = \ ClientInfo.h \ Mem.h \ tests/stub_mem.cc \ tests/stub_MemBuf.cc \ tests/stub_time.cc \ - String.cc \ ConfigParser.cc \ fatal.h \ tests/stub_fatal.cc \ tests/testMain.cc \ tests/testConfigParser.cc \ tests/testConfigParser.h \ cache_cf.h \ + $(SBUF_SOURCE) \ YesNoNone.h \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_debug.cc \ tests/stub_HelperChildConfig.cc \ tools.h \ tests/stub_tools.cc \ wordlist.h \ wordlist.cc nodist_tests_testConfigParser_SOURCES = \ $(TESTSOURCES) tests_testConfigParser_LDADD = \ base/libbase.la \ libsquid.la \ ip/libip.la \ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SSLLIB) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testConfigParser_LDFLAGS = $(LIBADD_DL) tests_testConfigParser_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) tests_testStatHist_SOURCES = \ tests/stub_cbdata.cc \ fatal.h \ tests/stub_fatal.cc \ tests/stub_MemBuf.cc \ StatHist.cc \ StatHist.h \ - String.cc \ tests/stub_cache_manager.cc \ tests/stub_comm.cc \ tests/stub_debug.cc \ tests/stub_DelayId.cc \ tests/stub_HelperChildConfig.cc \ Mem.h \ tests/stub_mem.cc \ tests/stub_MemObject.cc \ mime.h \ tests/stub_mime.cc \ tests/stub_pconn.cc \ tests/stub_stmem.cc \ repl_modules.h \ + $(SBUF_SOURCE) \ tests/stub_store.cc \ tests/stub_store_stats.cc \ tools.h \ + tests/stub_time.cc \ tests/stub_tools.cc \ tests/testMain.cc \ tests/testStatHist.cc \ tests/testStatHist.h nodist_tests_testStatHist_SOURCES = \ $(TESTSOURCES) tests_testStatHist_LDFLAGS = $(LIBADD_DL) tests_testStatHist_LDADD = \ base/libbase.la \ $(top_builddir)/lib/libmiscutil.la \ $(top_builddir)/lib/libmisccontainers.la \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(COMPAT_LIB) tests_testStatHist_DEPENDENCIES = $(SQUID_CPPUNIT_LA) tests_testVector_SOURCES = \ tests/testVector.cc \ tests/testMain.cc \ tests/testVector.h === modified file 'src/Notes.cc' --- src/Notes.cc 2013-10-27 05:08:49 +0000 +++ src/Notes.cc 2013-11-05 11:13:14 +0000 @@ -75,42 +75,42 @@ return NULL; } Note::Pointer Notes::add(const String ¬eKey) { typedef Notes::NotesList::iterator AMLI; for (AMLI i = notes.begin(); i != notes.end(); ++i) { if ((*i)->key == noteKey) return (*i); } Note::Pointer note = new Note(noteKey); notes.push_back(note); return note; } Note::Pointer Notes::parse(ConfigParser &parser) { - String key = ConfigParser::NextToken(); - String value = ConfigParser::NextQuotedToken(); + String key(ConfigParser::NextToken()); + String value(ConfigParser::NextQuotedToken()); Note::Pointer note = add(key); Note::Value::Pointer noteValue = note->addValue(value); String label(key); label.append('='); label.append(value); aclParseAclList(parser, ¬eValue->aclList, label.termedBuf()); if (blacklisted) { for (int i = 0; blacklisted[i] != NULL; ++i) { if (note->key.caseCmp(blacklisted[i]) == 0) { fatalf("%s:%d: meta key \"%s\" is a reserved %s name", cfg_filename, config_lineno, note->key.termedBuf(), descr ? descr : ""); } } } return note; } === modified file 'src/SBuf.cc' --- src/SBuf.cc 2013-10-07 11:23:58 +0000 +++ src/SBuf.cc 2013-10-29 19:57:27 +0000 @@ -98,50 +98,40 @@ return *this; } SBuf::SBuf() : store_(GetStorePrototype()), off_(0), len_(0) { debugs(24, 8, id << " created"); ++stats.alloc; ++stats.live; } SBuf::SBuf(const SBuf &S) : store_(S.store_), off_(S.off_), len_(S.len_) { debugs(24, 8, id << " created from id " << S.id); ++stats.alloc; ++stats.allocCopy; ++stats.live; } -SBuf::SBuf(const String &S) - : store_(GetStorePrototype()), off_(0), len_(0) -{ - debugs(24, 8, id << " created from string"); - assign(S.rawBuf(), S.size()); - ++stats.alloc; - ++stats.allocFromString; - ++stats.live; -} - SBuf::SBuf(const std::string &s) : store_(GetStorePrototype()), off_(0), len_(0) { debugs(24, 8, id << " created from std::string"); lowAppend(s.data(),s.length()); ++stats.alloc; ++stats.allocFromString; ++stats.live; } SBuf::SBuf(const char *S, size_type n) : store_(GetStorePrototype()), off_(0), len_(0) { append(S,n); ++stats.alloc; ++stats.allocFromCString; ++stats.live; } SBuf::~SBuf() @@ -721,41 +711,41 @@ */ int SBuf::scanf(const char *format, ...) { va_list arg; int rv; ++stats.scanf; va_start(arg, format); rv = vsscanf(c_str(), format, arg); va_end(arg); return rv; } std::ostream & SBufStats::dump(std::ostream& os) const { MemBlobStats ststats = MemBlob::GetStats(); os << "SBuf stats:\nnumber of allocations: " << alloc << "\ncopy-allocations: " << allocCopy << - "\ncopy-allocations from SquidString: " << allocFromString << + "\ncopy-allocations from std::string: " << allocFromString << "\ncopy-allocations from C String: " << allocFromCString << "\nlive references: " << live << "\nno-copy assignments: " << assignFast << "\nclearing operations: " << clear << "\nappend operations: " << append << "\ndump-to-ostream: " << toStream << "\nset-char: " << setChar << "\nget-char: " << getChar << "\ncomparisons with data-scan: " << compareSlow << "\ncomparisons not requiring data-scan: " << compareFast << "\ncopy-out ops: " << copyOut << "\nraw access to memory: " << rawAccess << "\nchop operations: " << chop << "\ntrim operations: " << trim << "\nfind: " << find << "\nscanf: " << scanf << "\ncase-change ops: " << caseChange << "\nCOW not actually requiring a copy: " << cowFast << "\nCOW: " << cowSlow << "\naverage store share factor: " << @@ -788,49 +778,40 @@ const int c = (*this)[j]; if (islower(c)) rv.setAt(j, toupper(c)); //will cow() if needed } debugs(24, 8, "result: \"" << rv << "\""); ++stats.caseChange; return rv; } /** * checks whether the requested 'pos' is within the bounds of the SBuf * \throw OutOfBoundsException if access is out of bounds */ void SBuf::checkAccessBounds(size_type pos) const { if (pos >= length()) throw OutOfBoundsException(*this, pos, __FILE__, __LINE__); } -String -SBuf::toString() const -{ - String rv; - rv.limitInit(buf(), length()); - ++stats.copyOut; - return rv; -} - /** re-allocate the backing store of the SBuf. * * If there are contents in the SBuf, they will be copied over. * NO verifications are made on the size parameters, it's up to the caller to * make sure that the new size is big enough to hold the copied contents. * The re-allocated storage MAY be bigger than the requested size due to size-chunking * algorithms in MemBlock, it is guarranteed NOT to be smaller. */ void SBuf::reAlloc(size_type newsize) { debugs(24, 8, "new size: " << newsize); if (newsize > maxSize) throw SBufTooBigException(__FILE__, __LINE__); MemBlob::Pointer newbuf = new MemBlob(newsize); if (length() > 0) newbuf->append(buf(), length()); store_ = newbuf; off_ = 0; ++stats.cowSlow; === modified file 'src/SBuf.h' --- src/SBuf.h 2013-10-08 04:17:17 +0000 +++ src/SBuf.h 2013-10-29 19:57:27 +0000 @@ -15,41 +15,40 @@ * 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_SBUF_H #define SQUID_SBUF_H #include "base/InstanceId.h" #include "MemBlob.h" #include "SBufExceptions.h" -#include "SquidString.h" #if HAVE_CLIMITS #include #elif HAVE_LIMITS_H #include #endif #if HAVE_UNISTD_H #include #endif #if HAVE_STDARG_H #include #endif #if HAVE_IOSFWD #include #endif /* SBuf placeholder for printf */ #ifndef SQUIDSBUFPH #define SQUIDSBUFPH "%.*s" #define SQUIDSBUFPRINT(s) (s).plength(),(s).rawContent() @@ -114,46 +113,40 @@ /// Maximum size of a SBuf. By design it MUST be < MAX(size_type)/2. Currently 256Mb. static const size_type maxSize = 0xfffffff; /// create an empty (zero-size) SBuf SBuf(); SBuf(const SBuf &S); /** Constructor: import c-style string * * Create a new SBuf containing a COPY of the contents of the * c-string * \param S the c string to be copied * \param n how many bytes to import into the SBuf. If it is npos * or unspecified, imports to end-of-cstring * \note it is the caller's responsibility not to go out of bounds * \note bounds is 0 <= pos < length(); caller must pay attention to signedness */ explicit SBuf(const char *S, size_type n = npos); - /** Constructor: import SquidString, copying contents. - * - * This method will be removed once SquidString has gone. - */ - explicit SBuf(const String &S); - /// Constructor: import std::string. Contents are copied. explicit SBuf(const std::string &s); ~SBuf(); /** Explicit assignment. * * Current SBuf will share backing store with the assigned one. */ SBuf& assign(const SBuf &S); /** Assignment operator. * * Current SBuf will share backing store with the assigned one. */ SBuf& operator =(const SBuf & S) {return assign(S);} /** Import a c-string into a SBuf, copying the data. * * It is the caller's duty to free the imported string, if needed. @@ -293,41 +286,41 @@ * \param n how many bytes to remove; could be zero. * npos (or no argument) means 'to the end of SBuf' * \return a new SBuf containing the consumed bytes. */ SBuf consume(size_type n = npos); /// gets global statistic informations static const SBufStats& GetStats(); /** Copy SBuf contents into user-supplied C buffer. * * Export a copy of the SBuf's contents into the user-supplied * buffer, up to the user-supplied-length. No zero-termination is performed * \return num the number of actually-copied chars. */ size_type copy(char *dest, size_type n) const; /** exports a pointer to the SBuf internal storage. * \warning ACCESSING RAW STORAGE IS DANGEROUS! * - * Returns a ead-only pointer to SBuf's content. No terminating null + * Returns a read-only pointer to SBuf's content. No terminating null * character is appended (use c_str() for that). * The returned value points to an internal location whose contents * are guaranteed to remain unchanged only until the next call * to a non-constant member function of the SBuf object. Such a * call may be implicit (e.g., when SBuf is destroyed * upon leaving the current context). * This is a very UNSAFE way of accessing the data. * This call never returns NULL. * \see c_str * \note the memory management system guarantees that the exported region * of memory will remain valid if the caller keeps holding * a valid reference to the SBuf object and does not write or append to * it. For example: * \code * SBuf foo("some string"); * const char *bar = foo.rawContent(); * doSomething(bar); //safe * foo.append(" other string"); * doSomething(bar); //unsafe * \endcode @@ -519,46 +512,40 @@ * sscanf re-implementation. Non-const, and not \0-clean. * \return same as sscanf * \see man sscanf(3) */ int scanf(const char *format, ...); /** Lower-case SBuf * * Returns a lower-cased COPY of the SBuf * \see man tolower(3) */ SBuf toLower() const; /** Upper-case SBuf * * Returns an upper-cased COPY of the SBuf * \see man toupper(3) */ SBuf toUpper() const; - /** String export function - * converts the SBuf to a legacy String, by copy. - * \deprecated - */ - String toString() const; - /// std::string export function std::string toStdString() const { return std::string(buf(),length()); } // TODO: possibly implement erase() similar to std::string's erase // TODO: possibly implement a replace() call private: MemBlob::Pointer store_; ///< memory block, possibly shared with other SBufs size_type off_; ///< our content start offset from the beginning of shared store_ size_type len_; ///< number of our content bytes in shared store_ static SBufStats stats; ///< class-wide statistics /// SBuf object identifier; does not change when contents do, /// including during assignment const InstanceId id; /** obtain prototype store * * Just-created SBufs all share to the same MemBlob. * This call instantiates and returns it. === modified file 'src/SquidString.h' --- src/SquidString.h 2013-10-04 13:55:21 +0000 +++ src/SquidString.h 2013-11-05 11:13:14 +0000 @@ -16,136 +16,137 @@ * * 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_STRING_H #define SQUID_STRING_H +#include "SBuf.h" + #if HAVE_OSTREAM #include #endif /* squid string placeholder (for printf) */ #ifndef SQUIDSTRINGPH #define SQUIDSTRINGPH "%.*s" #define SQUIDSTRINGPRINT(s) (s).psize(),(s).rawBuf() #endif /* SQUIDSTRINGPH */ class String { public: _SQUID_INLINE_ String(); - String(char const *); + explicit String(char const *); String(String const &); - ~String(); - typedef size_t size_type; //storage size intentionally unspecified - const static size_type npos = std::string::npos; + explicit String(SBuf const &s) : buf_(s), defined_(s.length() > 0) {} + SBuf &toSBuf() const {return buf_;} + + typedef SBuf::size_type size_type; //storage size intentionally unspecified + const static size_type npos = SBuf::npos; String &operator =(char const *); String &operator =(String const &); + String &operator =(SBuf const &s) { + defined_=(s.length() > 0); // SBuf is always defined; estimating + buf_=s; + return *this; + } bool operator ==(String const &) const; + // {return defined() == s.defined() && buf_ == s.buf_;} bool operator !=(String const &) const; + // {return defined() != s.defined() || buf_ != s.buf_;} /** * Retrieve a single character in the string. \param pos Position of character to retrieve. */ _SQUID_INLINE_ char operator [](unsigned int pos) const; _SQUID_INLINE_ size_type size() const; /// variant of size() suited to be used for printf-alikes. /// throws when size() > MAXINT int psize() const; /** * \retval true the String has some contents */ _SQUID_INLINE_ bool defined() const; /** - * \retval true the String does not hold any contents - */ - _SQUID_INLINE_ bool undefined() const; - /** * Returns a raw pointer to the underlying backing store. The caller has been * verified not to make any assumptions about null-termination */ _SQUID_INLINE_ char const * rawBuf() const; /** * Returns a raw pointer to the underlying backing store. * The caller requires it to be null-terminated. */ _SQUID_INLINE_ char const * termedBuf() const; void limitInit(const char *str, int len); // TODO: rename to assign() void clean(); void reset(char const *str); void append(char const *buf, int len); void append(char const *buf); void append(char const); void append(String const &); void absorb(String &old); const char * pos(char const *aString) const; const char * pos(char const ch) const; ///offset from string start of the first occurrence of ch /// returns String::npos if ch is not found size_type find(char const ch) const; size_type find(char const *aString) const; const char * rpos(char const ch) const; size_type rfind(char const ch) const; _SQUID_INLINE_ int cmp(char const *) const; _SQUID_INLINE_ int cmp(char const *, size_type count) const; _SQUID_INLINE_ int cmp(String const &) const; _SQUID_INLINE_ int caseCmp(char const *) const; _SQUID_INLINE_ int caseCmp(char const *, size_type count) const; _SQUID_INLINE_ int caseCmp(String const &) const; String substr(size_type from, size_type to) const; _SQUID_INLINE_ void cut(size_type newLength); private: - void allocAndFill(const char *str, int len); - void allocBuffer(size_type sz); - void setBuffer(char *buf, size_type sz); - _SQUID_INLINE_ bool nilCmp(bool, bool, int &) const; - /* never reference these directly! */ - size_type size_; /* buffer size; 64K limit */ - - size_type len_; /* current length */ - - char *buf_; - - _SQUID_INLINE_ void set(char const *loc, char const ch); - _SQUID_INLINE_ void cutPointer(char const *loc); + mutable SBuf buf_; + // SquidString used to track whether buf_ was NULL or not + // and some code makes use of this property. + // Until that is all checked and defined()/undefined() erased + // we explicitly track whether SquidString would have had + // buf_ allocated. + mutable bool defined_; }; _SQUID_INLINE_ std::ostream & operator<<(std::ostream& os, String const &aString); _SQUID_INLINE_ bool operator<(const String &a, const String &b); #if _USE_INLINE_ #include "String.cci" #endif const char *checkNullString(const char *p); int stringHasWhitespace(const char *); int stringHasCntl(const char *); char *strwordtok(char *buf, char **t); #endif /* SQUID_STRING_H */ === modified file 'src/String.cc' --- src/String.cc 2012-10-04 09:14:06 +0000 +++ src/String.cc 2013-11-05 11:13:14 +0000 @@ -20,262 +20,179 @@ * 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/TextException.h" #include "Mem.h" #include "mgr/Registration.h" #include "profiler/Profiler.h" #include "Store.h" +#include "SquidString.h" #if HAVE_LIMITS_H #include #endif int String::psize() const { Must(size() < INT_MAX); return size(); } -// low-level buffer allocation, -// does not free old buffer and does not adjust or look at len_ -void -String::allocBuffer(String::size_type sz) -{ - PROF_start(StringInitBuf); - assert (undefined()); - char *newBuffer = (char*)memAllocString(sz, &sz); - setBuffer(newBuffer, sz); - PROF_stop(StringInitBuf); -} - -// low-level buffer assignment -// does not free old buffer and does not adjust or look at len_ -void -String::setBuffer(char *aBuf, String::size_type aSize) -{ - assert(undefined()); - assert(aSize < 65536); - buf_ = aBuf; - size_ = aSize; -} - -String::String(char const *aString) : size_(0), len_(0), buf_(NULL) +String::String(char const *aString) : + buf_(aString), + defined_(aString != NULL) { - if (aString) - allocAndFill(aString, strlen(aString)); -#if DEBUGSTRINGS - - StringRegistry::Instance().add(this); -#endif } String & String::operator =(char const *aString) { reset(aString); return *this; } String & String::operator =(String const &old) { - clean(); // TODO: optimize to avoid cleaning the buffer we can use - if (old.size() > 0) - allocAndFill(old.rawBuf(), old.size()); + buf_ = old.buf_; + defined_ = old.defined_; return *this; } bool String::operator ==(String const &that) const { if (0 == this->cmp(that)) return true; return false; } bool String::operator !=(String const &that) const { if (0 == this->cmp(that)) return false; return true; } // public interface, makes sure that we clean the old buffer first void String::limitInit(const char *str, int len) { clean(); // TODO: optimize to avoid cleaning the buffer we can use - allocAndFill(str, len); -} - -// Allocates the buffer to fit the supplied string and fills it. -// Does not clean. -void -String::allocAndFill(const char *str, int len) -{ - PROF_start(StringAllocAndFill); - assert(this && str); - allocBuffer(len + 1); - len_ = len; - memcpy(buf_, str, len); - buf_[len] = '\0'; - PROF_stop(StringAllocAndFill); + append(str, len); } -String::String(String const &old) : size_(0), len_(0), buf_(NULL) +String::String(String const &old) : buf_(old.buf_), defined_(old.defined_) { - if (old.size() > 0) - allocAndFill(old.rawBuf(), old.size()); -#if DEBUGSTRINGS - - StringRegistry::Instance().add(this); -#endif } void String::clean() { PROF_start(StringClean); assert(this); - /* TODO if mempools has already closed this will FAIL!! */ - if (defined()) - memFreeString(size_, buf_); - - len_ = 0; + buf_.clear(); + defined_=false; - size_ = 0; - - buf_ = NULL; PROF_stop(StringClean); } -String::~String() -{ - clean(); -#if DEBUGSTRINGS - - StringRegistry::Instance().remove(this); -#endif -} - void String::reset(char const *str) { PROF_start(StringReset); clean(); // TODO: optimize to avoid cleaning the buffer if we can reuse it - if (str) - allocAndFill(str, strlen(str)); + if (str) { + append(str); + // XXX: empty string "" sent to append means no change, + // but on reset / assignment it means set a defined empty string. + defined_=true; + } PROF_stop(StringReset); } void String::append( char const *str, int len) { assert(this); assert(str && len >= 0); PROF_start(StringAppend); - if (len_ + len < size_) { - strncat(buf_, str, len); - len_ += len; - } else { - // Create a temporary string and absorb it later. - String snew; - assert(len_ + len < 65536); // otherwise snew.len_ overflows below - snew.len_ = len_ + len; - snew.allocBuffer(snew.len_ + 1); - - if (len_) - memcpy(snew.buf_, rawBuf(), len_); - - if (len) - memcpy(snew.buf_ + len_, str, len); - - snew.buf_[snew.len_] = '\0'; - - absorb(snew); - } + buf_.append(str, len); + defined_ = true; PROF_stop(StringAppend); } void String::append(char const *str) { assert(str); append(str, strlen(str)); } void String::append(char const chr) { char myString[2]; myString[0]=chr; myString[1]='\0'; append(myString, 1); } void String::append(String const &old) { - append(old.rawBuf(), old.len_); + append(old.rawBuf(), old.size()); } void String::absorb(String &old) { - clean(); - setBuffer(old.buf_, old.size_); - len_ = old.len_; - old.size_ = 0; - old.buf_ = NULL; - old.len_ = 0; + operator = (old); + old.clean(); } String String::substr(String::size_type from, String::size_type to) const { -// Must(from >= 0 && from < size()); Must(from < size()); Must(to > 0 && to <= size()); Must(to > from); - String rv; - rv.limitInit(rawBuf()+from,to-from); - return rv; + return String(buf_.substr(from, to-from)); } #if DEBUGSTRINGS void String::stat(StoreEntry *entry) const { storeAppendPrintf(entry, "%p : %d/%d \"%.*s\"\n",this,len_, size_, size(), rawBuf()); } StringRegistry & StringRegistry::Instance() { return Instance_; } template int ptrcmp(C const &lhs, C const &rhs) { return lhs - rhs; @@ -425,57 +342,57 @@ } } done: *d = '\0'; error: *t = (char *) p; return (char *) word; } const char * checkNullString(const char *p) { return p ? p : "(NULL)"; } const char * String::pos(char const *aString) const { - if (undefined()) + if (!defined()) return NULL; return strstr(termedBuf(), aString); } const char * String::pos(char const ch) const { - if (undefined()) + if (!defined()) return NULL; return strchr(termedBuf(), ch); } const char * String::rpos(char const ch) const { - if (undefined()) + if (!defined()) return NULL; return strrchr(termedBuf(), (ch)); } String::size_type String::find(char const ch) const { const char *c; c=pos(ch); if (c==NULL) return npos; return c-rawBuf(); } String::size_type String::find(char const *aString) const { const char *c; c=pos(aString); if (c==NULL) === modified file 'src/String.cci' --- src/String.cci 2012-09-22 01:28:35 +0000 +++ src/String.cci 2013-11-05 11:13:14 +0000 @@ -23,180 +23,147 @@ * 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 #if HAVE_STDINT_H #include #else /* HAVE_STDINT_H */ #ifndef INT_MAX #define INT_MAX 1<<31 //hack but a safe bet #endif /* INT_MAX */ #endif /* HAVE_STDINT_H */ -String::String() : size_(0), len_(0), buf_(NULL) +String::String() : buf_(), defined_(false) { -#if DEBUGSTRINGS - StringRegistry::Instance().add(this); -#endif } String::size_type String::size() const { - return len_; + return buf_.length(); } bool String::defined() const { - return buf_!=NULL; -} - -bool String::undefined() const -{ - return buf_==NULL; + return defined_; } char const * String::rawBuf() const { - return buf_; + return termedBuf(); } char const * String::termedBuf() const { - return buf_; + if (!defined()) return NULL; + // XXX: callers will probably try and write to the buffer, + // but SquidString never offered any more guarantee than SBuf + // does now about buffers existence. (see NULL result above) + return buf_.c_str(); } char String::operator [](unsigned int aPos) const { - assert(aPos < size_); + assert(aPos < size()); return buf_[aPos]; } /// compare NULL and empty strings because str*cmp() may fail on NULL strings /// and because we need to return consistent results for strncmp(count == 0). bool String::nilCmp(const bool thisIsNilOrEmpty, const bool otherIsNilOrEmpty, int &result) const { if (!thisIsNilOrEmpty && !otherIsNilOrEmpty) return false; // result does not matter if (thisIsNilOrEmpty && otherIsNilOrEmpty) result = 0; else if (thisIsNilOrEmpty) result = -1; else // otherIsNilOrEmpty result = +1; return true; } int String::cmp(char const *aString) const { - int result = 0; - if (nilCmp(!size(), (!aString || !*aString), result)) - return result; - - return strcmp(termedBuf(), aString); + return buf_.cmp(SBuf(aString)); } int String::cmp(char const *aString, String::size_type count) const { int result = 0; if (nilCmp((!size() || !count), (!aString || !*aString || !count), result)) return result; return strncmp(termedBuf(), aString, count); } int String::cmp(String const &aString) const { - int result = 0; - if (nilCmp(!size(), !aString.size(), result)) - return result; - - return strcmp(termedBuf(), aString.termedBuf()); + return buf_.cmp(aString.buf_); } int String::caseCmp(char const *aString) const { - int result = 0; - if (nilCmp(!size(), (!aString || !*aString), result)) - return result; - - return strcasecmp(termedBuf(), aString); + return buf_.caseCmp(SBuf(aString)); } int String::caseCmp(char const *aString, String::size_type count) const { int result = 0; if (nilCmp((!size() || !count), (!aString || !*aString || !count), result)) return result; return strncasecmp(termedBuf(), aString, count); } int String::caseCmp(const String &str) const { - return caseCmp(str.rawBuf(),str.size()); -} - -void -String::set(char const *loc, char const ch) -{ - if (loc < buf_ || loc > (buf_ + size_) ) return; - - buf_[loc-buf_] = ch; + return buf_.caseCmp(str.buf_); } void String::cut(String::size_type newLength) { // size_type is size_t, unsigned. No need to check for newLength <0 - if (newLength > len_) return; + if (newLength > buf_.length()) return; - len_ = newLength; + buf_ = buf_.substr(0, newLength); // buf_ may be NULL on zero-length strings. - if (len_ == 0 && buf_ == NULL) return; - - buf_[newLength] = '\0'; -} - -void -String::cutPointer(char const *loc) -{ - if (loc < buf_ || loc > (buf_ + size_) ) return; + if (buf_.length() == 0 && !defined()) return; - len_ = loc-buf_; - buf_[len_] = '\0'; + buf_.setAt(newLength, '\0'); // terminate String. } std::ostream & operator<<(std::ostream& os, String const &aString) { - os.write(aString.rawBuf(),aString.size()); + os << aString.toSBuf(); return os; } bool operator<(const String &a, const String &b) { return a.cmp(b) < 0; } === modified file 'src/acl/AdaptationServiceData.cc' --- src/acl/AdaptationServiceData.cc 2013-11-12 14:48:50 +0000 +++ src/acl/AdaptationServiceData.cc 2013-11-05 11:13:14 +0000 @@ -1,39 +1,39 @@ #include "squid.h" #include "acl/AdaptationServiceData.h" #include "acl/Checklist.h" #include "adaptation/Config.h" #include "adaptation/ecap/Config.h" #include "adaptation/icap/Config.h" #include "adaptation/Service.h" #include "adaptation/ServiceGroups.h" #include "cache_cf.h" #include "ConfigParser.h" #include "Debug.h" #include "wordlist.h" void ACLAdaptationServiceData::parse() { Adaptation::Config::needHistory = true; while (char *t = ConfigParser::strtokFile()) { if ( #if USE_ECAP - Adaptation::Ecap::TheConfig.findServiceConfig(t) == NULL && + Adaptation::Ecap::TheConfig.findServiceConfig(String(t)) == NULL && #endif #if ICAP_CLIENT - Adaptation::Icap::TheConfig.findServiceConfig(t) == NULL && + Adaptation::Icap::TheConfig.findServiceConfig(String(t)) == NULL && #endif - Adaptation::FindGroup(t) == NULL) { + Adaptation::FindGroup(String(t)) == NULL) { debugs(28, DBG_CRITICAL, "FATAL: Adaptation service/group " << t << " in adaptation_service acl is not defined"); self_destruct(); } insert(t); } } ACLData * ACLAdaptationServiceData::clone() const { return new ACLAdaptationServiceData(*this); } === modified file 'src/adaptation/Config.cc' --- src/adaptation/Config.cc 2013-11-12 14:48:50 +0000 +++ src/adaptation/Config.cc 2013-11-05 11:13:14 +0000 @@ -260,41 +260,41 @@ void Adaptation::Config::FreeServiceGroups() { while (!AllGroups().empty()) { // groups are refcounted so we do not explicitly delete them AllGroups().pop_back(); } } void Adaptation::Config::DumpServiceGroups(StoreEntry *entry, const char *name) { typedef Groups::iterator GI; for (GI i = AllGroups().begin(); i != AllGroups().end(); ++i) storeAppendPrintf(entry, "%s " SQUIDSTRINGPH "\n", name, SQUIDSTRINGPRINT((*i)->id)); } void Adaptation::Config::ParseAccess(ConfigParser &parser) { - String groupId = ConfigParser::NextToken(); + String groupId(ConfigParser::NextToken()); AccessRule *r; if (!(r=FindRuleByGroupId(groupId))) { r = new AccessRule(groupId); AllRules().push_back(r); } r->parse(parser); } void Adaptation::Config::FreeAccess() { while (!AllRules().empty()) { delete AllRules().back(); AllRules().pop_back(); } } void Adaptation::Config::DumpAccess(StoreEntry *entry, const char *name) { === modified file 'src/adaptation/History.cc' --- src/adaptation/History.cc 2013-11-12 14:48:50 +0000 +++ src/adaptation/History.cc 2013-11-05 11:13:14 +0000 @@ -1,30 +1,30 @@ #include "squid.h" #include "adaptation/Config.h" #include "adaptation/History.h" #include "base/TextException.h" #include "Debug.h" #include "globals.h" #include "SquidTime.h" /// impossible services value to identify unset theNextServices -const static char *TheNullServices = ",null,"; +const static String TheNullServices(",null,"); Adaptation::History::Entry::Entry(const String &serviceId, const timeval &when): service(serviceId), start(when), theRptm(-1), retried(false) { } Adaptation::History::Entry::Entry(): start(current_time), theRptm(-1), retried(false) { } void Adaptation::History::Entry::stop() { // theRptm may already be set if the access log entry has already been made (void)rptm(); // will cache result in theRptm if not set already } int Adaptation::History::Entry::rptm() { if (theRptm < 0) @@ -42,67 +42,69 @@ int Adaptation::History::recordXactStart(const String &serviceId, const timeval &when, bool retrying) { // the history will be empty on retries if it was enabled after the failure if (retrying && !theEntries.empty()) theEntries.back().retried = true; theEntries.push_back(Adaptation::History::Entry(serviceId, when)); return theEntries.size() - 1; // record position becomes history ID } void Adaptation::History::recordXactFinish(int hid) { Must(0 <= hid && hid < static_cast(theEntries.size())); theEntries[hid].stop(); } void Adaptation::History::allLogString(const char *serviceId, String &s) { s=""; bool prevWasRetried = false; + String theServiceId(serviceId); // XXX: Fix Vector<> so that we can use const_iterator here typedef Adaptation::History::Entries::iterator ECI; for (ECI i = theEntries.begin(); i != theEntries.end(); ++i) { // TODO: here and below, optimize service ID comparison? - if (!serviceId || i->service == serviceId) { + if (!serviceId || i->service == theServiceId) { if (s.size() > 0) // not the first logged time, must delimit s.append(prevWasRetried ? "+" : ","); char buf[64]; snprintf(buf, sizeof(buf), "%d", i->rptm()); s.append(buf); // continue; we may have two identical services (e.g., for retries) } prevWasRetried = i->retried; } } void Adaptation::History::sumLogString(const char *serviceId, String &s) { s=""; int retriedRptm = 0; // sum of rptm times of retried transactions typedef Adaptation::History::Entries::iterator ECI; + String theServiceId(serviceId); for (ECI i = theEntries.begin(); i != theEntries.end(); ++i) { if (i->retried) { // do not log retried xact but accumulate their time retriedRptm += i->rptm(); - } else if (!serviceId || i->service == serviceId) { + } else if (!serviceId || i->service == theServiceId) { if (s.size() > 0) // not the first logged time, must delimit s.append(","); char buf[64]; snprintf(buf, sizeof(buf), "%d", retriedRptm + i->rptm()); s.append(buf); // continue; we may have two identical services (e.g., for retries) } if (!i->retried) retriedRptm = 0; } // the last transaction is never retried or it would not be the last Must(!retriedRptm); } void Adaptation::History::updateXxRecord(const char *name, const String &value) { === modified file 'src/adaptation/Iterator.cc' --- src/adaptation/Iterator.cc 2013-11-12 14:48:50 +0000 +++ src/adaptation/Iterator.cc 2013-11-05 11:13:14 +0000 @@ -37,81 +37,81 @@ { assert(!theLauncher); HTTPMSGUNLOCK(theMsg); HTTPMSGUNLOCK(theCause); } void Adaptation::Iterator::start() { Adaptation::Initiate::start(); thePlan = ServicePlan(theGroup, filter()); // Add adaptation group name once and now, before // dynamic groups change it at step() time. if (Adaptation::Config::needHistory && !thePlan.exhausted() && (dynamic_cast(theGroup.getRaw()) || dynamic_cast(theGroup.getRaw()))) { HttpRequest *request = dynamic_cast(theMsg); if (!request) request = theCause; Must(request); Adaptation::History::Pointer ah = request->adaptHistory(true); - SBuf gid(theGroup->id); + SBuf gid(theGroup->id.toSBuf()); ah->recordAdaptationService(gid); } step(); } void Adaptation::Iterator::step() { ++iterations; debugs(93,5, HERE << '#' << iterations << " plan: " << thePlan); Must(!theLauncher); if (thePlan.exhausted()) { // nothing more to do sendAnswer(Answer::Forward(theMsg)); Must(done()); return; } HttpRequest *request = dynamic_cast(theMsg); if (!request) request = theCause; assert(request); request->clearError(); if (iterations > Adaptation::Config::service_iteration_limit) { debugs(93,DBG_CRITICAL, "Adaptation iterations limit (" << Adaptation::Config::service_iteration_limit << ") exceeded:\n" << "\tPossible service loop with " << theGroup->kind << " " << theGroup->id << ", plan=" << thePlan); throw TexcHere("too many adaptations"); } ServicePointer service = thePlan.current(); Must(service != NULL); debugs(93,5, HERE << "using adaptation service: " << service->cfg().key); if (Adaptation::Config::needHistory) { Adaptation::History::Pointer ah = request->adaptHistory(true); - SBuf uid(thePlan.current()->cfg().key); + SBuf uid(thePlan.current()->cfg().key.toSBuf()); ah->recordAdaptationService(uid); } theLauncher = initiateAdaptation( service->makeXactLauncher(theMsg, theCause)); Must(initiated(theLauncher)); Must(!done()); } void Adaptation::Iterator::noteAdaptationAnswer(const Answer &answer) { switch (answer.kind) { case Answer::akForward: handleAdaptedHeader(const_cast(answer.message.getRaw())); break; case Answer::akBlock: handleAdaptationBlock(answer); break; === modified file 'src/adaptation/ServiceConfig.cc' --- src/adaptation/ServiceConfig.cc 2013-07-21 19:24:35 +0000 +++ src/adaptation/ServiceConfig.cc 2013-11-05 11:13:14 +0000 @@ -45,41 +45,41 @@ { const char *t = service_configConfig; const char *q = strchr(t, '_'); if (q) t = q + 1; if (!strcmp(t, "precache")) return Adaptation::pointPreCache; if (!strcmp(t, "postcache")) return Adaptation::pointPostCache; return Adaptation::pointNone; } bool Adaptation::ServiceConfig::parse() { key = ConfigParser::NextToken(); - String method_point = ConfigParser::NextToken(); + String method_point(ConfigParser::NextToken()); method = parseMethod(method_point.termedBuf()); point = parseVectPoint(method_point.termedBuf()); // reset optional parameters in case we are reconfiguring bypass = routing = false; // handle optional service name=value parameters bool grokkedUri = false; bool onOverloadSet = false; std::set options; while (char *option = ConfigParser::NextToken()) { const char *name = option; const char *value = ""; if (strcmp(option, "0") == 0) { // backward compatibility name = "bypass"; value = "off"; debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT), "UPGRADE: Please use 'bypass=off' option to disable service bypass"); } else if (strcmp(option, "1") == 0) { // backward compatibility name = "bypass"; === modified file 'src/adaptation/ServiceGroups.cc' --- src/adaptation/ServiceGroups.cc 2013-07-21 19:24:35 +0000 +++ src/adaptation/ServiceGroups.cc 2013-11-05 11:13:14 +0000 @@ -11,41 +11,41 @@ #include "wordlist.h" Adaptation::ServiceGroup::ServiceGroup(const String &aKind, bool allSame): kind(aKind), method(methodNone), point(pointNone), allServicesSame(allSame) { } Adaptation::ServiceGroup::~ServiceGroup() { } void Adaptation::ServiceGroup::parse() { id = ConfigParser::NextToken(); wordlist *names = NULL; ConfigParser::ParseWordList(&names); for (wordlist *i = names; i; i = i->next) - services.push_back(i->key); + services.push_back(String(i->key)); wordlistDestroy(&names); } // Note: configuration code aside, this method is called by DynamicServiceChain void Adaptation::ServiceGroup::finalize() { // 1) warn if services have different methods or vectoring point // 2) warn if all-same services have different bypass status // 3) warn if there are seemingly identical services in the group // TODO: optimize by remembering ServicePointers rather than IDs if (!removedServices.empty()) { String s; for (Store::iterator it = removedServices.begin(); it != removedServices.end(); ++it) { s.append(*it); s.append(','); } s.cut(s.size() - 1); debugs(93, DBG_IMPORTANT, "Adaptation group '" << id << "' contains disabled member(s) after reconfiguration: " << s); removedServices.clean(); @@ -179,56 +179,56 @@ } debugs(93,5,HERE << id << " has no matching services"); return false; } bool Adaptation::ServiceGroup::findReplacement(const ServiceFilter &filter, Pos &pos) const { return allServicesSame && findService(filter, pos); } bool Adaptation::ServiceGroup::findLink(const ServiceFilter &filter, Pos &pos) const { return !allServicesSame && findService(filter, pos); } /* ServiceSet */ -Adaptation::ServiceSet::ServiceSet(): ServiceGroup("adaptation set", true) +Adaptation::ServiceSet::ServiceSet(): ServiceGroup(String("adaptation set"), true) { } /* SingleService */ Adaptation::SingleService::SingleService(const String &aServiceId): - ServiceGroup("single-service group", false) + ServiceGroup(String("single-service group"), false) { id = aServiceId; services.push_back(aServiceId); } /* ServiceChain */ -Adaptation::ServiceChain::ServiceChain(): ServiceGroup("adaptation chain", false) +Adaptation::ServiceChain::ServiceChain(): ServiceGroup(String("adaptation chain"), false) { } /* DynamicServiceChain */ Adaptation::DynamicServiceChain::DynamicServiceChain( const DynamicGroupCfg &cfg, const ServiceFilter &filter) { kind = "dynamic adaptation chain"; // TODO: optimize by using String const id = cfg.id; // use services ids as the dynamic group ID services = cfg.services; // initialize cache to improve consistency checks in finalize() method = filter.method; point = filter.point; finalize(); // will report [dynamic] config errors } void === modified file 'src/adaptation/ecap/ServiceRep.cc' --- src/adaptation/ecap/ServiceRep.cc 2012-08-28 13:00:30 +0000 +++ src/adaptation/ecap/ServiceRep.cc 2013-11-05 11:13:14 +0000 @@ -196,73 +196,73 @@ return buf.content(); } void Adaptation::Ecap::ServiceRep::detach() { isDetached = true; } bool Adaptation::Ecap::ServiceRep::detached() const { return isDetached; } Adaptation::Ecap::ServiceRep::AdapterService Adaptation::Ecap::FindAdapterService(const String& serviceUri) { typedef std::list::const_iterator ASCI; for (ASCI s = TheServices.begin(); s != TheServices.end(); ++s) { Must(*s); - if (serviceUri == (*s)->uri().c_str()) + if (serviceUri == String((*s)->uri().c_str())) return *s; } return ServiceRep::AdapterService(); } void Adaptation::Ecap::RegisterAdapterService(const Adaptation::Ecap::ServiceRep::AdapterService& adapterService) { typedef std::list::iterator ASI; for (ASI s = TheServices.begin(); s != TheServices.end(); ++s) { Must(*s); if (adapterService->uri() == (*s)->uri()) { *s = adapterService; debugs(93, 3, "updated eCAP module service: " << adapterService->uri()); return; } } TheServices.push_back(adapterService); debugs(93, 3, "registered eCAP module service: " << adapterService->uri()); } void Adaptation::Ecap::UnregisterAdapterService(const String& serviceUri) { typedef std::list::iterator ASI; for (ASI s = TheServices.begin(); s != TheServices.end(); ++s) { - if (serviceUri == (*s)->uri().c_str()) { + if (serviceUri == String((*s)->uri().c_str())) { TheServices.erase(s); debugs(93, 3, "unregistered eCAP module service: " << serviceUri); return; } } debugs(93, 3, "failed to unregister eCAP module service: " << serviceUri); } void Adaptation::Ecap::CheckUnusedAdapterServices(const Adaptation::Services& cfgs) { typedef std::list::const_iterator ASCI; for (ASCI loaded = TheServices.begin(); loaded != TheServices.end(); ++loaded) { bool found = false; for (Services::const_iterator cfged = cfgs.begin(); cfged != cfgs.end() && !found; ++cfged) { - found = (*cfged)->cfg().uri == (*loaded)->uri().c_str(); + found = (*cfged)->cfg().uri == String((*loaded)->uri().c_str()); } if (!found) debugs(93, DBG_IMPORTANT, "Warning: loaded eCAP service has no matching " << "ecap_service config option: " << (*loaded)->uri()); } } === modified file 'src/adaptation/ecap/XactionRep.cc' --- src/adaptation/ecap/XactionRep.cc 2013-10-25 00:13:46 +0000 +++ src/adaptation/ecap/XactionRep.cc 2013-11-05 11:13:14 +0000 @@ -429,51 +429,51 @@ /// which may affect answer processing and may be needed for logging. void Adaptation::Ecap::XactionRep::updateHistory(HttpMsg *adapted) { if (!theMaster) // all updates rely on being able to query the adapter return; const HttpRequest *request = dynamic_cast(theCauseRep ? theCauseRep->raw().header : theVirginRep.raw().header); Must(request); // TODO: move common ICAP/eCAP logic to Adaptation::Xaction or similar // TODO: optimize Area-to-String conversion // update the cross-transactional database if needed if (const char *xxNameStr = Adaptation::Config::masterx_shared_name) { Adaptation::History::Pointer ah = request->adaptHistory(true); if (ah != NULL) { libecap::Name xxName(xxNameStr); // TODO: optimize? if (const libecap::Area val = theMaster->option(xxName)) - ah->updateXxRecord(xxNameStr, val.toString().c_str()); + ah->updateXxRecord(xxNameStr, String(val.toString().c_str())); } } // update the adaptation plan if needed if (service().cfg().routing) { String services; if (const libecap::Area services = theMaster->option(libecap::metaNextServices)) { Adaptation::History::Pointer ah = request->adaptHistory(true); if (ah != NULL) - ah->updateNextServices(services.toString().c_str()); + ah->updateNextServices(String(services.toString().c_str())); } } // TODO: else warn (occasionally!) if we got libecap::metaNextServices // Store received meta headers for adapt::adaptLogHistory(); if (ah != NULL) { HttpHeader meta(hoReply); OptionsExtractor extractor(meta); theMaster->visitEachOption(extractor); ah->recordMeta(&meta); } // Add just-created history to the adapted/cloned request that lacks it. if (HttpRequest *adaptedReq = dynamic_cast(adapted)) adaptedReq->adaptHistoryImport(*request); } void === modified file 'src/cache_cf.cc' --- src/cache_cf.cc 2013-10-25 00:13:46 +0000 +++ src/cache_cf.cc 2013-11-05 11:13:14 +0000 @@ -4282,45 +4282,45 @@ } } 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; - if (!parseNamedIntList(pToken, "process_numbers", processes)) { + if (!parseNamedIntList(pToken, String("process_numbers"), processes)) { debugs(3, DBG_CRITICAL, "FATAL: bad 'process_numbers' parameter " << "in 'cpu_affinity_map'"); self_destruct(); - } else if (!parseNamedIntList(cToken, "cores", cores)) { + } else if (!parseNamedIntList(cToken, String("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]); } @@ -4744,41 +4744,41 @@ } static void parse_HeaderWithAclList(HeaderWithAclList **headers) { char *fn; if (!*headers) { *headers = new HeaderWithAclList; } if ((fn = ConfigParser::NextToken()) == NULL) { self_destruct(); return; } HeaderWithAcl hwa; hwa.fieldName = fn; hwa.fieldId = httpHeaderIdByNameDef(fn, strlen(fn)); if (hwa.fieldId == HDR_BAD_HDR) hwa.fieldId = HDR_OTHER; Format::Format *nlf = new ::Format::Format("hdrWithAcl"); ConfigParser::EnableMacros(); - String buf = ConfigParser::NextQuotedToken(); + String buf(ConfigParser::NextQuotedToken()); ConfigParser::DisableMacros(); hwa.fieldValue = buf.termedBuf(); hwa.quoted = ConfigParser::LastTokenWasQuoted(); if (hwa.quoted) { if (!nlf->parse(hwa.fieldValue.c_str())) { self_destruct(); return; } hwa.valueFormat = nlf; } else delete nlf; aclParseAclList(LegacyParser, &hwa.aclList, (hwa.fieldName + ':' + hwa.fieldValue).c_str()); (*headers)->push_back(hwa); } static void free_HeaderWithAclList(HeaderWithAclList **header) { if (!(*header)) return; === modified file 'src/cache_manager.cc' --- src/cache_manager.cc 2013-10-25 00:13:46 +0000 +++ src/cache_manager.cc 2013-11-05 11:13:14 +0000 @@ -220,41 +220,41 @@ xstrncpy(request, "index", MAX_URL); } #endif debugs(16, 3, HERE << "MGR request: t=" << t << ", host='" << host << "', request='" << request << "', pos=" << pos << ", password='" << password << "', params='" << params << "'"); Mgr::ActionProfile::Pointer profile = findAction(request); if (!profile) { debugs(16, DBG_IMPORTANT, "CacheManager::ParseUrl: action '" << request << "' not found"); return NULL; } const char *prot = ActionProtection(profile); if (!strcmp(prot, "disabled") || !strcmp(prot, "hidden")) { debugs(16, DBG_IMPORTANT, "CacheManager::ParseUrl: action '" << request << "' is " << prot); return NULL; } Mgr::Command::Pointer cmd = new Mgr::Command; - if (!Mgr::QueryParams::Parse(params, cmd->params.queryParams)) + if (!Mgr::QueryParams::Parse(String(params), cmd->params.queryParams)) return NULL; cmd->profile = profile; cmd->params.httpUri = url; cmd->params.userName = String(); cmd->params.password = password; cmd->params.actionName = request; return cmd; } /// \ingroup CacheManagerInternal /* \ingroup CacheManagerInternal * Decodes the headers needed to perform user authentication and fills * the details into the cachemgrStateData argument */ void CacheManager::ParseHeaders(const HttpRequest * request, Mgr::ActionParams ¶ms) { assert(request); @@ -297,41 +297,41 @@ CacheManager::CheckPassword(const Mgr::Command &cmd) { assert(cmd.profile != NULL); const char *action = cmd.profile->name; char *pwd = PasswdGet(Config.passwd_list, action); debugs(16, 4, "CacheManager::CheckPassword for action " << action); if (pwd == NULL) return cmd.profile->isPwReq; if (strcmp(pwd, "disable") == 0) return 1; if (strcmp(pwd, "none") == 0) return 0; if (!cmd.params.password.size()) return 1; - return cmd.params.password != pwd; + return cmd.params.password != String(pwd); } /** \ingroup CacheManagerAPI * Main entry point in the Cache Manager's activity. Gets called as part * of the forward chain if the right URL is detected there. Initiates * all needed internal work and renders the response. */ void CacheManager::Start(const Comm::ConnectionPointer &client, HttpRequest * request, StoreEntry * entry) { debugs(16, 3, "CacheManager::Start: '" << entry->url() << "'" ); Mgr::Command::Pointer cmd = ParseUrl(entry->url()); if (!cmd) { ErrorState *err = new ErrorState(ERR_INVALID_URL, Http::scNotFound, request); err->url = xstrdup(entry->url()); errorAppendEntry(entry, err); entry->expires = squid_curtime; return; === modified file 'src/client_side.cc' --- src/client_side.cc 2013-11-11 12:09:44 +0000 +++ src/client_side.cc 2013-11-05 11:13:14 +0000 @@ -2787,41 +2787,41 @@ setLogUri (http, urlCanonicalClean(request.getRaw())); request->client_addr = conn->clientConnection->remote; // XXX: remove reuest->client_addr member. #if FOLLOW_X_FORWARDED_FOR // indirect client gets stored here because it is an HTTP header result (from X-Forwarded-For:) // not a details about teh TCP connection itself request->indirect_client_addr = conn->clientConnection->remote; #endif /* FOLLOW_X_FORWARDED_FOR */ request->my_addr = conn->clientConnection->local; request->myportname = conn->port->name; request->http_ver = http_ver; // Link this HttpRequest to ConnStateData relatively early so the following complex handling can use it // TODO: this effectively obsoletes a lot of conn->FOO copying. That needs cleaning up later. request->clientConnectionManager = conn; if (request->header.chunked()) { chunked = true; } else if (request->header.has(HDR_TRANSFER_ENCODING)) { const String te = request->header.getList(HDR_TRANSFER_ENCODING); // HTTP/1.1 requires chunking to be the last encoding if there is one - unsupportedTe = te.size() && te != "identity"; + unsupportedTe = te.size() && te != String("identity"); } // else implied identity coding mustReplyToOptions = (method == Http::METHOD_OPTIONS) && (request->header.getInt64(HDR_MAX_FORWARDS) == 0); if (!urlCheckRequest(request.getRaw()) || mustReplyToOptions || unsupportedTe) { clientStreamNode *node = context->getClientReplyContext(); conn->quitAfterError(request.getRaw()); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); repContext->setReplyToError(ERR_UNSUP_REQ, Http::scNotImplemented, request->method, NULL, conn->clientConnection->remote, request.getRaw(), NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); goto finish; } if (!chunked && !clientIsContentLengthValid(request.getRaw())) { clientStreamNode *node = context->getClientReplyContext(); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); === modified file 'src/errorpage.cc' --- src/errorpage.cc 2013-10-25 00:13:46 +0000 +++ src/errorpage.cc 2013-11-05 11:13:14 +0000 @@ -404,41 +404,41 @@ #endif *dt = xtolower(hdr[pos]); // valid codes only contain A-Z, hyphen (-) and * if (*dt != '-' && *dt != '*' && (*dt < 'a' || *dt > 'z') ) invalid_byte = true; else ++dt; // move to next destination byte. } ++pos; } *dt = '\0'; // nul-terminated the filename content string before system use. ++dt; // if we terminated the tag on garbage or ';' we need to skip to the next ',' or end of header. while (pos < hdr.size() && hdr[pos] != ',') ++pos; if (pos < hdr.size() && hdr[pos] == ',') ++pos; - debugs(4, 9, HERE << "STATE: dt='" << dt << "', lang='" << lang << "', pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : "") << "'"); + debugs(4, 9, "STATE: dt='" << dt << "', lang='" << lang << "', pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : String("")) << "'"); /* if we found anything we might use, try it. */ if (*lang != '\0' && !invalid_byte) return true; } return false; } bool TemplateFile::loadFor(const HttpRequest *request) { String hdr; #if USE_ERR_LOCALES if (loaded()) // already loaded? return true; if (!request || !request->header.getList(HDR_ACCEPT_LANGUAGE, &hdr) ) return false; === modified file 'src/esi/Assign.cc' --- src/esi/Assign.cc 2012-09-01 14:38:36 +0000 +++ src/esi/Assign.cc 2013-11-05 11:13:14 +0000 @@ -78,41 +78,41 @@ varState = cbdataReference(aContext->varState); } void ESIAssign::evaluateVariable() { if (variable.getRaw()) variable->process (false); variable = NULL; if (unevaluatedVariable.size()) { varState->feedData(unevaluatedVariable.rawBuf(), unevaluatedVariable.size()); char const *result = varState->extractChar (); /* Consider activating this, when we want to evaluate variables to a * value */ // setTestResult(ESIExpression::Evaluate (expression)); - value = new ESIVariableExpression (result); + value = new ESIVariableExpression (String(result)); safe_free (result); } } void ESIAssign::provideData (ESISegment::Pointer data, ESIElement * source) { assert (source == variable.getRaw()); char *result = data->listToChar(); unevaluatedVariable = result; safe_free (result); } esiProcessResult_t ESIAssign::process (int dovars) { assert (varState); if (!value) === modified file 'src/fqdncache.cc' --- src/fqdncache.cc 2013-10-01 23:21:17 +0000 +++ src/fqdncache.cc 2013-11-05 11:13:14 +0000 @@ -316,41 +316,41 @@ * * Walks down the pending list, calling handlers */ static void fqdncacheCallback(fqdncache_entry * f, int wait) { FQDNH *callback; void *cbdata; f->lastref = squid_curtime; if (!f->handler) return; fqdncacheLockEntry(f); callback = f->handler; f->handler = NULL; if (cbdataReferenceValidDone(f->handlerData, &cbdata)) { - const DnsLookupDetails details(f->error_message, wait); + const DnsLookupDetails details(String(f->error_message), wait); callback(f->name_count ? f->names[0] : NULL, details, cbdata); } fqdncacheUnlockEntry(f); } /// \ingroup FQDNCacheInternal static int fqdncacheParse(fqdncache_entry *f, const rfc1035_rr * answers, int nr, const char *error_message) { int k; int ttl = 0; const char *name = (const char *)f->hash.key; f->expires = squid_curtime + Config.negativeDnsTtl; f->flags.negcached = true; if (nr < 0) { debugs(35, 3, "fqdncacheParse: Lookup of '" << name << "' failed (" << error_message << ")"); f->error_message = xstrdup(error_message); return -1; @@ -433,41 +433,41 @@ * \param addr IP address of domain to resolve. \param handler A pointer to the function to be called when * the reply from the FQDN cache * (or the DNS if the FQDN cache misses) \param handlerData Information that is passed to the handler * and does not affect the FQDN cache. */ void fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH * handler, void *handlerData) { fqdncache_entry *f = NULL; char name[MAX_IPSTRLEN]; generic_cbdata *c; addr.toStr(name,MAX_IPSTRLEN); debugs(35, 4, "fqdncache_nbgethostbyaddr: Name '" << name << "'."); ++FqdncacheStats.requests; if (name[0] == '\0') { debugs(35, 4, "fqdncache_nbgethostbyaddr: Invalid name!"); - const DnsLookupDetails details("Invalid hostname", -1); // error, no lookup + const DnsLookupDetails details(String("Invalid hostname"), -1); // error, no lookup if (handler) handler(NULL, details, handlerData); return; } f = fqdncache_get(name); if (NULL == f) { /* miss */ (void) 0; } else if (fqdncacheExpiredEntry(f)) { /* hit, but expired -- bummer */ fqdncacheRelease(f); f = NULL; } else { /* hit */ debugs(35, 4, "fqdncache_nbgethostbyaddr: HIT for '" << name << "'"); if (f->flags.negcached) ++ FqdncacheStats.negative_hits; === modified file 'src/ftp.cc' --- src/ftp.cc 2013-10-31 19:13:17 +0000 +++ src/ftp.cc 2013-11-05 11:13:14 +0000 @@ -3700,41 +3700,41 @@ newrep->header.putAuth("Basic", realm); #endif return newrep; } /** \ingroup ServerProtocolFTPAPI \todo Should be a URL class API call. * * Construct an URI with leading / in PATH portion for use by CWD command * possibly others. FTP encodes absolute paths as beginning with '/' * after the initial URI path delimiter, which happens to be / itself. * This makes FTP absolute URI appear as: ftp:host:port//root/path * To encompass older software which compacts multiple // to / in transit * We use standard URI-encoding on the second / making it * ftp:host:port/%2froot/path AKA 'the FTP %2f hack'. */ const char * ftpUrlWith2f(HttpRequest * request) { - String newbuf = "%2f"; + String newbuf("%2f"); if (request->protocol != AnyP::PROTO_FTP) return NULL; if ( request->urlpath[0]=='/' ) { newbuf.append(request->urlpath); request->urlpath.absorb(newbuf); safe_free(request->canonical); } else if ( !strncmp(request->urlpath.termedBuf(), "%2f", 3) ) { newbuf.append(request->urlpath.substr(1,request->urlpath.size())); request->urlpath.absorb(newbuf); safe_free(request->canonical); } return urlCanonical(request); } void FtpStateData::printfReplyBody(const char *fmt, ...) { === modified file 'src/ipc/Coordinator.cc' --- src/ipc/Coordinator.cc 2013-01-21 07:15:09 +0000 +++ src/ipc/Coordinator.cc 2013-11-05 11:13:14 +0000 @@ -11,41 +11,41 @@ #include "comm/Connection.h" #include "ipc/Coordinator.h" #include "ipc/SharedListen.h" #include "mgr/Inquirer.h" #include "mgr/Request.h" #include "mgr/Response.h" #include "tools.h" #if SQUID_SNMP #include "snmp/Inquirer.h" #include "snmp/Request.h" #include "snmp/Response.h" #endif #if HAVE_ERRNO_H #include #endif CBDATA_NAMESPACED_CLASS_INIT(Ipc, Coordinator); Ipc::Coordinator* Ipc::Coordinator::TheInstance = NULL; Ipc::Coordinator::Coordinator(): - Port(coordinatorAddr) + Port(String(coordinatorAddr)) { } void Ipc::Coordinator::start() { Port::start(); } Ipc::StrandCoord* Ipc::Coordinator::findStrand(int kidId) { typedef StrandCoords::iterator SI; for (SI iter = strands_.begin(); iter != strands_.end(); ++iter) { if (iter->kidId == kidId) return &(*iter); } return NULL; } void Ipc::Coordinator::registerStrand(const StrandCoord& strand) { === modified file 'src/ipc/Forwarder.cc' --- src/ipc/Forwarder.cc 2012-09-01 14:38:36 +0000 +++ src/ipc/Forwarder.cc 2013-11-05 11:13:14 +0000 @@ -42,41 +42,41 @@ Ipc::Forwarder::start() { debugs(54, 3, HERE); typedef NullaryMemFunT Dialer; AsyncCall::Pointer callback = JobCallback(54, 5, Dialer, this, Forwarder::handleRemoteAck); if (++LastRequestId == 0) // don't use zero value as request->requestId ++LastRequestId; request->requestId = LastRequestId; TheRequestsMap[request->requestId] = callback; TypedMsgHdr message; try { request->pack(message); } catch (...) { // assume the pack() call failed because the message did not fit // TODO: add a more specific exception? handleError(); } - SendMessage(coordinatorAddr, message); + SendMessage(String(coordinatorAddr), message); eventAdd("Ipc::Forwarder::requestTimedOut", &Forwarder::RequestTimedOut, this, timeout, 0, false); } void Ipc::Forwarder::swanSong() { debugs(54, 5, HERE); removeTimeoutEvent(); if (request->requestId > 0) { DequeueRequest(request->requestId); request->requestId = 0; } cleanup(); } bool Ipc::Forwarder::doneAll() const { debugs(54, 5, HERE); === modified file 'src/ipc/Kids.cc' --- src/ipc/Kids.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/Kids.cc 2013-11-05 11:13:14 +0000 @@ -12,53 +12,53 @@ Kids TheKids; KidName TheKidName; Kids::Kids() { } /// maintain n kids void Kids::init() { if (storage.size() > 0) storage.clean(); storage.reserve(NumberOfKids()); char kid_name[32]; // add Kid records for all workers for (int i = 0; i < Config.workers; ++i) { snprintf(kid_name, sizeof(kid_name), "(squid-%d)", (int)(storage.size()+1)); - storage.push_back(Kid(kid_name)); + storage.push_back(Kid(String(kid_name))); } // add Kid records for all disk processes for (int i = 0; i < Config.cacheSwap.n_strands; ++i) { snprintf(kid_name, sizeof(kid_name), "(squid-disk-%d)", (int)(storage.size()+1)); - storage.push_back(Kid(kid_name)); + storage.push_back(Kid(String(kid_name))); } // if coordination is needed, add a Kid record for Coordinator if (storage.size() > 1) { snprintf(kid_name, sizeof(kid_name), "(squid-coord-%d)", (int)(storage.size()+1)); - storage.push_back(Kid(kid_name)); + storage.push_back(Kid(String(kid_name))); } Must(storage.size() == static_cast(NumberOfKids())); } /// returns kid by pid Kid* Kids::find(pid_t pid) { assert(pid > 0); assert(count() > 0); for (size_t i = 0; i < storage.size(); ++i) { if (storage[i].getPid() == pid) return &storage[i]; } return NULL; } /// returns the kid by index, useful for kids iteration Kid& Kids::get(size_t i) === modified file 'src/ipc/Port.cc' --- src/ipc/Port.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/Port.cc 2013-11-05 11:13:14 +0000 @@ -25,40 +25,40 @@ } void Ipc::Port::doListen() { debugs(54, 6, HERE); buf.prepForReading(); typedef CommCbMemFunT Dialer; AsyncCall::Pointer readHandler = JobCallback(54, 6, Dialer, this, Port::noteRead); comm_read(conn(), buf.raw(), buf.size(), readHandler); } bool Ipc::Port::doneAll() const { return false; // listen forever } String Ipc::Port::MakeAddr(const char* pathAddr, int id) { assert(id >= 0); - String addr = pathAddr; + String addr(pathAddr); addr.append('-'); addr.append(xitoa(id)); addr.append(".ipc"); return addr; } void Ipc::Port::noteRead(const CommIoCbParams& params) { debugs(54, 6, HERE << params.conn << " flag " << params.flag << " [" << this << ']'); if (params.flag == COMM_OK) { assert(params.buf == buf.raw()); receive(buf); } // TODO: if there was a fatal error on our socket, close the socket before // trying to listen again and print a level-1 error message. doListen(); } === modified file 'src/ipc/SharedListen.cc' --- src/ipc/SharedListen.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/SharedListen.cc 2013-11-05 11:13:14 +0000 @@ -100,41 +100,41 @@ hdrMsg.putFd(fd); } void Ipc::JoinSharedListen(const OpenListenerParams ¶ms, AsyncCall::Pointer &callback) { PendingOpenRequest por; por.params = params; por.callback = callback; SharedListenRequest request; request.requestorId = KidIdentifier; request.params = por.params; request.mapId = AddToMap(por); debugs(54, 3, HERE << "getting listening FD for " << request.params.addr << " mapId=" << request.mapId); TypedMsgHdr message; request.pack(message); - SendMessage(coordinatorAddr, message); + SendMessage(String(coordinatorAddr), message); } void Ipc::SharedListenJoined(const SharedListenResponse &response) { // Dont debugs c fully since only FD is filled right now. debugs(54, 3, HERE << "got listening FD " << response.fd << " errNo=" << response.errNo << " mapId=" << response.mapId); Must(TheSharedListenRequestMap.find(response.mapId) != TheSharedListenRequestMap.end()); PendingOpenRequest por = TheSharedListenRequestMap[response.mapId]; Must(por.callback != NULL); TheSharedListenRequestMap.erase(response.mapId); StartListeningCb *cbd = dynamic_cast(por.callback->getDialer()); assert(cbd && cbd->conn != NULL); Must(cbd && cbd->conn != NULL); cbd->conn->fd = response.fd; if (Comm::IsConnOpen(cbd->conn)) { OpenListenerParams &p = por.params; === modified file 'src/ipc/Strand.cc' --- src/ipc/Strand.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/Strand.cc 2013-11-05 11:13:14 +0000 @@ -33,41 +33,41 @@ Ipc::Strand::Strand(): Port(MakeAddr(strandAddrPfx, KidIdentifier)), isRegistered(false) { } void Ipc::Strand::start() { Port::start(); registerSelf(); } void Ipc::Strand::registerSelf() { debugs(54, 6, HERE); Must(!isRegistered); HereIamMessage ann(StrandCoord(KidIdentifier, getpid())); TypedMsgHdr message; ann.pack(message); - SendMessage(coordinatorAddr, message); + SendMessage(String(coordinatorAddr), message); setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable? } void Ipc::Strand::receive(const TypedMsgHdr &message) { debugs(54, 6, HERE << message.type()); switch (message.type()) { case mtRegistration: handleRegistrationResponse(HereIamMessage(message)); break; case mtSharedListenResponse: SharedListenJoined(SharedListenResponse(message)); break; #if USE_DISKIO_IPCIO case mtStrandSearchResponse: IpcIoFile::HandleOpenResponse(StrandSearchResponse(message)); break; === modified file 'src/ipcache.cc' --- src/ipcache.cc 2013-10-25 00:13:46 +0000 +++ src/ipcache.cc 2013-11-05 11:13:14 +0000 @@ -326,41 +326,41 @@ * * walks down the pending list, calling handlers */ static void ipcacheCallback(ipcache_entry *i, int wait) { IPH *callback = i->handler; void *cbdata = NULL; i->lastref = squid_curtime; if (!i->handler) return; ipcacheLockEntry(i); callback = i->handler; i->handler = NULL; if (cbdataReferenceValidDone(i->handlerData, &cbdata)) { - const DnsLookupDetails details(i->error_message, wait); + const DnsLookupDetails details(String(i->error_message), wait); callback((i->addrs.count ? &i->addrs : NULL), details, cbdata); } ipcacheUnlockEntry(i); } /// \ingroup IPCacheAPI static int ipcacheParse(ipcache_entry *i, const rfc1035_rr * answers, int nr, const char *error_message) { int k; int j = 0; int na = 0; int ttl = 0; const char *name = (const char *)i->hash.key; int cname_found = 0; i->expires = squid_curtime + Config.negativeDnsTtl; i->flags.negcached = true; safe_free(i->addrs.in_addrs); @@ -509,50 +509,50 @@ * XXX: on hits and some errors, the handler is called immediately instead * of scheduling an async call. This reentrant behavior means that the * user job must be extra careful after calling ipcache_nbgethostbyname, * especially if the handler destroys the job. Moreover, the job has * no way of knowing whether the reentrant call happened. * Comm::Connection setup usually protects the job by scheduling an async call, * but some user code calls ipcache_nbgethostbyname directly. */ void ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData) { ipcache_entry *i = NULL; const ipcache_addrs *addrs = NULL; generic_cbdata *c; debugs(14, 4, "ipcache_nbgethostbyname: Name '" << name << "'."); ++IpcacheStats.requests; if (name == NULL || name[0] == '\0') { debugs(14, 4, "ipcache_nbgethostbyname: Invalid name!"); ++IpcacheStats.invalid; - const DnsLookupDetails details("Invalid hostname", -1); // error, no lookup + const DnsLookupDetails details(String("Invalid hostname"), -1); // error, no lookup if (handler) handler(NULL, details, handlerData); return; } if ((addrs = ipcacheCheckNumeric(name))) { debugs(14, 4, "ipcache_nbgethostbyname: BYPASS for '" << name << "' (already numeric)"); ++IpcacheStats.numeric_hits; - const DnsLookupDetails details(NULL, -1); // no error, no lookup + const DnsLookupDetails details(String(NULL), -1); // no error, no lookup if (handler) handler(addrs, details, handlerData); return; } i = ipcache_get(name); if (NULL == i) { /* miss */ (void) 0; } else if (ipcacheExpiredEntry(i)) { /* hit, but expired -- bummer */ ipcacheRelease(i); i = NULL; } else { /* hit */ debugs(14, 4, "ipcache_nbgethostbyname: HIT for '" << name << "'"); if (i->flags.negcached) ++IpcacheStats.negative_hits; === modified file 'src/mgr/Action.cc' --- src/mgr/Action.cc 2013-10-25 00:13:46 +0000 +++ src/mgr/Action.cc 2013-11-05 11:13:14 +0000 @@ -62,41 +62,41 @@ void Mgr::Action::respond(const Request& request) { debugs(16, 5, HERE); // Assume most kid classes are fully aggregatable (i.e., they do not dump // local info at all). Do not import the remote HTTP fd into our Comm // space; collect and send an IPC msg with collected info to Coordinator. ::close(request.conn->fd); request.conn->fd = -1; collect(); sendResponse(request.requestId); } void Mgr::Action::sendResponse(unsigned int requestId) { Response response(requestId, this); Ipc::TypedMsgHdr message; response.pack(message); - Ipc::SendMessage(Ipc::coordinatorAddr, message); + Ipc::SendMessage(String(Ipc::coordinatorAddr), message); } void Mgr::Action::run(StoreEntry* entry, bool writeHttpHeader) { debugs(16, 5, HERE); collect(); fillEntry(entry, writeHttpHeader); } void Mgr::Action::fillEntry(StoreEntry* entry, bool writeHttpHeader) { debugs(16, 5, HERE); entry->buffer(); if (writeHttpHeader) { HttpReply *rep = new HttpReply; rep->setHeaders(Http::scOkay, NULL, "text/plain", -1, squid_curtime, squid_curtime); // Allow cachemgr and other XHR scripts access to our version string === modified file 'src/mgr/Inquirer.cc' --- src/mgr/Inquirer.cc 2013-10-25 00:13:46 +0000 +++ src/mgr/Inquirer.cc 2013-11-05 11:13:14 +0000 @@ -134,42 +134,42 @@ Mgr::Inquirer::sendResponse() { if (!strands.empty() && aggrAction->aggregatable()) { removeCloseHandler(); AsyncJob::Start(new ActionWriter(aggrAction, conn)); conn = NULL; // should not close because we passed it to ActionWriter } } bool Mgr::Inquirer::doneAll() const { return !writer && Ipc::Inquirer::doneAll(); } Ipc::StrandCoords Mgr::Inquirer::applyQueryParams(const Ipc::StrandCoords& aStrands, const QueryParams& aParams) { Ipc::StrandCoords sc; - QueryParam::Pointer processesParam = aParams.get("processes"); - QueryParam::Pointer workersParam = aParams.get("workers"); + QueryParam::Pointer processesParam = aParams.get(String("processes")); + QueryParam::Pointer workersParam = aParams.get(String("workers")); if (processesParam == NULL || workersParam == NULL) { if (processesParam != NULL) { IntParam* param = dynamic_cast(processesParam.getRaw()); if (param != NULL && param->type == QueryParam::ptInt) { const std::vector& processes = param->value(); for (Ipc::StrandCoords::const_iterator iter = aStrands.begin(); iter != aStrands.end(); ++iter) { if (std::find(processes.begin(), processes.end(), iter->kidId) != processes.end()) sc.push_back(*iter); } } } else if (workersParam != NULL) { IntParam* param = dynamic_cast(workersParam.getRaw()); if (param != NULL && param->type == QueryParam::ptInt) { const std::vector& workers = param->value(); for (int i = 0; i < (int)aStrands.size(); ++i) { if (std::find(workers.begin(), workers.end(), i + 1) != workers.end()) sc.push_back(aStrands[i]); } === modified file 'src/mgr/Response.cc' --- src/mgr/Response.cc 2012-09-01 14:38:36 +0000 +++ src/mgr/Response.cc 2013-11-05 11:13:14 +0000 @@ -29,41 +29,41 @@ msg.checkType(Ipc::mtCacheMgrResponse); msg.getPod(requestId); Must(requestId != 0); if (msg.hasMoreData()) { String actionName; msg.getString(actionName); action = CacheManager::GetInstance()->createNamedAction(actionName.termedBuf()); Must(hasAction()); action->unpack(msg); } } void Mgr::Response::pack(Ipc::TypedMsgHdr& msg) const { Must(requestId != 0); msg.setType(Ipc::mtCacheMgrResponse); msg.putPod(requestId); if (hasAction()) { - msg.putString(action->name()); + msg.putString(String(action->name())); action->pack(msg); } } Ipc::Response::Pointer Mgr::Response::clone() const { return new Response(*this); } bool Mgr::Response::hasAction() const { return action != NULL; } const Mgr::Action& Mgr::Response::getAction() const { Must(hasAction()); === modified file 'src/snmp/Forwarder.cc' --- src/snmp/Forwarder.cc 2013-10-25 00:13:46 +0000 +++ src/snmp/Forwarder.cc 2013-11-05 11:13:14 +0000 @@ -84,22 +84,22 @@ void Snmp::SendResponse(unsigned int requestId, const Pdu& pdu) { debugs(49, 5, HERE); // snmpAgentResponse() can modify arg Pdu tmp = pdu; Snmp::Response response(requestId); snmp_pdu* response_pdu = NULL; try { response_pdu = snmpAgentResponse(&tmp); Must(response_pdu != NULL); response.pdu = static_cast(*response_pdu); snmp_free_pdu(response_pdu); } catch (const std::exception& e) { debugs(49, DBG_CRITICAL, HERE << e.what()); response.pdu.command = SNMP_PDU_RESPONSE; response.pdu.errstat = SNMP_ERR_GENERR; } Ipc::TypedMsgHdr message; response.pack(message); - Ipc::SendMessage(Ipc::coordinatorAddr, message); + Ipc::SendMessage(String(Ipc::coordinatorAddr), message); } === modified file 'src/stat.cc' --- src/stat.cc 2013-10-25 00:13:46 +0000 +++ src/stat.cc 2013-11-05 11:13:14 +0000 @@ -420,41 +420,41 @@ continue; statStoreEntry(&mb, e); } if (mb.size) state->sentry->append(mb.buf, mb.size); mb.clean(); eventAdd("statObjects", statObjects, state, 0.0, 1); } static void statObjectsStart(StoreEntry * sentry, STOBJFLT * filter) { StatObjectsState *state = new StatObjectsState; state->sentry = sentry; state->filter = filter; sentry->lock(); - state->theSearch = Store::Root().search(NULL, NULL); + state->theSearch = Store::Root().search(String(NULL), NULL); eventAdd("statObjects", statObjects, state, 0.0, 1); } static void stat_objects_get(StoreEntry * sentry) { statObjectsStart(sentry, NULL); } static int statObjectsVmFilter(const StoreEntry * e) { return e->mem_obj ? 1 : 0; } static void stat_vmobjects_get(StoreEntry * sentry) { statObjectsStart(sentry, statObjectsVmFilter); === modified file 'src/store_digest.cc' --- src/store_digest.cc 2013-03-16 04:57:43 +0000 +++ src/store_digest.cc 2013-11-05 11:13:14 +0000 @@ -308,41 +308,41 @@ return; } sd_state.rebuild_lock = 1; debugs(71, 2, "storeDigestRebuildStart: rebuild #" << sd_state.rebuild_count + 1); if (sd_state.rewrite_lock) { debugs(71, 2, "storeDigestRebuildStart: waiting for Rewrite to finish."); return; } storeDigestRebuildResume(); } /* called be Rewrite to push Rebuild forward */ static void storeDigestRebuildResume(void) { assert(sd_state.rebuild_lock); assert(!sd_state.rewrite_lock); - sd_state.theSearch = Store::Root().search(NULL, NULL); + sd_state.theSearch = Store::Root().search(String(NULL), NULL); /* resize or clear */ if (!storeDigestResize()) cacheDigestClear(store_digest); /* not clean()! */ memset(&sd_stats, 0, sizeof(sd_stats)); eventAdd("storeDigestRebuildStep", storeDigestRebuildStep, NULL, 0.0, 1); } /* finishes swap out sequence for the digest; schedules next rebuild */ static void storeDigestRebuildFinish(void) { assert(sd_state.rebuild_lock); sd_state.rebuild_lock = 0; ++sd_state.rebuild_count; debugs(71, 2, "storeDigestRebuildFinish: done."); eventAdd("storeDigestRebuildStart", storeDigestRebuildStart, NULL, (double) Config.digest.rebuild_period, 1); === modified file 'src/store_log.cc' --- src/store_log.cc 2013-10-31 19:13:17 +0000 +++ src/store_log.cc 2013-11-05 11:13:14 +0000 @@ -66,41 +66,41 @@ str_unknown="unknown"; //hack. Delay initialization as string doesn't support global variables.. if (NULL == storelog) return; ++storeLogTagsCounts[tag]; if (mem != NULL) { if (mem->log_url == NULL) { debugs(20, DBG_IMPORTANT, "storeLog: NULL log_url for " << mem->url); mem->dump(); mem->log_url = xstrdup(mem->url); } reply = e->getReply(); /* * XXX Ok, where should we print the dir number here? * Because if we print it before the swap file number, it'll break * the existing log format. */ - String ctype=(reply->content_type.size() ? reply->content_type.termedBuf() : str_unknown); + String ctype(reply->content_type.size() ? reply->content_type : str_unknown); logfileLineStart(storelog); logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d " SQUIDSTRINGPH " %" PRId64 "/%" PRId64 " %s %s\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], e->swap_dirn, e->swap_filen, e->getMD5Text(), reply->sline.status(), (int) reply->date, (int) reply->last_modified, (int) reply->expires, SQUIDSTRINGPRINT(ctype), reply->content_length, e->contentLen(), RequestMethodStr(mem->method), mem->log_url); logfileLineEnd(storelog); } else { === modified file 'src/store_rebuild.cc' --- src/store_rebuild.cc 2013-10-25 00:13:46 +0000 +++ src/store_rebuild.cc 2013-11-05 11:13:14 +0000 @@ -59,41 +59,41 @@ int scanned; } store_rebuild_progress; static store_rebuild_progress *RebuildProgress = NULL; static int storeCleanupDoubleCheck(StoreEntry * e) { SwapDir *SD = dynamic_cast(INDEXSD(e->swap_dirn)); return (SD->doubleCheck(*e)); } static void storeCleanup(void *datanotused) { static int store_errors = 0; static StoreSearchPointer currentSearch; static int validated = 0; if (currentSearch == NULL || currentSearch->isDone()) - currentSearch = Store::Root().search(NULL, NULL); + currentSearch = Store::Root().search(String(NULL), NULL); size_t statCount = 500; // TODO: Avoid the loop (and ENTRY_VALIDATED) unless opt_store_doublecheck. while (statCount-- && !currentSearch->isDone() && currentSearch->next()) { StoreEntry *e; e = currentSearch->currentItem(); if (EBIT_TEST(e->flags, ENTRY_VALIDATED)) continue; /* * Calling StoreEntry->release() has no effect because we're * still in 'store_rebuilding' state */ if (e->swap_filen < 0) continue; if (opt_store_doublecheck) === modified file 'src/tests/stub_Port.cc' --- src/tests/stub_Port.cc 2012-01-20 18:55:04 +0000 +++ src/tests/stub_Port.cc 2013-11-05 11:13:14 +0000 @@ -1,10 +1,10 @@ #include "squid.h" #include "ipc/Port.h" #define STUB_API "ipc/Port.cc" #include "tests/STUB.h" const char Ipc::coordinatorAddr[] = ""; const char Ipc::strandAddrPfx[] = ""; -String Ipc::Port::MakeAddr(char const*, int) STUB_RETVAL("") +String Ipc::Port::MakeAddr(char const*, int) STUB_RETVAL(String("")) === modified file 'src/tests/testConfigParser.cc' --- src/tests/testConfigParser.cc 2013-11-19 01:12:54 +0000 +++ src/tests/testConfigParser.cc 2013-11-19 11:55:24 +0000 @@ -12,41 +12,41 @@ void eventAdd(const char *name, EVH * func, void *arg, double when, int, bool cbdata) {} void testConfigParser::setUp() { } bool testConfigParser::doParseQuotedTest(const char *s, const char *expectInterp) { char cfgline[2048]; char cfgparam[2048]; snprintf(cfgline, 2048, "%s", s); // Keep the initial value on cfgparam. The ConfigParser methods will write on cfgline strncpy(cfgparam, cfgline, sizeof(cfgparam)-1); cfgparam[sizeof(cfgparam)-1] = '\0'; // Initialize parser to point to the start of quoted string ConfigParser::SetCfgLine(cfgline); - String unEscaped = ConfigParser::NextToken(); + String unEscaped(ConfigParser::NextToken()); const bool interpOk = (unEscaped.cmp(expectInterp) == 0); if (!interpOk) { printf("%25s: %s\n%25s: %s\n%25s: %s\n", "Raw configuration", cfgparam, "Expected interpretation", expectInterp, "Actual interpretation", unEscaped.termedBuf()); } const char *quoted = ConfigParser::QuoteString(unEscaped); bool quotedOk = (strcmp(cfgparam, quoted)==0); if (!quotedOk) { printf("%25s: %s\n%25s: %s\n%25s: %s\n", "Raw configuration", cfgparam, "Parsed and quoted", quoted, "parsed value was", unEscaped.termedBuf()); } return quotedOk && interpOk ; } === modified file 'src/tests/testEvent.cc' --- src/tests/testEvent.cc 2012-08-31 16:57:39 +0000 +++ src/tests/testEvent.cc 2013-11-05 11:13:14 +0000 @@ -51,45 +51,45 @@ CalledEvent event; CalledEvent event_to_cancel; scheduler.schedule("test event", CalledEvent::Handler, &event, 0, 0, false); scheduler.schedule("test event2", CalledEvent::Handler, &event_to_cancel, 0, 0, false); scheduler.cancel(CalledEvent::Handler, &event_to_cancel); scheduler.checkEvents(0); AsyncCallQueue::Instance().fire(); CPPUNIT_ASSERT_EQUAL(1, event.calls); CPPUNIT_ASSERT_EQUAL(0, event_to_cancel.calls); } /* submit two callbacks, and then dump the queue. */ void testEvent::testDump() { EventScheduler scheduler; CalledEvent event; CalledEvent event2; CapturingStoreEntry * anEntry = new CapturingStoreEntry(); - String expect = "Last event to run: last event\n" - "\n" - "Operation \tNext Execution \tWeight\tCallback Valid?\n" - "test event \t0.000 sec\t 0\t N/A\n" - "test event2 \t0.000 sec\t 0\t N/A\n"; + String expect("Last event to run: last event\n" + "\n" + "Operation \tNext Execution \tWeight\tCallback Valid?\n" + "test event \t0.000 sec\t 0\t N/A\n" + "test event2 \t0.000 sec\t 0\t N/A\n"); scheduler.schedule("last event", CalledEvent::Handler, &event, 0, 0, false); /* schedule and dispatch to set the last run event */ scheduler.checkEvents(0); AsyncCallQueue::Instance().fire(); scheduler.schedule("test event", CalledEvent::Handler, &event, 0, 0, false); scheduler.schedule("test event2", CalledEvent::Handler, &event2, 0, 0, false); scheduler.dump(anEntry); /* loop over the strings, showing exactly where they differ (if at all) */ printf("Actual Text:\n"); /* TODO: these should really be just [] lookups, but String doesn't have those here yet. */ for ( unsigned int i = 0; i < anEntry->_appended_text.size(); ++i) { CPPUNIT_ASSERT( expect[i] ); CPPUNIT_ASSERT( anEntry->_appended_text[i] ); /* slight hack to make special chars visible */ switch (anEntry->_appended_text[i]) { case '\t': === modified file 'src/tests/testSBuf.cc' --- src/tests/testSBuf.cc 2013-10-25 00:13:46 +0000 +++ src/tests/testSBuf.cc 2013-10-29 19:57:27 +0000 @@ -88,47 +88,40 @@ } // TEST: check that COW doesn't happen upon copy-construction { SBuf s1(empty_sbuf), s2(s1); CPPUNIT_ASSERT_EQUAL(s1.rawContent(), s2.rawContent()); SBuf s3(literal), s4(literal); CPPUNIT_ASSERT_EQUAL(s3.rawContent(), s4.rawContent()); } // TEST: sub-string copy { SBuf s1=SBuf(fox+4), s2(fox); SBuf s3=s2.substr(4,s2.length()); //n is out-of-bounds CPPUNIT_ASSERT_EQUAL(s1,s3); SBuf s4=SBuf(fox,4); s3=s2.substr(0,4); CPPUNIT_ASSERT_EQUAL(s4,s3); } - // TEST: go via SquidString adapters. - { - String str(fox); - SBuf s1(str); - CPPUNIT_ASSERT_EQUAL(literal,s1); - } - // TEST: go via std::string adapter. { std::string str(fox); SBuf s1(str); CPPUNIT_ASSERT_EQUAL(literal,s1); } } void testSBuf::testSBufConstructDestructAfterMemInit() { Mem::Init(); testSBufConstructDestruct(); } void testSBuf::testEqualityTest() { SBuf s1(fox),s2(fox); CPPUNIT_ASSERT_EQUAL(s1,s1); //self-equality === modified file 'src/tests/testStoreController.cc' --- src/tests/testStoreController.cc 2013-11-18 17:03:55 +0000 +++ src/tests/testStoreController.cc 2013-11-19 11:55:24 +0000 @@ -118,43 +118,43 @@ static bool cbcalled; static void searchCallback(void *cbdata) { cbcalled = true; } void testStoreController::testSearch() { commonInit(); StorePointer aRoot (new StoreController()); Store::Root(aRoot); TestSwapDirPointer aStore (new TestSwapDir); TestSwapDirPointer aStore2 (new TestSwapDir); addSwapDir(aStore); addSwapDir(aStore2); Store::Root().init(); - StoreEntry * entry1 = addedEntry (&Store::Root(), aStore.getRaw(), "name", NULL, NULL); - StoreEntry * entry2 = addedEntry (&Store::Root(), aStore2.getRaw(), "name2", NULL, NULL); - StoreSearchPointer search = aRoot->search (NULL, NULL); /* search for everything in the store */ + StoreEntry * entry1 = addedEntry (&Store::Root(), aStore.getRaw(), String("name"), String(NULL), String(NULL)); + StoreEntry * entry2 = addedEntry (&Store::Root(), aStore2.getRaw(), String("name2"), String(NULL), String(NULL)); + StoreSearchPointer search = aRoot->search (String(NULL), NULL); /* search for everything in the store */ /* nothing should be immediately available */ CPPUNIT_ASSERT_EQUAL(false, search->error()); CPPUNIT_ASSERT_EQUAL(false, search->isDone()); CPPUNIT_ASSERT_EQUAL(static_cast(NULL), search->currentItem()); #if 0 CPPUNIT_ASSERT_EQUAL(false, search->next()); #endif /* trigger a callback */ cbcalled = false; search->next(searchCallback, NULL); CPPUNIT_ASSERT_EQUAL(true, cbcalled); /* we should have access to a entry now, that matches the entry we had before */ CPPUNIT_ASSERT_EQUAL(false, search->error()); CPPUNIT_ASSERT_EQUAL(false, search->isDone()); /* note the hash order is random - the test happens to be in a nice order */ CPPUNIT_ASSERT_EQUAL(entry1, search->currentItem()); === modified file 'src/tests/testStoreHashIndex.cc' --- src/tests/testStoreHashIndex.cc 2013-11-18 17:03:55 +0000 +++ src/tests/testStoreHashIndex.cc 2013-11-19 11:55:24 +0000 @@ -115,43 +115,43 @@ static bool cbcalled; static void searchCallback(void *cbdata) { cbcalled = true; } void testStoreHashIndex::testSearch() { commonInit(); StorePointer aRoot (new StoreHashIndex()); Store::Root(aRoot); TestSwapDirPointer aStore (new TestSwapDir); TestSwapDirPointer aStore2 (new TestSwapDir); addSwapDir(aStore); addSwapDir(aStore2); Store::Root().init(); - StoreEntry * entry1 = addedEntry (&Store::Root(), aStore.getRaw(), "name", NULL, NULL); - StoreEntry * entry2 = addedEntry (&Store::Root(), aStore2.getRaw(), "name2", NULL, NULL); - StoreSearchPointer search = aRoot->search (NULL, NULL); /* search for everything in the store */ + StoreEntry * entry1 = addedEntry (&Store::Root(), aStore.getRaw(), String("name"), String(NULL), String(NULL)); + StoreEntry * entry2 = addedEntry (&Store::Root(), aStore2.getRaw(), String("name2"), String(NULL), String(NULL)); + StoreSearchPointer search = aRoot->search (String(NULL), NULL); /* search for everything in the store */ /* nothing should be immediately available */ CPPUNIT_ASSERT_EQUAL(false, search->error()); CPPUNIT_ASSERT_EQUAL(false, search->isDone()); CPPUNIT_ASSERT_EQUAL(static_cast(NULL), search->currentItem()); #if 0 CPPUNIT_ASSERT_EQUAL(false, search->next()); #endif /* trigger a callback */ cbcalled = false; search->next(searchCallback, NULL); CPPUNIT_ASSERT_EQUAL(true, cbcalled); /* we should have access to a entry now, that matches the entry we had before */ CPPUNIT_ASSERT_EQUAL(false, search->error()); CPPUNIT_ASSERT_EQUAL(false, search->isDone()); /* note the hash order is random - the test happens to be in a nice order */ CPPUNIT_ASSERT_EQUAL(entry1, search->currentItem()); === modified file 'src/tests/testString.cc' --- src/tests/testString.cc 2013-10-25 00:13:46 +0000 +++ src/tests/testString.cc 2013-11-05 11:13:14 +0000 @@ -14,53 +14,61 @@ {} /* init memory pools */ void testString::setUp() { Mem::Init(); } void testString::testCmpDefault() { String left, right; /* two default strings are equal */ CPPUNIT_ASSERT(!left.cmp(right)); CPPUNIT_ASSERT(!left.cmp(NULL)); CPPUNIT_ASSERT(!left.cmp(NULL, 1)); } +#include void testString::testCmpEmptyString() { String left(""); String right; /* an empty string ("") is equal to a default string */ - CPPUNIT_ASSERT(!left.cmp(right)); - CPPUNIT_ASSERT(!left.cmp(NULL)); - CPPUNIT_ASSERT(!left.cmp(NULL, 1)); + std::cerr << 1 << std::endl; + CPPUNIT_ASSERT_EQUAL(0,left.cmp(right)); + std::cerr << 2 << std::endl; + CPPUNIT_ASSERT_EQUAL(0,left.cmp(NULL)); + std::cerr << 3 << std::endl; + CPPUNIT_ASSERT_EQUAL(0,left.cmp(NULL, 1)); /* reverse the order to catch corners */ - CPPUNIT_ASSERT(!right.cmp(left)); - CPPUNIT_ASSERT(!right.cmp("")); - CPPUNIT_ASSERT(!right.cmp("", 1)); + std::cerr << 4 << std::endl; + CPPUNIT_ASSERT_EQUAL(0,right.cmp(left)); + std::cerr << 5 << std::endl; + CPPUNIT_ASSERT_EQUAL(0,right.cmp("")); + std::cerr << 6 << std::endl; + CPPUNIT_ASSERT_EQUAL(0,right.cmp("", 1)); + std::cerr << 7 << std::endl; } void testString::testCmpNotEmptyDefault() { String left("foo"); String right; /* empty string sorts before everything */ CPPUNIT_ASSERT(left.cmp(right) > 0); CPPUNIT_ASSERT(left.cmp(NULL) > 0); CPPUNIT_ASSERT(left.cmp(NULL, 1) > 0); /* reverse for symmetry tests */ CPPUNIT_ASSERT(right.cmp(left) < 0); CPPUNIT_ASSERT(right.cmp("foo") < 0); CPPUNIT_ASSERT(right.cmp("foo", 1) < 0); } void testString::testSubstr() { String s("0123456789"); === modified file 'src/tests/testUfs.cc' --- src/tests/testUfs.cc 2013-11-18 17:03:55 +0000 +++ src/tests/testUfs.cc 2013-11-19 11:55:24 +0000 @@ -156,41 +156,41 @@ Packer p; packerToStoreInit(&p, pe); pe->getReply()->packHeadersInto(&p); packerClean(&p); } pe->flush(); pe->timestampsSet(); pe->complete(); pe->swapOut(); CPPUNIT_ASSERT_EQUAL(0, pe->swap_dirn); CPPUNIT_ASSERT_EQUAL(0, pe->swap_filen); pe->unlock(); } storeDirWriteCleanLogs(0); /* here we cheat: we know that UFSSwapDirs search off disk. If we did an init call to a new * swapdir instance, we'd not be testing a clean build. */ - StoreSearchPointer search = aStore->search (NULL, NULL); /* search for everything in the store */ + StoreSearchPointer search = aStore->search (String(NULL), NULL); /* search for everything in the store */ /* nothing should be immediately available */ #if 0 CPPUNIT_ASSERT_EQUAL(false, search->next()); #endif CPPUNIT_ASSERT_EQUAL(false, search->error()); CPPUNIT_ASSERT_EQUAL(false, search->isDone()); CPPUNIT_ASSERT_EQUAL(static_cast(NULL), search->currentItem()); /* trigger a callback */ cbcalled = false; search->next(searchCallback, NULL); CPPUNIT_ASSERT_EQUAL(true, cbcalled); /* we should have access to a entry now, that matches the entry we had before */ //CPPUNIT_ASSERT_EQUAL(false, search->next()); CPPUNIT_ASSERT_EQUAL(false, search->error()); CPPUNIT_ASSERT_EQUAL(false, search->isDone()); === modified file 'src/tools.cc' --- src/tools.cc 2013-10-25 00:13:46 +0000 +++ src/tools.cc 2013-11-05 11:13:14 +0000 @@ -801,41 +801,41 @@ } int NumberOfKids() { // no kids in no-daemon mode if (!InDaemonMode()) return 0; // XXX: detect and abort when called before workers/cache_dirs are parsed const int rockDirs = Config.cacheSwap.n_strands; const bool needCoord = Config.workers > 1 || rockDirs > 0; return (needCoord ? 1 : 0) + Config.workers + rockDirs; } String ProcessRoles() { - String roles = ""; + String roles(""); if (IamMasterProcess()) roles.append(" master"); if (IamCoordinatorProcess()) roles.append(" coordinator"); if (IamWorkerProcess()) roles.append(" worker"); if (IamDiskProcess()) roles.append(" disker"); return roles; } void writePidFile(void) { int fd; const char *f = NULL; mode_t old_umask; char buf[32]; if (!IamPrimaryProcess()) === modified file 'src/url.cc' --- src/url.cc 2012-12-27 17:58:29 +0000 +++ src/url.cc 2013-11-05 11:13:14 +0000 @@ -808,41 +808,41 @@ urlCheckRequest(const HttpRequest * r) { int rc = 0; /* protocol "independent" methods * * actually these methods are specific to HTTP: * they are methods we recieve on our HTTP port, * and if we had a FTP listener would not be relevant * there. * * So, we should delegate them to HTTP. The problem is that we * do not have a default protocol from the client side of HTTP. */ if (r->method == Http::METHOD_CONNECT) return 1; // we support OPTIONS and TRACE directed at us (with a 501 reply, for now) // we also support forwarding OPTIONS and TRACE, except for the *-URI ones if (r->method == Http::METHOD_OPTIONS || r->method == Http::METHOD_TRACE) - return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || r->urlpath != "*"); + return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || r->urlpath != String("*")); if (r->method == Http::METHOD_PURGE) return 1; /* does method match the protocol? */ switch (r->protocol) { case AnyP::PROTO_URN: case AnyP::PROTO_HTTP: case AnyP::PROTO_CACHE_OBJECT: rc = 1; break; case AnyP::PROTO_FTP: if (r->method == Http::METHOD_PUT) rc = 1;