/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * 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.
#include "squid.h"
#include "comm.h"
#include "comm/Connection.h"
-#include "disk.h"
#include "fatal.h"
#include "fd.h"
+#include "fs_io.h"
#include "log/File.h"
#include "log/ModUdp.h"
#include "Parsing.h"
fd_bytes(ll->fd, s, FD_WRITE);
#if 0
if (s < 0) {
- debugs(1, DBG_IMPORTANT, "logfile (udp): got errno (" << errno << "):" << xstrerror());
+ int xerrno = errno;
+ debugs(1, DBG_IMPORTANT, "logfile (udp): got errno (" << errno << "):" << xstrerr(xerrno));
}
if (s != len) {
debugs(1, DBG_IMPORTANT, "logfile (udp): len=" << len << ", wrote=" << s);
any_addr.setIPv4();
ll->fd = comm_open(SOCK_DGRAM, IPPROTO_UDP, any_addr, COMM_NONBLOCKING, "UDP log socket");
+ int xerrno = errno;
if (ll->fd < 0) {
if (lf->flags.fatal) {
fatalf("Unable to open UDP socket for logging\n");
return FALSE;
}
} else if (!comm_connect_addr(ll->fd, addr)) {
+ xerrno = errno;
if (lf->flags.fatal) {
- fatalf("Unable to connect to %s for UDP log: %s\n", lf->path, xstrerror());
+ fatalf("Unable to connect to %s for UDP log: %s\n", lf->path, xstrerr(xerrno));
} else {
- debugs(50, DBG_IMPORTANT, "Unable to connect to " << lf->path << " for UDP log: " << xstrerror());
+ debugs(50, DBG_IMPORTANT, "Unable to connect to " << lf->path << " for UDP log: " << xstrerr(xerrno));
return FALSE;
}
}
if (ll->fd == -1) {
- if (ENOENT == errno && fatal_flag) {
+ if (ENOENT == xerrno && fatal_flag) {
fatalf("Cannot open '%s' because\n"
"\tthe parent directory does not exist.\n"
"\tPlease create the directory.\n", path);
- } else if (EACCES == errno && fatal_flag) {
+ } else if (EACCES == xerrno && fatal_flag) {
fatalf("Cannot open '%s' for writing.\n"
"\tThe parent directory must be writeable by the\n"
"\tuser '%s', which is the cache_effective_user\n"
"\tset in squid.conf.", path, Config.effectiveUser);
} else {
- debugs(50, DBG_IMPORTANT, "logfileOpen (UDP): " << lf->path << ": " << xstrerror());
+ debugs(50, DBG_IMPORTANT, "logfileOpen (UDP): " << lf->path << ": " << xstrerr(xerrno));
return 0;
}
}
* applications like netcat have a small default receive buffer and will
* truncate!
*/
- bufsz = 1400;
+ if (bufsz > 1400)
+ bufsz = 1400;
if (bufsz > 0) {
ll->buf = static_cast<char*>(xmalloc(bufsz));
ll->bufsz = bufsz;