Skip to content

Commit

Permalink
Merge branch 'devel-gcc-fix' of github.com:juju4/squid into devel-gcc…
Browse files Browse the repository at this point in the history
…-fix
  • Loading branch information
juju4 committed Jan 12, 2025
2 parents ebcd098 + 042cd22 commit f976e5f
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 48 deletions.
6 changes: 2 additions & 4 deletions src/DiskIO/DiskThreads/aiops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ squidaio_xstrfree(char *str)
void
squidaio_init(void)
{
size_t i;
squidaio_thread_t *threadp;

if (squidaio_initialised)
Expand Down Expand Up @@ -294,7 +293,7 @@ squidaio_init(void)

assert(NUMTHREADS != 0);

for (i = 0; i < NUMTHREADS; ++i) {
for (size_t i = 0; i < NUMTHREADS; ++i) {
threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
threadp->status = _THREAD_STARTING;
threadp->current_req = nullptr;
Expand Down Expand Up @@ -999,7 +998,6 @@ void
squidaio_stats(StoreEntry * sentry)
{
squidaio_thread_t *threadp;
size_t i;

if (!squidaio_initialised)
return;
Expand All @@ -1010,7 +1008,7 @@ squidaio_stats(StoreEntry * sentry)

threadp = threads;

for (i = 0; i < NUMTHREADS; ++i) {
for (size_t i = 0; i < NUMTHREADS; ++i) {
storeAppendPrintf(sentry, "%zu\t0x%lx\t%ld\n", i + 1, (unsigned long)threadp->thread, threadp->requests);
threadp = threadp->next;
}
Expand Down
8 changes: 4 additions & 4 deletions src/fs/ufs/UFSSwapDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,6 @@ int
Fs::Ufs::UFSSwapDir::HandleCleanEvent()
{
static int swap_index = 0;
size_t i;
int j = 0;
size_t n = 0;

Expand All @@ -1054,7 +1053,7 @@ Fs::Ufs::UFSSwapDir::HandleCleanEvent()
*/
UFSDirToGlobalDirMapping = (int *)xcalloc(NumberOfUFSDirs, sizeof(*UFSDirToGlobalDirMapping));

for (i = 0, n = 0; i < Config.cacheSwap.n_configured; ++i) {
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
/* This is bogus, the controller should just clean each instance once */
sd = dynamic_cast <SwapDir *>(INDEXSD(i));

Expand Down Expand Up @@ -1112,12 +1111,13 @@ Fs::Ufs::UFSSwapDir::IsUFSDir(SwapDir * sd)
* if not UFSSwapDir return 0;
*/
bool
Fs::Ufs::UFSSwapDir::FilenoBelongsHere(int fn, size_t F0, int F1, int F2)
Fs::Ufs::UFSSwapDir::FilenoBelongsHere(int fn, int F0, int F1, int F2)
{
int D1, D2;
int L1, L2;
int filn = fn;
assert(F0 < Config.cacheSwap.n_configured);
assert(F0 >= 0);
assert(static_cast<size_t>(F0) < Config.cacheSwap.n_configured);
assert (UFSSwapDir::IsUFSDir (dynamic_cast<SwapDir *>(INDEXSD(F0))));
UFSSwapDir *sd = dynamic_cast<UFSSwapDir *>(INDEXSD(F0));

Expand Down
2 changes: 1 addition & 1 deletion src/fs/ufs/UFSSwapDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UFSSwapDir : public SwapDir
* \param level1dir level-1 dir in the cachedir
* \param level2dir level-2 dir
*/
static bool FilenoBelongsHere(int fn, size_t cachedir, int level1dir, int level2dir);
static bool FilenoBelongsHere(int fn, int cachedir, int level1dir, int level2dir);

UFSSwapDir(char const *aType, const char *aModuleType);
~UFSSwapDir() override;
Expand Down
24 changes: 14 additions & 10 deletions src/pconn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ IdleConnList::~IdleConnList()
int
IdleConnList::findIndexOf(const Comm::ConnectionPointer &conn) const
{
for (int index = size_ - 1; index >= 0; --index) {
for (auto right = size_; right > 0; --right) {
const auto index = right - 1;
if (conn->fd == theList_[index]->fd) {
debugs(48, 3, "found " << conn << " at index " << index);
return index;
Expand All @@ -89,10 +90,11 @@ IdleConnList::findIndexOf(const Comm::ConnectionPointer &conn) const
* \retval false The index is not an in-use entry.
*/
bool
IdleConnList::removeAt(int index)
IdleConnList::removeAt(size_t index)
{
if (index < 0 || index >= size_)
if (index >= size_)
return false;
assert(size_ > 0);

// shuffle the remaining entries to fill the new gap.
for (; index < size_ - 1; ++index)
Expand All @@ -112,12 +114,12 @@ IdleConnList::removeAt(int index)

// almost a duplicate of removeFD. But drops multiple entries.
void
IdleConnList::closeN(size_t n)
IdleConnList::closeN(const size_t n)
{
if (n < 1) {
debugs(48, 2, "Nothing to do.");
return;
} else if (n >= (size_t)size_) {
} else if (n >= size_) {
debugs(48, 2, "Closing all entries.");
while (size_ > 0) {
const Comm::ConnectionPointer conn = theList_[--size_];
Expand All @@ -141,11 +143,11 @@ IdleConnList::closeN(size_t n)
parent_->noteConnectionRemoved();
}
// shuffle the list N down.
for (index = 0; index < (size_t)size_ - n; ++index) {
for (index = 0; index < size_ - n; ++index) {
theList_[index] = theList_[index + n];
}
// ensure the last N entries are unset
while (index < ((size_t)size_)) {
while (index < size_) {
theList_[index] = nullptr;
++index;
}
Expand Down Expand Up @@ -174,7 +176,7 @@ IdleConnList::push(const Comm::ConnectionPointer &conn)
capacity_ <<= 1;
const Comm::ConnectionPointer *oldList = theList_;
theList_ = new Comm::ConnectionPointer[capacity_];
for (int index = 0; index < size_; ++index)
for (size_t index = 0; index < size_; ++index)
theList_[index] = oldList[index];

delete[] oldList;
Expand Down Expand Up @@ -214,7 +216,8 @@ IdleConnList::isAvailable(int i) const
Comm::ConnectionPointer
IdleConnList::pop()
{
for (int i=size_-1; i>=0; --i) {
for (auto right = size_; right > 0; --right) {
const auto i = right - 1;

if (!isAvailable(i))
continue;
Expand Down Expand Up @@ -252,7 +255,8 @@ IdleConnList::findUseable(const Comm::ConnectionPointer &aKey)
const bool keyCheckAddr = !aKey->local.isAnyAddr();
const bool keyCheckPort = aKey->local.port() > 0;

for (int i=size_-1; i>=0; --i) {
for (auto right = size_; right > 0; --right) {
const auto i = right - 1;

if (!isAvailable(i))
continue;
Expand Down
8 changes: 5 additions & 3 deletions src/pconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ class IdleConnList: public hash_link, private IndependentRunner

void clearHandlers(const Comm::ConnectionPointer &conn);

// TODO: Upgrade to return size_t
int count() const { return size_; }

void closeN(size_t count);

// IndependentRunner API
void endingShutdown() override;
private:
bool isAvailable(int i) const;
bool removeAt(int index);
bool removeAt(size_t index);
int findIndexOf(const Comm::ConnectionPointer &conn) const;
void findAndClose(const Comm::ConnectionPointer &conn);
static IOCB Read;
Expand All @@ -81,9 +83,9 @@ class IdleConnList: public hash_link, private IndependentRunner
Comm::ConnectionPointer *theList_;

/// Number of entries theList can currently hold without re-allocating (capacity).
int capacity_;
size_t capacity_;
///< Number of in-use entries in theList
int size_;
size_t size_;

/** The pool containing this sub-list.
* The parent performs all stats accounting, and
Expand Down
29 changes: 12 additions & 17 deletions src/store/Disks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ storeDirSelectSwapDirRoundRobin(const StoreEntry * e)
firstCandidate = 0;

for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
const int dirn = (firstCandidate + i) % Config.cacheSwap.n_configured;
const auto dirn = (firstCandidate + i) % Config.cacheSwap.n_configured;
auto &dir = SwapDirByIndex(dirn);

int load = 0;
Expand Down Expand Up @@ -118,11 +118,10 @@ storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
int least_load = INT_MAX;
int load;
SwapDir *selectedDir = nullptr;
size_t i;

const int64_t objsize = objectSizeForDirSelection(*e);

for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
auto &sd = SwapDirByIndex(i);
sd.flags.selected = false;

Expand Down Expand Up @@ -173,13 +172,13 @@ Store::Disks::Disks():
}

SwapDir *
Store::Disks::store(int const x) const
Store::Disks::store(const size_t x) const
{
return &SwapDirByIndex(x);
}

SwapDir &
Store::Disks::Dir(const int i)
Store::Disks::Dir(const size_t i)
{
return SwapDirByIndex(i);
}
Expand Down Expand Up @@ -232,11 +231,11 @@ Store::Disks::create()
StoreEntry *
Store::Disks::get(const cache_key *key)
{
if (const size_t cacheDirs = Config.cacheSwap.n_configured) {
if (const auto cacheDirs = Config.cacheSwap.n_configured) {
// ask each cache_dir until the entry is found; use static starting
// point to avoid asking the same subset of disks more often
// TODO: coordinate with put() to be able to guess the right disk often
static int idx = 0;
static size_t idx = 0;
for (size_t n = 0; n < cacheDirs; ++n) {
idx = (idx + 1) % cacheDirs;
auto &sd = Dir(idx);
Expand Down Expand Up @@ -531,11 +530,9 @@ Store::Disks::getStats(StoreInfoStats &stats) const
void
Store::Disks::stat(StoreEntry & output) const
{
size_t i;

/* Now go through each store, calling its stat routine */

for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
storeAppendPrintf(&output, "\n");
store(i)->stat(output);
}
Expand Down Expand Up @@ -563,10 +560,9 @@ Store::Disks::updateHeaders(StoreEntry *e)
void
Store::Disks::maintain()
{
size_t i;
/* walk each fs */

for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
/* XXX FixMe: This should be done "in parallel" on the different
* cache_dirs, not one at a time.
*/
Expand Down Expand Up @@ -618,7 +614,7 @@ Store::Disks::anchorToCache(StoreEntry &entry)
// ask each cache_dir until the entry is found; use static starting
// point to avoid asking the same subset of disks more often
// TODO: coordinate with put() to be able to guess the right disk often
static int idx = 0;
static size_t idx = 0;
for (size_t n = 0; n < cacheDirs; ++n) {
idx = (idx + 1) % cacheDirs;
SwapDir &sd = Dir(idx);
Expand Down Expand Up @@ -703,7 +699,6 @@ storeDirWriteCleanLogs(int reopen)

struct timeval start;
double dt;
size_t dirn;
int notdone = 1;

// Check for store_dirs_rebuilding because fatal() often calls us in early
Expand All @@ -719,7 +714,7 @@ storeDirWriteCleanLogs(int reopen)
getCurrentTime();
start = current_time;

for (dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
auto &sd = SwapDirByIndex(dirn);

if (sd.writeCleanStart() < 0) {
Expand All @@ -736,7 +731,7 @@ storeDirWriteCleanLogs(int reopen)
while (notdone) {
notdone = 0;

for (dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
auto &sd = SwapDirByIndex(dirn);

if (!sd.cleanLog)
Expand All @@ -763,7 +758,7 @@ storeDirWriteCleanLogs(int reopen)
}

/* Flush */
for (dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
SwapDirByIndex(dirn).writeCleanDone();

if (reopen)
Expand Down
4 changes: 2 additions & 2 deletions src/store/Disks.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class Disks: public Controlled

private:
/* migration logic */
SwapDir *store(int const x) const;
static SwapDir &Dir(int const idx);
SwapDir *store(size_t index) const;
static SwapDir &Dir(size_t index);

int64_t largestMinimumObjectSize; ///< maximum of all Disk::minObjectSize()s
int64_t largestMaximumObjectSize; ///< maximum of all Disk::maxObjectSize()s
Expand Down
13 changes: 9 additions & 4 deletions src/store_rebuild.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,18 @@ storeRebuildStart(void)
* progress.
*/
void
storeRebuildProgress(size_t sd_index, int total, int sofar)
storeRebuildProgress(const int sd_index_raw, const int total, const int sofar)
{
static time_t last_report = 0;
// TODO: Switch to int64_t and fix handling of unknown totals.
double n = 0.0;
double d = 0.0;

if (sd_index_raw < 0)
return;

// TODO: Upgrade Disk::index and sd_index_raw to size_t, removing this cast.
const auto sd_index = static_cast<size_t>(sd_index_raw);
if (sd_index >= Config.cacheSwap.n_configured)
return;

Expand All @@ -231,9 +236,9 @@ storeRebuildProgress(size_t sd_index, int total, int sofar)
if (squid_curtime - last_report < 15)
return;

for (sd_index = 0; sd_index < Config.cacheSwap.n_configured; ++sd_index) {
n += (double) RebuildProgress[sd_index].scanned;
d += (double) RebuildProgress[sd_index].total;
for (size_t diskIndex = 0; diskIndex < Config.cacheSwap.n_configured; ++diskIndex) {
n += (double) RebuildProgress[diskIndex].scanned;
d += (double) RebuildProgress[diskIndex].total;
}

debugs(20, Important(57), "Indexing cache entries: " << Progress(n, d));
Expand Down
2 changes: 1 addition & 1 deletion src/store_rebuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ operator <<(std::ostream &os, const Progress &p)

void storeRebuildStart(void);
void storeRebuildComplete(StoreRebuildData *);
void storeRebuildProgress(size_t sd_index, int total, int sofar);
void storeRebuildProgress(int sd_index, int total, int sofar);

/// loads entry from disk; fills supplied memory buffer on success
bool storeRebuildLoadEntry(int fd, int diskIndex, MemBuf &buf, StoreRebuildData &counts);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/testStoreController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ addedEntry(Store::Disk *aStore,
e->swap_filen = 0; /* garh - lower level*/
e->swap_dirn = -1;

for (size_t i=0; i < Config.cacheSwap.n_configured; ++i) {
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
if (INDEXSD(i) == aStore)
e->swap_dirn = i;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/testStoreHashIndex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ addedEntry(Store::Disk *aStore,
e->swap_filen = 0; /* garh - lower level*/
e->swap_dirn = -1;

for (size_t i=0; i < Config.cacheSwap.n_configured; ++i) {
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
if (INDEXSD(i) == aStore)
e->swap_dirn = i;
}
Expand Down

0 comments on commit f976e5f

Please sign in to comment.