web queue: fix cache resizing utility + bug in indexer which would skip oldest entry
This commit is contained in:
parent
1f2776daf6
commit
9d26f4908a
2 changed files with 210 additions and 191 deletions
|
@ -287,7 +287,8 @@ bool BeagleQueueIndexer::index()
|
|||
if (!eof)
|
||||
return false;
|
||||
}
|
||||
while (cc->next(eof)) {
|
||||
int nentries = 0;
|
||||
do {
|
||||
string udi;
|
||||
if (!cc->getCurrentUdi(udi)) {
|
||||
LOGERR(("BeagleQueueIndexer:: cache file damaged\n"));
|
||||
|
@ -307,7 +308,8 @@ bool BeagleQueueIndexer::index()
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
nentries++;
|
||||
} while (cc->next(eof));
|
||||
}
|
||||
|
||||
// Finally index the queue
|
||||
|
|
|
@ -156,7 +156,8 @@ public:
|
|||
////// These are cache persistent state and written to the first block:
|
||||
// Maximum file size, after which we begin reusing old space
|
||||
off_t m_maxsize;
|
||||
// Offset of the oldest header.
|
||||
// Offset of the oldest header, or max file offset (file size)
|
||||
// while the file is growing. This is the next write position.
|
||||
off_t m_oheadoffs;
|
||||
// Offset of last write (newest header)
|
||||
off_t m_nheadoffs;
|
||||
|
@ -1132,8 +1133,19 @@ bool CirCache::rewind(bool& eof)
|
|||
|
||||
eof = false;
|
||||
|
||||
// Read oldest header
|
||||
off_t fsize = lseek(m_d->m_fd, 0, SEEK_END);
|
||||
if (fsize == (off_t)-1) {
|
||||
LOGERR(("CirCache::rewind: seek to EOF failed\n"));
|
||||
return false;
|
||||
}
|
||||
// Read oldest header. This is either at the position pointed to
|
||||
// by oheadoffs, or after the first block if the file is still
|
||||
// growing.
|
||||
if (m_d->m_oheadoffs == fsize) {
|
||||
m_d->m_itoffs = CIRCACHE_FIRSTBLOCK_SIZE;
|
||||
} else {
|
||||
m_d->m_itoffs = m_d->m_oheadoffs;
|
||||
}
|
||||
CCScanHook::status st = m_d->readEntryHeader(m_d->m_itoffs, m_d->m_ithd);
|
||||
|
||||
switch(st) {
|
||||
|
@ -1351,7 +1363,12 @@ bool resizecc(const string& dir, int newmbs)
|
|||
}
|
||||
|
||||
bool eof = false;
|
||||
occ->rewind(eof);
|
||||
if (!occ->rewind(eof)) {
|
||||
if (!eof) {
|
||||
cerr << "Initial rewind failed" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int nentries = 0;
|
||||
while (!eof) {
|
||||
string udi, sdic, data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue