]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polished to address squid-dev review comments.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 28 Apr 2014 20:30:43 +0000 (14:30 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 28 Apr 2014 20:30:43 +0000 (14:30 -0600)
src/DiskIO/IpcIo/IpcIoFile.cc
src/Store.h
src/store.cc
src/tests/stub_store.cc

index 87902ee893042fd6f05adaa35925141d635ea73d..c724d982e32cc8362ce57c1448490ade2f7da3f2 100644 (file)
@@ -18,6 +18,7 @@
 #include "ipc/Queue.h"
 #include "ipc/StrandSearch.h"
 #include "ipc/UdsOp.h"
+#include "SBuf.h"
 #include "SquidConfig.h"
 #include "SquidTime.h"
 #include "StatCounters.h"
@@ -43,8 +44,8 @@ std::auto_ptr<IpcIoFile::Queue> IpcIoFile::queue;
 
 bool IpcIoFile::DiskerHandleMoreRequestsScheduled = false;
 
-static bool DiskerOpen(const String &path, int flags, mode_t mode);
-static void DiskerClose(const String &path);
+static bool DiskerOpen(const SBuf &path, int flags, mode_t mode);
+static void DiskerClose(const SBuf &path);
 
 /// IpcIo wrapper for debugs() streams; XXX: find a better class name
 struct SipcIo {
@@ -98,7 +99,7 @@ IpcIoFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
         queue.reset(new Queue(ShmLabel, IamWorkerProcess() ? Queue::groupA : Queue::groupB, KidIdentifier));
 
     if (IamDiskProcess()) {
-        error_ = !DiskerOpen(dbName, flags, mode);
+        error_ = !DiskerOpen(SBuf(dbName.termedBuf()), flags, mode);
         if (error_)
             return;
 
@@ -177,7 +178,7 @@ IpcIoFile::close()
     assert(ioRequestor != NULL);
 
     if (IamDiskProcess())
-        DiskerClose(dbName);
+        DiskerClose(SBuf(dbName.termedBuf()));
     // XXX: else nothing to do?
 
     ioRequestor->closeCompleted();
@@ -636,7 +637,7 @@ IpcIoPendingRequest::completeIo(IpcIoMsg *const response)
 
 /* XXX: disker code that should probably be moved elsewhere */
 
-static String DbName; ///< full db file name
+static SBuf DbName; ///< full db file name
 static int TheFile = -1; ///< db file descriptor
 
 static void
@@ -884,12 +885,12 @@ IpcIoFile::DiskerHandleRequest(const int workerId, IpcIoMsg &ipcIo)
 }
 
 static bool
-DiskerOpen(const String &path, int flags, mode_t mode)
+DiskerOpen(const SBuf &path, int flags, mode_t mode)
 {
     assert(TheFile < 0);
 
     DbName = path;
-    TheFile = file_open(DbName.termedBuf(), flags);
+    TheFile = file_open(DbName.c_str(), flags);
 
     if (TheFile < 0) {
         const int xerrno = errno;
@@ -899,12 +900,12 @@ DiskerOpen(const String &path, int flags, mode_t mode)
     }
 
     ++store_open_disk_fd;
-    debugs(79,3, HERE << "rock db opened " << DbName << ": FD " << TheFile);
+    debugs(79,3, "rock db opened " << DbName << ": FD " << TheFile);
     return true;
 }
 
 static void
-DiskerClose(const String &path)
+DiskerClose(const SBuf &path)
 {
     if (TheFile >= 0) {
         file_close(TheFile);
@@ -912,7 +913,7 @@ DiskerClose(const String &path)
         TheFile = -1;
         --store_open_disk_fd;
     }
-    DbName.clean();
+    DbName.clear();
 }
 
 /// reports our needs for shared memory pages to Ipc::Mem::Pages
index 6a4c191c2bf287b9b1d58399c5548b3d82df752c..a48d7d584cbfe26352f85929929bbf56cb0842ef 100644 (file)
@@ -120,10 +120,10 @@ public:
     bool swappingOut() const { return swap_status == SWAPOUT_WRITING; }
     void swapOutFileClose(int how);
     const char *url() const;
-    /// generally cachable (checks agnostic to disk/RAM-specific requirements)
-    /// common part of mayStartSwapOut() and memoryCachable()
-    /// TODO: Make private so only those two methods can call this.
-    int checkCachable();
+    /// Satisfies cachability requirements shared among disk and RAM caches.
+    /// Encapsulates common checks of mayStartSwapOut() and memoryCachable().
+    /// TODO: Rename and make private so only those two methods can call this.
+    bool checkCachable();
     int checkNegativeHit() const;
     int locked() const;
     int validToSend() const;
index 206e28d86ffeb1ca20b07a917d113ba67e01cbd3..62371cbdd39cedb16347da4a07b2a45d3b8775e1 100644 (file)
@@ -950,7 +950,7 @@ StoreEntry::checkTooSmall()
 }
 
 // TODO: move "too many open..." checks outside -- we are called too early/late
-int
+bool
 StoreEntry::checkCachable()
 {
     // XXX: This method is used for both memory and disk caches, but some
index fd2bb4819a7972c8320242f941fe4784ee021ac1..930653697e1b00c6d8105a6509de0324192be597 100644 (file)
@@ -46,7 +46,7 @@ void StoreEntry::purgeMem() STUB
 void StoreEntry::swapOut() STUB
 void StoreEntry::swapOutFileClose(int how) STUB
 const char *StoreEntry::url() const STUB_RETVAL(NULL)
-int StoreEntry::checkCachable() STUB_RETVAL(0)
+bool StoreEntry::checkCachable() STUB_RETVAL(0)
 int StoreEntry::checkNegativeHit() const STUB_RETVAL(0)
 int StoreEntry::locked() const STUB_RETVAL(0)
 int StoreEntry::validToSend() const STUB_RETVAL(0)