/*
- * DEBUG: section 50 Log file handling
- * AUTHOR: Adrian Chadd <adrian@squid-cache.org>
- *
- * 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) 1996-2021 The Squid Software Foundation and contributors
*
+ * 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 50 Log file handling */
+
#include "squid.h"
#include "cbdata.h"
#include "comm/Loops.h"
+#include "fatal.h"
#include "fde.h"
#include "globals.h"
#include "log/Config.h"
#include "log/File.h"
#include "log/ModDaemon.h"
-#include "SquidIpc.h"
#include "SquidConfig.h"
+#include "SquidIpc.h"
#include "SquidTime.h"
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
+#include <cerrno>
/* How many buffers to keep before we say we've buffered too much */
-#define LOGFILE_MAXBUFS 128
+#define LOGFILE_MAXBUFS 128
/* Size of the logfile buffer */
/*
* For optimal performance this should match LOGFILE_BUFSIZ in logfile-daemon.c
*/
-#define LOGFILE_BUFSZ 32768
+#define LOGFILE_BUFSZ 32768
/* How many seconds between warnings */
-#define LOGFILE_WARN_TIME 30
+#define LOGFILE_WARN_TIME 30
static LOGWRITE logfile_mod_daemon_writeline;
static LOGLINESTART logfile_mod_daemon_linestart;
}
static void
-logfileHandleWrite(int fd, void *data)
+logfileHandleWrite(int, void *data)
{
Logfile *lf = static_cast<Logfile *>(data);
l_daemon_t *ll = static_cast<l_daemon_t *>(lf->data);
ll->flush_pending = 0;
int ret = FD_WRITE_METHOD(ll->wfd, b->buf + b->written_len, b->len - b->written_len);
+ int xerrno = errno;
debugs(50, 3, lf->path << ": write returned " << ret);
if (ret < 0) {
- if (ignoreErrno(errno)) {
+ if (ignoreErrno(xerrno)) {
/* something temporary */
Comm::SetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
ll->flush_pending = 1;
return;
}
- debugs(50, DBG_IMPORTANT,"logfileHandleWrite: " << lf->path << ": error writing (" << xstrerror() << ")");
+ debugs(50, DBG_IMPORTANT,"logfileHandleWrite: " << lf->path << ": error writing (" << xstrerr(xerrno) << ")");
/* XXX should handle this better */
fatal("I don't handle this error well!");
}
/* External code */
int
-logfile_mod_daemon_open(Logfile * lf, const char *path, size_t bufsz, int fatal_flag)
+logfile_mod_daemon_open(Logfile * lf, const char *path, size_t, int)
{
const char *args[5];
char *tmpbuf;
}
static void
-logfile_mod_daemon_rotate(Logfile * lf)
+logfile_mod_daemon_rotate(Logfile * lf, const int16_t)
{
char tb[3];
debugs(50, DBG_IMPORTANT, "logfileRotate: " << lf->path);
}
return;
}
- /* Append this data to the end buffer; create a new one if needed */
+
/* Are we eol? If so, prefix with our logfile command byte */
+ if (ll->eol == 1) {
+ logfile_mod_daemon_append(lf, "L", 1);
+ ll->eol = 0;
+ }
+
+ /* Append this data to the end buffer; create a new one if needed */
logfile_mod_daemon_append(lf, buf, len);
}
logfile_mod_daemon_linestart(Logfile * lf)
{
l_daemon_t *ll = static_cast<l_daemon_t *>(lf->data);
- char tb[2];
assert(ll->eol == 1);
- ll->eol = 0;
- tb[0] = 'L';
- tb[1] = '\0';
- logfile_mod_daemon_append(lf, tb, 1);
+ // logfile_mod_daemon_writeline() sends the starting command
}
static void
{
l_daemon_t *ll = static_cast<l_daemon_t *>(lf->data);
logfile_buffer_t *b;
- assert(ll->eol == 0);
+ if (ll->eol == 1) // logfile_mod_daemon_writeline() wrote nothing
+ return;
ll->eol = 1;
/* Kick a write off if the head buffer is -full- */
if (ll->bufs.head != NULL) {
return;
}
}
+