/* STATIC */
-static DescriptorSet *TheHalfClosed = NULL; /// the set of half-closed FDs
+static DescriptorSet *TheHalfClosed = nullptr; /// the set of half-closed FDs
static bool WillCheckHalfClosed = false; /// true if check is scheduled
static EVH commHalfClosedCheck;
static void commPlanHalfClosedCheck();
{
++ statCounter.syscalls.sock.recvfroms;
debugs(5,8, "comm_udp_recvfrom: FD " << fd << " from " << from);
- struct addrinfo *AI = NULL;
+ struct addrinfo *AI = nullptr;
Ip::Address::InitAddr(AI);
int x = recvfrom(fd, buf, len, flags, AI->ai_addr, &AI->ai_addrlen);
from = *AI;
bool
comm_has_incomplete_write(int fd)
{
- assert(isOpen(fd) && COMMIO_FD_WRITECB(fd) != NULL);
+ assert(isOpen(fd) && COMMIO_FD_WRITECB(fd) != nullptr);
return COMMIO_FD_WRITECB(fd)->active();
}
comm_local_port(int fd)
{
Ip::Address temp;
- struct addrinfo *addr = NULL;
+ struct addrinfo *addr = nullptr;
fde *F = &fd_table[fd];
/* If the fd is closed already, just return */
const char *note)
{
int new_socket;
- struct addrinfo *AI = NULL;
+ struct addrinfo *AI = nullptr;
/* Create socket for accepting new connections. */
++ statCounter.syscalls.sock.sockets;
fde *F = &fd_table[fd];
assert(F->flags.open);
- F->timeoutHandler = NULL;
+ F->timeoutHandler = nullptr;
F->timeout = 0;
}
assert(F->flags.open);
if (timeout < 0) {
- F->timeoutHandler = NULL;
+ F->timeoutHandler = nullptr;
F->timeout = 0;
} else {
- if (callback != NULL) {
+ if (callback != nullptr) {
typedef CommTimeoutCbParams Params;
Params ¶ms = GetCommParams<Params>(callback);
params.conn = conn;
int x = 0;
int err = 0;
socklen_t errlen;
- struct addrinfo *AI = NULL;
+ struct addrinfo *AI = nullptr;
assert(address.port() != 0);
fde *F = &fd_table[fd];
debugs(5, 5, "commCallCloseHandlers: FD " << fd);
- while (F->closeHandler != NULL) {
+ while (F->closeHandler != nullptr) {
AsyncCall::Pointer call = F->closeHandler;
F->closeHandler = call->Next();
- call->setNext(NULL);
+ call->setNext(nullptr);
// If call is not canceled schedule it for execution else ignore it
if (!call->canceled()) {
debugs(5, 5, "commCallCloseHandlers: ch->handler=" << call);
// notify read/write handlers after canceling select reservations, if any
if (COMMIO_FD_WRITECB(fd)->active()) {
- Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+ Comm::SetSelect(fd, COMM_SELECT_WRITE, nullptr, nullptr, 0);
COMMIO_FD_WRITECB(fd)->finish(Comm::ERR_CLOSING, errno);
}
if (COMMIO_FD_READCB(fd)->active()) {
- Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+ Comm::SetSelect(fd, COMM_SELECT_READ, nullptr, nullptr, 0);
COMMIO_FD_READCB(fd)->finish(Comm::ERR_CLOSING, errno);
}
comm_empty_os_read_buffers(fd);
AsyncCall::Pointer completeCall=commCbCall(5,4, "comm_close_complete",
- FdeCbPtrFun(comm_close_complete, NULL));
+ FdeCbPtrFun(comm_close_complete, nullptr));
FdeCbParams &completeParams = GetCommParams<FdeCbParams>(completeCall);
completeParams.fd = fd;
// must use async call to wait for all callbacks
debugs(50, 3, "comm_udp_sendto: Attempt to send UDP packet to " << to_addr <<
" using FD " << fd << " using Port " << comm_local_port(fd) );
- struct addrinfo *AI = NULL;
+ struct addrinfo *AI = nullptr;
to_addr.getAddrInfo(AI, fd_table[fd].sock_family);
int x = sendto(fd, buf, len, 0, AI->ai_addr, AI->ai_addrlen);
int xerrno = errno;
debugs(5, 5, "comm_remove_close_handler: FD " << fd << ", handler=" <<
handler << ", data=" << data);
- AsyncCall::Pointer p, prev = NULL;
- for (p = fd_table[fd].closeHandler; p != NULL; prev = p, p = p->Next()) {
+ AsyncCall::Pointer p, prev = nullptr;
+ for (p = fd_table[fd].closeHandler; p != nullptr; prev = p, p = p->Next()) {
typedef CommCbFunPtrCallT<CommCloseCbPtrFun> Call;
const Call *call = dynamic_cast<const Call*>(p.getRaw());
if (!call) // method callbacks have their own comm_remove_close_handler
}
// comm_close removes all close handlers so our handler may be gone
- if (p != NULL) {
+ if (p != nullptr) {
p->dequeue(fd_table[fd].closeHandler, prev);
p->cancel("comm_remove_close_handler");
}
debugs(5, 5, "comm_remove_close_handler: FD " << fd << ", AsyncCall=" << call);
// comm_close removes all close handlers so our handler may be gone
- AsyncCall::Pointer p, prev = NULL;
- for (p = fd_table[fd].closeHandler; p != NULL && p != call; prev = p, p = p->Next());
+ AsyncCall::Pointer p, prev = nullptr;
+ for (p = fd_table[fd].closeHandler; p != nullptr && p != call; prev = p, p = p->Next());
- if (p != NULL)
+ if (p != nullptr)
p->dequeue(fd_table[fd].closeHandler, prev);
call->cancel("comm_remove_close_handler");
}
comm_exit(void)
{
delete TheHalfClosed;
- TheHalfClosed = NULL;
+ TheHalfClosed = nullptr;
Comm::CallbackTableDestruct();
}
commCloseAllSockets(void)
{
int fd;
- fde *F = NULL;
+ fde *F = nullptr;
for (fd = 0; fd <= Biggest_FD; ++fd) {
F = &fd_table[fd];
if (F->flags.ipc) /* don't close inter-process sockets */
continue;
- if (F->timeoutHandler != NULL) {
+ if (F->timeoutHandler != nullptr) {
AsyncCall::Pointer callback = F->timeoutHandler;
- F->timeoutHandler = NULL;
+ F->timeoutHandler = nullptr;
debugs(5, 5, "commCloseAllSockets: FD " << fd << ": Calling timeout handler");
ScheduleCallHere(callback);
} else {
checkTimeouts(void)
{
int fd;
- fde *F = NULL;
+ fde *F = nullptr;
AsyncCall::Pointer callback;
for (fd = 0; fd <= Biggest_FD; ++fd) {
// We have an active write callback and we are timed out
CodeContext::Reset(F->codeContext);
debugs(5, 5, "checkTimeouts: FD " << fd << " auto write timeout");
- Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+ Comm::SetSelect(fd, COMM_SELECT_WRITE, nullptr, nullptr, 0);
COMMIO_FD_WRITECB(fd)->finish(Comm::COMM_ERROR, ETIMEDOUT);
CodeContext::Reset();
continue;
CodeContext::Reset(F->codeContext);
debugs(5, 5, "checkTimeouts: FD " << fd << " Expired");
- if (F->timeoutHandler != NULL) {
+ if (F->timeoutHandler != nullptr) {
debugs(5, 5, "checkTimeouts: FD " << fd << ": Call timeout handler");
callback = F->timeoutHandler;
- F->timeoutHandler = NULL;
+ F->timeoutHandler = nullptr;
ScheduleCallHere(callback);
} else {
debugs(5, 5, "checkTimeouts: FD " << fd << ": Forcing comm_close()");
commPlanHalfClosedCheck()
{
if (!WillCheckHalfClosed && !TheHalfClosed->empty()) {
- eventAdd("commHalfClosedCheck", &commHalfClosedCheck, NULL, 1.0, 1);
+ eventAdd("commHalfClosedCheck", &commHalfClosedCheck, nullptr, 1.0, 1);
WillCheckHalfClosed = true;
}
}
// cancel the read if one was scheduled
AsyncCall::Pointer reader = fd_table[fd].halfClosedReader;
- if (reader != NULL)
+ if (reader != nullptr)
Comm::ReadCancel(fd, reader);
- fd_table[fd].halfClosedReader = NULL;
+ fd_table[fd].halfClosedReader = nullptr;
TheHalfClosed->del(fd);
}
{
// there cannot be more data coming in on half-closed connections
assert(size == 0);
- assert(conn != NULL);
+ assert(conn != nullptr);
assert(commHasHalfClosedMonitor(conn->fd)); // or we would have canceled the read
- fd_table[conn->fd].halfClosedReader = NULL; // done reading, for now
+ fd_table[conn->fd].halfClosedReader = nullptr; // done reading, for now
// nothing to do if fd is being closed
if (flag == Comm::ERR_CLOSING)
AI.ai_protocol = proto;
AI.ai_addrlen = SUN_LEN(addr);
AI.ai_addr = (sockaddr*)addr;
- AI.ai_canonname = NULL;
- AI.ai_next = NULL;
+ AI.ai_canonname = nullptr;
+ AI.ai_next = nullptr;
debugs(50, 3, "Attempt open socket for: " << addr->sun_path);