]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DiskIO/Blocking/BlockingFile.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / DiskIO / Blocking / BlockingFile.cc
index 66d2ca483d02f298aad7f0461e611bd0d15954c6..fd92024a48cc55d9938c436edf0c2bf0abe8bd20 100644 (file)
@@ -1,6 +1,5 @@
-
 /*
- * $Id: BlockingFile.cc,v 1.2 2004/12/21 17:28:29 robertc Exp $
+ * $Id$
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Robert Collins
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
  *
  * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
  */
-
+#include "squid.h"
 #include "BlockingFile.h"
 #include "DiskIO/IORequestor.h"
 #include "DiskIO/ReadRequest.h"
 #include "DiskIO/WriteRequest.h"
 
 CBDATA_CLASS_INIT(BlockingFile);
+
 void *
-BlockingFile::operator new (size_t)
+BlockingFile::operator new(size_t sz)
 {
     CBDATA_INIT_TYPE(BlockingFile);
     BlockingFile *result = cbdataAlloc(BlockingFile);
@@ -51,16 +51,16 @@ BlockingFile::operator new (size_t)
 }
 
 void
-BlockingFile::operator delete (void *address)
+BlockingFile::operator delete(void *address)
 {
     BlockingFile *t = static_cast<BlockingFile *>(address);
     cbdataFree(t);
 }
 
-BlockingFile::BlockingFile (char const *aPath) : fd (-1), closed (true), error_(false)
+BlockingFile::BlockingFile(char const *aPath) : fd (-1), closed (true), error_(false)
 {
-    assert (aPath);
-    debug (79,3)("BlockingFile::BlockingFile: %s\n", aPath);
+    assert(aPath);
+    debugs(79, 3, "BlockingFile::BlockingFile: " << aPath);
     path_ = xstrdup (aPath);
 }
 
@@ -71,26 +71,30 @@ BlockingFile::~BlockingFile()
 }
 
 void
-BlockingFile::open (int flags, mode_t mode, IORequestor::Pointer callback)
+BlockingFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
 {
     /* Simulate async calls */
     fd = file_open(path_ , flags);
     ioRequestor = callback;
 
     if (fd < 0) {
-        debug(79, 3) ("BlockingFile::open: got failure (%d)\n", errno);
+        debugs(79, 3, "BlockingFile::open: got failure (" << errno << ")");
         error(true);
     } else {
         closed = false;
         store_open_disk_fd++;
-        debug(79, 3) ("BlockingFile::open: opened FD %d\n", fd);
+        debugs(79, 3, "BlockingFile::open: opened FD " << fd);
     }
 
     callback->ioCompletedNotification();
 }
 
+/**
+ * Alias for BlockingFile::open(...)
+ \copydoc BlockingFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
+ */
 void
-BlockingFile::create (int flags, mode_t mode, IORequestor::Pointer callback)
+BlockingFile::create(int flags, mode_t mode, RefCount<IORequestor> callback)
 {
     /* We use the same logic path for open */
     open(flags, mode, callback);
@@ -108,9 +112,9 @@ void BlockingFile::doClose()
 }
 
 void
-BlockingFile::close ()
+BlockingFile::close()
 {
-    debug (79,3)("BlockingFile::close: %p closing for %p\n", this, ioRequestor.getRaw());
+    debugs(79, 3, "BlockingFile::close: " << this << " closing for " << ioRequestor.getRaw());
     doClose();
     assert (ioRequestor.getRaw());
     ioRequestor->closeCompleted();
@@ -142,6 +146,7 @@ BlockingFile::read(ReadRequest *aRequest)
     assert (fd > -1);
     assert (ioRequestor.getRaw());
     readRequest = aRequest;
+    debugs(79, 3, HERE << aRequest->len << " for FD " << fd << " at " << aRequest->offset);
     file_read(fd, aRequest->buf, aRequest->len, aRequest->offset, ReadDone, this);
 }
 
@@ -156,7 +161,7 @@ BlockingFile::ReadDone(int fd, const char *buf, int len, int errflag, void *my_d
 void
 BlockingFile::write(WriteRequest *aRequest)
 {
-    debug(79, 3) ("storeUfsWrite: FD %d\n",fd);
+    debugs(79, 3, HERE << aRequest->len << " for FD " << fd << " at " << aRequest->offset);
     writeRequest = aRequest;
     file_write(fd,
                aRequest->offset,
@@ -168,9 +173,9 @@ BlockingFile::write(WriteRequest *aRequest)
 }
 
 bool
-BlockingFile::ioInProgress()const
+BlockingFile::ioInProgress() const
 {
-    /* IO is never pending with UFS */
+    /** \retval false   IO is never pending with UFS */
     return false;
 }
 
@@ -179,13 +184,13 @@ BlockingFile::ioInProgress()const
 void
 BlockingFile::readDone(int rvfd, const char *buf, int len, int errflag)
 {
-    debug (79,3)("BlockingFile::readDone: FD %d\n",rvfd);
+    debugs(79, 3, "BlockingFile::readDone: FD " << rvfd);
     assert (fd == rvfd);
 
     ssize_t rlen;
 
     if (errflag) {
-        debug(79, 3) ("BlockingFile::readDone: got failure (%d)\n", errflag);
+        debugs(79, 3, "BlockingFile::readDone: got failure (" << errflag << ")");
         rlen = -1;
     } else {
         rlen = (ssize_t) len;
@@ -212,14 +217,13 @@ void
 BlockingFile::writeDone(int rvfd, int errflag, size_t len)
 {
     assert (rvfd == fd);
-    debug(79, 3) ("storeUfsWriteDone: FD %d, len %ld\n",
-                  fd, (long int) len);
+    debugs(79, 3, HERE << "FD " << fd << ", len " << len);
 
     WriteRequest::Pointer result = writeRequest;
     writeRequest = NULL;
 
     if (errflag) {
-        debug(79, 0) ("storeUfsWriteDone: got failure (%d)\n", errflag);
+        debugs(79, 0, "storeUfsWriteDone: got failure (" << errflag << ")");
         doClose();
         ioRequestor->writeCompleted (DISK_ERROR,0, result);
         return;