/*
- * DEBUG: section 79 Squid-side DISKD I/O functions.
- * AUTHOR: Duane Wessels
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
*
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 79 Squid-side DISKD I/O functions. */
+
#include "squid.h"
#include "comm/Loops.h"
#include "ConfigOption.h"
+#include "diomsg.h"
+#include "DiskdFile.h"
#include "DiskdIOStrategy.h"
#include "DiskIO/DiskFile.h"
-#include "DiskdFile.h"
-#include "diomsg.h"
#include "fd.h"
-#include "Store.h"
-#include "StatCounters.h"
#include "SquidConfig.h"
#include "SquidIpc.h"
#include "SquidTime.h"
+#include "StatCounters.h"
+#include "Store.h"
#include "unlinkd.h"
+#include <cerrno>
#if HAVE_SYS_IPC_H
#include <sys/ipc.h>
#endif
#if HAVE_SYS_SHM_H
#include <sys/shm.h>
#endif
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
diskd_stats_t diskd_stats;
return new DiskdFile (path, this);
}
-DiskdIOStrategy::DiskdIOStrategy() : magic1(64), magic2(72), away(0) , smsgid(-1), rmsgid(-1), wfd(-1) , instanceID(newInstance())
+DiskdIOStrategy::DiskdIOStrategy() : magic1(64), magic2(72), away(0), smsgid(-1), rmsgid(-1), wfd(-1), instanceID(newInstance())
{}
bool
shm_offset);
if (x < 0) {
- debugs(79, DBG_IMPORTANT, "storeDiskdSend UNLINK: " << xstrerror());
- ::unlink(buf); /* XXX EWW! */
+ int xerrno = errno;
+ debugs(79, DBG_IMPORTANT, "storeDiskdSend UNLINK: " << xstrerr(xerrno));
+ ::unlink(buf); /* XXX EWW! */
// shm.put (shm_offset);
}
smsgid = msgget((key_t) ikey, 0700 | IPC_CREAT);
if (smsgid < 0) {
- debugs(50, DBG_CRITICAL, "storeDiskdInit: msgget: " << xstrerror());
+ int xerrno = errno;
+ debugs(50, DBG_CRITICAL, MYNAME << "msgget: " << xstrerr(xerrno));
fatal("msgget failed");
}
rmsgid = msgget((key_t) (ikey + 1), 0700 | IPC_CREAT);
if (rmsgid < 0) {
- debugs(50, DBG_CRITICAL, "storeDiskdInit: msgget: " << xstrerror());
+ int xerrno = errno;
+ debugs(50, DBG_CRITICAL, MYNAME << "msgget: " << xstrerr(xerrno));
fatal("msgget failed");
}
args[2] = skey2;
args[3] = skey3;
args[4] = NULL;
- localhost.SetLocalhost();
+ localhost.setLocalhost();
pid = ipcCreate(IPC_STREAM,
Config.Program.diskd,
args,
nbufs * SHMBUF_BLKSZ, 0600 | IPC_CREAT);
if (id < 0) {
- debugs(50, DBG_CRITICAL, "storeDiskdInit: shmget: " << xstrerror());
+ int xerrno = errno;
+ debugs(50, DBG_CRITICAL, MYNAME << "shmget: " << xstrerr(xerrno));
fatal("shmget failed");
}
buf = (char *)shmat(id, NULL, 0);
if (buf == (void *) -1) {
- debugs(50, DBG_CRITICAL, "storeDiskdInit: shmat: " << xstrerror());
+ int xerrno = errno;
+ debugs(50, DBG_CRITICAL, MYNAME << "shmat: " << xstrerr(xerrno));
fatal("shmat failed");
}
++diskd_stats.sent_count;
++away;
} else {
- debugs(79, DBG_IMPORTANT, "storeDiskdSend: msgsnd: " << xstrerror());
+ int xerrno = errno;
+ debugs(79, DBG_IMPORTANT, MYNAME << "msgsnd: " << xstrerr(xerrno));
cbdataReferenceDone(M->callback_data);
++send_errors;
assert(send_errors < 100);
}
while (1) {
-#ifdef ALWAYS_ZERO_BUFFERS
+#ifdef ALWAYS_ZERO_BUFFERS
memset(&M, '\0', sizeof(M));
#endif
++diskd_stats.recv_count;
--away;
handle(&M);
- retval = 1; /* Return that we've actually done some work */
+ retval = 1; /* Return that we've actually done some work */
if (M.shm_offset > -1)
shm.put ((off_t) M.shm_offset);
{
storeAppendPrintf(&sentry, "Pending operations: %d\n", away);
}
+