CBDATA_CLASS_INIT(netdbExchangeState);
-static hash_table *addr_table = NULL;
-static hash_table *host_table = NULL;
+static hash_table *addr_table = nullptr;
+static hash_table *host_table = nullptr;
Ip::Address networkFromInaddr(const Ip::Address &a);
static void netdbRelease(netdbEntry * n);
* gets freed during a reconfigure. We want this database to
* remain persisitent, so _net_db_peer->peername points into this
* linked list */
-static wordlist *peer_names = NULL;
+static wordlist *peer_names = nullptr;
static void
netdbHashInsert(netdbEntry * n, Ip::Address &addr)
{
networkFromInaddr(addr).toStr(n->network, MAX_IPSTRLEN);
n->key = n->network;
- assert(hash_lookup(addr_table, n->network) == NULL);
+ assert(hash_lookup(addr_table, n->network) == nullptr);
hash_join(addr_table, n);
}
{
hash_link *hptr = (hash_link *)hash_lookup(addr_table, key);
- if (hptr == NULL) {
+ if (hptr == nullptr) {
debug_trap("netdbHashDelete: key not found");
return;
}
netdbHostInsert(netdbEntry * n, const char *hostname)
{
net_db_name *x = new net_db_name(hostname, n);
- assert(hash_lookup(host_table, hostname) == NULL);
+ assert(hash_lookup(host_table, hostname) == nullptr);
hash_join(host_table, x);
}
static void
netdbHostDelete(const net_db_name * x)
{
- assert(x != NULL);
- assert(x->net_db_entry != NULL);
+ assert(x != nullptr);
+ assert(x->net_db_entry != nullptr);
netdbEntry *n = x->net_db_entry;
-- n->link_count;
netdbLookupHost(const char *key)
{
net_db_name *x = (net_db_name *) hash_lookup(host_table, key);
- return x ? x->net_db_entry : NULL;
+ return x ? x->net_db_entry : nullptr;
}
static void
netdbHostDelete(x);
}
- n->hosts = NULL;
+ n->hosts = nullptr;
safe_free(n->peers);
- n->peers = NULL;
+ n->peers = nullptr;
n->n_peers = 0;
n->n_peers_alloc = 0;
if (netdbEntry::UseCount() > Config.Netdb.high)
netdbPurgeLRU();
- if ((n = netdbLookupAddr(addr)) == NULL) {
+ if ((n = netdbLookupAddr(addr)) == nullptr) {
n = new netdbEntry;
netdbHashInsert(n, addr);
}
netdbSendPing(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data)
{
Ip::Address addr;
- char *hostname = NULL;
+ char *hostname = nullptr;
static_cast<generic_cbdata *>(data)->unwrap(&hostname);
netdbEntry *n;
netdbEntry *na;
net_db_name *x;
net_db_name **X;
- if (ia == NULL) {
+ if (ia == nullptr) {
xfree(hostname);
return;
}
addr = ia->current();
- if ((n = netdbLookupHost(hostname)) == NULL) {
+ if ((n = netdbLookupHost(hostname)) == nullptr) {
n = netdbAdd(addr);
netdbHostInsert(n, hostname);
} else if ((na = netdbLookupAddr(addr)) != n) {
*hostname moved from 'network n' to 'network na'!
*/
- if (na == NULL)
+ if (na == nullptr)
na = netdbAdd(addr);
debugs(38, 3, "netdbSendPing: " << hostname << " moved from " << n->network << " to " << na->network);
x = (net_db_name *) hash_lookup(host_table, hostname);
- if (x == NULL) {
+ if (x == nullptr) {
debugs(38, DBG_IMPORTANT, "ERROR: Squid BUG: net_db_name list bug: " << hostname << " not found");
xfree(hostname);
return;
return p;
}
- return NULL;
+ return nullptr;
}
static net_db_peer *
debugs(38, DBG_IMPORTANT, "NETDB state saved; " <<
count << " entries, " <<
tvSubMsec(start, current_time) << " msec" );
- eventAddIsh("netdbSaveState", netdbSaveState, NULL, 3600.0, 1);
+ eventAddIsh("netdbSaveState", netdbSaveState, nullptr, 3600.0, 1);
}
static void
q = strtok(t, w_space);
t = s + 1;
- if (NULL == q)
+ if (nullptr == q)
continue;
if (! (addr = q) )
continue;
- if (netdbLookupAddr(addr) != NULL) /* no dups! */
+ if (netdbLookupAddr(addr) != nullptr) /* no dups! */
continue;
- if ((q = strtok(NULL, w_space)) == NULL)
+ if ((q = strtok(nullptr, w_space)) == nullptr)
continue;
N.pings_sent = atoi(q);
- if ((q = strtok(NULL, w_space)) == NULL)
+ if ((q = strtok(nullptr, w_space)) == nullptr)
continue;
N.pings_recv = atoi(q);
N.pings_recv = 1;
- if ((q = strtok(NULL, w_space)) == NULL)
+ if ((q = strtok(nullptr, w_space)) == nullptr)
continue;
N.hops = atof(q);
- if ((q = strtok(NULL, w_space)) == NULL)
+ if ((q = strtok(nullptr, w_space)) == nullptr)
continue;
N.rtt = atof(q);
- if ((q = strtok(NULL, w_space)) == NULL)
+ if ((q = strtok(nullptr, w_space)) == nullptr)
continue;
N.next_ping_time = (time_t) atoi(q);
- if ((q = strtok(NULL, w_space)) == NULL)
+ if ((q = strtok(nullptr, w_space)) == nullptr)
continue;
N.last_use_time = (time_t) atoi(q);
netdbHashInsert(n, addr);
- while ((q = strtok(NULL, w_space)) != NULL) {
- if (netdbLookupHost(q) != NULL) /* no dups! */
+ while ((q = strtok(nullptr, w_space)) != nullptr) {
+ if (netdbLookupHost(q) != nullptr) /* no dups! */
continue;
netdbHostInsert(n, q);
host_table = hash_create((HASHCMP *) strcmp, n, hash_string);
- eventAddIsh("netdbSaveState", netdbSaveState, NULL, 3600.0, 1);
+ eventAddIsh("netdbSaveState", netdbSaveState, nullptr, 3600.0, 1);
netdbReloadState();
#if USE_ICMP
netdbEntry *n;
- if ((n = netdbLookupHost(hostname)) != NULL)
+ if ((n = netdbLookupHost(hostname)) != nullptr)
if (n->next_ping_time > squid_curtime)
return;
int N;
debugs(38, 3, "netdbHandlePingReply: from " << from);
- if ((n = netdbLookupAddr(from)) == NULL)
+ if ((n = netdbLookupAddr(from)) == nullptr)
return;
N = ++n->pings_recv;
#if USE_ICMP
hashFreeItems(addr_table, netdbFreeNetdbEntry);
hashFreeMemory(addr_table);
- addr_table = NULL;
+ addr_table = nullptr;
hashFreeItems(host_table, netdbFreeNameEntry);
hashFreeMemory(host_table);
- host_table = NULL;
+ host_table = nullptr;
wordlistDestroy(&peer_names);
- peer_names = NULL;
+ peer_names = nullptr;
#endif
}
#if USE_ICMP
netdbEntry *n = netdbLookupHost(host);
- if (n == NULL)
+ if (n == nullptr)
return;
*samp = n->pings_recv;
debugs(38, 3, url.host() << ", " << ihops << " hops, " << irtt << " rtt");
n = netdbLookupHost(url.host());
- if (n == NULL) {
+ if (n == nullptr) {
debugs(38, 3, "host " << url.host() << " not found");
return;
}
- if ((p = netdbPeerByName(n, e->host)) == NULL)
+ if ((p = netdbPeerByName(n, e->host)) == nullptr)
p = netdbPeerAdd(n, e);
p->rtt = rtt;
n = netdbLookupAddr(addr);
- if (n == NULL)
+ if (n == nullptr)
n = netdbAdd(addr);
- assert(NULL != n);
+ assert(nullptr != n);
- if ((p = netdbPeerByName(n, e->host)) == NULL)
+ if ((p = netdbPeerByName(n, e->host)) == nullptr)
p = netdbPeerAdd(n, e);
p->rtt = rtt;
#if USE_ICMP
netdbEntry *n = netdbLookupAddr(addr);
- if (n == NULL)
+ if (n == nullptr)
return;
debugs(38, 3, "netdbDeleteAddrNetwork: " << n->network);
struct in_addr line_addr;
s->buffer();
- reply->setHeaders(Http::scOkay, "OK", NULL, -1, squid_curtime, -2);
+ reply->setHeaders(Http::scOkay, "OK", nullptr, -1, squid_curtime, -2);
s->replaceHttpReply(reply);
rec_sz = 0;
rec_sz += 1 + sizeof(struct in_addr);
netdbExchangeState *ex = new netdbExchangeState(p, req);
ex->e = storeCreateEntry(uri, uri, RequestFlags(), Http::METHOD_GET);
- assert(NULL != ex->e);
+ assert(nullptr != ex->e);
StoreIOBuffer tempBuffer;
tempBuffer.length = ex->buf_sz;
assert(ps);
HttpRequest *request = ps->request;
- CachePeer *p = NULL;
+ CachePeer *p = nullptr;
netdbEntry *n;
const ipcache_addrs *ia;
net_db_peer *h;
int i;
n = netdbLookupHost(request->url.host());
- if (NULL == n) {
+ if (nullptr == n) {
/* try IP addr */
ia = ipcache_gethostbyname(request->url.host(), 0);
- if (NULL != ia)
+ if (nullptr != ia)
n = netdbLookupAddr(ia->current());
}
- if (NULL == n)
- return NULL;
+ if (nullptr == n)
+ return nullptr;
if (0 == n->n_peers)
- return NULL;
+ return nullptr;
n->last_use_time = squid_curtime;
p = peerFindByName(h->peername);
- if (NULL == p) /* not found */
+ if (nullptr == p) /* not found */
continue;
if (neighborType(p, request->url) != PEER_PARENT)
#else
(void)ps;
#endif
- return NULL;
+ return nullptr;
}