-
/*
- * $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);
}
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);
}
}
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);
}
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();
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);
}
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,
}
bool
-BlockingFile::ioInProgress()const
+BlockingFile::ioInProgress() const
{
- /* IO is never pending with UFS */
+ /** \retval false IO is never pending with UFS */
return false;
}
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;
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;