#define PCONN_FDS_SZ 8 /* pconn set size, increase for better memcache hit rate */
//TODO: re-attach to MemPools. WAS: static MemAllocator *pconn_fds_pool = NULL;
-PconnModule * PconnModule::instance = NULL;
+PconnModule * PconnModule::instance = nullptr;
CBDATA_CLASS_INIT(IdleConnList);
/* ========== IdleConnList ============================================ */
{
//Initialize hash_link members
key = xstrdup(aKey);
- next = NULL;
+ next = nullptr;
theList_ = new Comm::ConnectionPointer[capacity_];
parent_->unlinkList(this);
if (size_) {
- parent_ = NULL; // prevent reentrant notifications and deletions
+ parent_ = nullptr; // prevent reentrant notifications and deletions
closeN(size_);
}
// shuffle the remaining entries to fill the new gap.
for (; index < size_ - 1; ++index)
theList_[index] = theList_[index + 1];
- theList_[--size_] = NULL;
+ theList_[--size_] = nullptr;
if (parent_) {
parent_->noteConnectionRemoved();
debugs(48, 2, "Closing all entries.");
while (size_ > 0) {
const Comm::ConnectionPointer conn = theList_[--size_];
- theList_[size_] = NULL;
+ theList_[size_] = nullptr;
clearHandlers(conn);
conn->close();
if (parent_)
// ensure the first N entries are closed
for (index = 0; index < n; ++index) {
const Comm::ConnectionPointer conn = theList_[index];
- theList_[index] = NULL;
+ theList_[index] = nullptr;
clearHandlers(conn);
conn->close();
if (parent_)
}
// ensure the last N entries are unset
while (index < ((size_t)size_)) {
- theList_[index] = NULL;
+ theList_[index] = nullptr;
++index;
}
size_ -= n;
// our connection timeout handler is scheduled to run already. unsafe for now.
// TODO: cancel the pending timeout callback and allow re-use of the conn.
- if (fd_table[theList_[i]->fd].timeoutHandler == NULL)
+ if (fd_table[theList_[i]->fd].timeoutHandler == nullptr)
continue;
// finally, a match. pop and return it.
// our connection timeout handler is scheduled to run already. unsafe for now.
// TODO: cancel the pending timeout callback and allow re-use of the conn.
- if (fd_table[theList_[i]->fd].timeoutHandler == NULL)
+ if (fd_table[theList_[i]->fd].timeoutHandler == nullptr)
continue;
// finally, a match. pop and return it.
/* ========== PconnPool PUBLIC FUNCTIONS ============================================ */
PconnPool::PconnPool(const char *aDescr, const CbcPointer<PeerPoolMgr> &aMgr):
- table(NULL), descr(aDescr),
+ table(nullptr), descr(aDescr),
mgr(aMgr),
theCount(0)
{
PconnModule::GetInstance()->remove(this);
hashFreeItems(table, &DeleteIdleConnList);
hashFreeMemory(table);
- descr = NULL;
+ descr = nullptr;
}
void
const char *aKey = key(conn, domain);
IdleConnList *list = (IdleConnList *) hash_lookup(table, aKey);
- if (list == NULL) {
+ if (list == nullptr) {
list = new IdleConnList(aKey, this);
debugs(48, 3, "new IdleConnList for {" << hashKeyStr(list) << "}" );
hash_join(table, list);
const char * aKey = key(dest, domain);
IdleConnList *list = (IdleConnList *)hash_lookup(table, aKey);
- if (list == NULL) {
+ if (list == nullptr) {
debugs(48, 3, "lookup for key {" << aKey << "} failed.");
// failure notifications resume standby conn creation after fdUsageHigh
notifyManager("pop lookup failure");
PconnModule *
PconnModule::GetInstance()
{
- if (instance == NULL)
+ if (instance == nullptr)
instance = new PconnModule;
return instance;