/*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
int x;
struct sockaddr_in PS;
+ int xerrno;
WSAStartup(2, &wsaData);
atexit(Win32SockCleanup);
x = read(0, buf, sizeof(wpi));
if (x < (int)sizeof(wpi)) {
+ xerrno = errno;
getCurrentTime();
- debugs(42, DBG_CRITICAL, HERE << "read: FD 0: " << xstrerror());
+ debugs(42, DBG_CRITICAL, MYNAME << " read: FD 0: " << xstrerr(xerrno));
write(1, "ERR\n", 4);
return -1;
}
x = read(0, buf, sizeof(PS));
if (x < (int)sizeof(PS)) {
+ xerrno = errno;
getCurrentTime();
- debugs(42, DBG_CRITICAL, HERE << "read: FD 0: " << xstrerror());
+ debugs(42, DBG_CRITICAL, MYNAME << " read: FD 0: " << xstrerr(xerrno));
write(1, "ERR\n", 4);
return -1;
}
icmp_sock = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, &wpi, 0, 0);
if (icmp_sock == -1) {
+ xerrno = errno;
getCurrentTime();
- debugs(42, DBG_CRITICAL, HERE << "WSASocket: " << xstrerror());
+ debugs(42, DBG_CRITICAL, MYNAME << "WSASocket: " << xstrerr(xerrno));
write(1, "ERR\n", 4);
return -1;
}
x = connect(icmp_sock, (struct sockaddr *) &PS, sizeof(PS));
if (SOCKET_ERROR == x) {
+ xerrno = errno;
getCurrentTime();
- debugs(42, DBG_CRITICAL, HERE << "connect: " << xstrerror());
+ debugs(42, DBG_CRITICAL, MYNAME << "connect: " << xstrerr(xerrno));
write(1, "ERR\n", 4);
return -1;
}
x = recv(icmp_sock, (void *) buf, sizeof(buf), 0);
if (x < 3) {
- debugs(42, DBG_CRITICAL, HERE << "recv: " << xstrerror());
+ xerrno = errno;
+ debugs(42, DBG_CRITICAL, MYNAME << "recv: " << xstrerr(xerrno));
return -1;
}
x = send(icmp_sock, (const void *) buf, strlen(buf), 0);
+ xerrno = errno;
if (x < 3 || strncmp("OK\n", buf, 3)) {
- debugs(42, DBG_CRITICAL, HERE << "recv: " << xstrerror());
+ debugs(42, DBG_CRITICAL, MYNAME << "recv: " << xstrerr(xerrno));
return -1;
}
if (n < 0) {
debugs(42, DBG_IMPORTANT, "Pinger exiting.");
Close();
- exit(1);
+ exit(EXIT_FAILURE);
}
if (0 == n) {
/* EOF indicator */
- debugs(42, DBG_CRITICAL, HERE << "EOF encountered. Pinger exiting.\n");
+ debugs(42, DBG_CRITICAL, "EOF encountered. Pinger exiting.");
errno = 0;
Close();
- exit(1);
+ exit(EXIT_FAILURE);
}
guess_size = n - (sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ);
debugs(42, 2, HERE << "return result to squid. len=" << len);
if (send(socket_to_squid, &preply, len, 0) < 0) {
- debugs(42, DBG_CRITICAL, "pinger: FATAL error on send: " << xstrerror());
+ int xerrno = errno;
+ debugs(42, DBG_CRITICAL, "pinger: FATAL error on send: " << xstrerr(xerrno));
Close();
- exit(1);
+ exit(EXIT_FAILURE);
}
}