freeChain(fileno, s, true);
assert(s.empty());
+ s.start = -1; // we have not allocated any slices yet
++shared->count;
//s.setKey(key); // XXX: the caller should do that
return shared->slots[anchorId].anchor;
}
-/// terminate writing the entry, freeing its slot for others to use
void
Ipc::StoreMap::abortWriting(const sfileno fileno)
{
debugs(54, 5, "closed clean entry " << fileno << " for writing " << path);
} else {
s.waitingToBeFreed = true;
- // XXX: s.state &= !Anchor::Writeable;
s.lock.unlockExclusive();
debugs(54, 5, "closed dirty entry " << fileno << " for writing " << path);
}
}
-void
-Ipc::StoreMap::abortIo(const sfileno fileno)
-{
- debugs(54, 5, "aborting entry " << fileno << " for I/O in " << path);
- assert(valid(fileno));
- Anchor &s = shared->slots[fileno].anchor;
-
- // The caller is a lock holder. Thus, if we are Writeable, then the
- // caller must be the writer; otherwise the caller must be the reader.
- if (s.writing())
- abortWriting(fileno);
- else
- closeForReading(fileno);
-}
-
const Ipc::StoreMap::Anchor *
Ipc::StoreMap::peekAtReader(const sfileno fileno) const
{
while (sliceId >= 0) {
Slice &slice = shared->slots[sliceId].slice;
const sfileno nextId = slice.next;
+ slice.size = 0;
slice.next = -1;
if (cleaner)
cleaner->noteFreeMapSlice(sliceId); // might change slice state
* the caller holds an appropriate lock */
bool empty() const { return !key[0] && !key[1]; }
bool reading() const { return lock.readers; }
- bool writing() const { return lock.writers; }
+ bool writing() const { return lock.writing; }
bool complete() const { return !empty() && !writing(); }
public:
/// readable anchor for the entry created by openForReading()
const Anchor &readableEntry(const AnchorId anchorId) const;
- /// called by lock holder to terminate either slice writing or reading
- void abortIo(const sfileno fileno);
+ /// stop writing the entry, freeing its slot for others to use if possible
+ void abortWriting(const sfileno fileno);
/// finds an unlocked entry and frees it or returns false
bool purgeOne();
void updateStats(ReadWriteLockStats &stats) const;
StoreMapCleaner *cleaner; ///< notified before a readable entry is freed
+ const String path; ///< cache_dir path or similar cache name; for logging
protected:
static Owner *Init(const char *const path, const int limit, const size_t extrasSize);
- const String path; ///< cache_dir path, used for logging
Mem::Pointer<Shared> shared;
private:
Anchor &anchorByKey(const cache_key *const key);
Anchor *openForReading(Slice &s);
- void abortWriting(const sfileno fileno);
void freeChain(const sfileno fileno, Anchor &inode, const bool keepLock);
};