From: Dmitry Kurochkin Date: Tue, 23 Aug 2011 16:22:16 +0000 (+0400) Subject: s/fileno/filen/ in Rock store code to avoid conflicts with fileno(3). X-Git-Tag: take08~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b3ea32189b76b91a21749b9a2f48afd7486f415;p=thirdparty%2Fsquid.git s/fileno/filen/ in Rock store code to avoid conflicts with fileno(3). Apparently, older GCC versions include more standard headers than it should which causes build failures. --- diff --git a/src/fs/rock/RockRebuild.cc b/src/fs/rock/RockRebuild.cc index 24a1f6fd19..4fa9255661 100644 --- a/src/fs/rock/RockRebuild.cc +++ b/src/fs/rock/RockRebuild.cc @@ -18,7 +18,7 @@ Rock::Rebuild::Rebuild(SwapDir *dir): AsyncJob("Rock::Rebuild"), dbEntryLimit(0), fd(-1), dbOffset(0), - fileno(0) + filen(0) { assert(sd); memset(&counts, 0, sizeof(counts)); @@ -56,7 +56,7 @@ Rock::Rebuild::start() { failure("cannot read db header", errno); dbOffset = SwapDir::HeaderSize; - fileno = 0; + filen = 0; checkpoint(); } @@ -84,13 +84,13 @@ Rock::Rebuild::Steps(void *data) void Rock::Rebuild::steps() { - debugs(47,5, HERE << sd->index << " fileno " << fileno << " at " << + debugs(47,5, HERE << sd->index << " filen " << filen << " at " << dbOffset << " <= " << dbSize); const int maxCount = dbEntryLimit; const int wantedCount = opt_foreground_rebuild ? maxCount : 50; const int stepCount = min(wantedCount, maxCount); - for (int i = 0; i < stepCount && dbOffset < dbSize; ++i, ++fileno) { + for (int i = 0; i < stepCount && dbOffset < dbSize; ++i, ++filen) { doOneEntry(); dbOffset += dbEntrySize; @@ -103,7 +103,7 @@ Rock::Rebuild::steps() { void Rock::Rebuild::doOneEntry() { - debugs(47,5, HERE << sd->index << " fileno " << fileno << " at " << + debugs(47,5, HERE << sd->index << " filen " << filen << " at " << dbOffset << " <= " << dbSize); ++counts.scancount; @@ -141,7 +141,7 @@ Rock::Rebuild::doOneEntry() { // skip empty slots if (loadedE.swap_filen > 0 || loadedE.swap_file_sz > 0) { counts.invalid++; - //sd->unlink(fileno); leave garbage on disk, it should not hurt + //sd->unlink(filen); leave garbage on disk, it should not hurt } return; } @@ -153,7 +153,7 @@ Rock::Rebuild::doOneEntry() { counts.objcount++; // loadedE->dump(5); - sd->addEntry(fileno, header, loadedE); + sd->addEntry(filen, header, loadedE); } void @@ -166,7 +166,7 @@ Rock::Rebuild::swanSong() { void Rock::Rebuild::failure(const char *msg, int errNo) { - debugs(47,5, HERE << sd->index << " fileno " << fileno << " at " << + debugs(47,5, HERE << sd->index << " filen " << filen << " at " << dbOffset << " <= " << dbSize); if (errNo) diff --git a/src/fs/rock/RockRebuild.h b/src/fs/rock/RockRebuild.h index f9bd43ab2a..0d0c556675 100644 --- a/src/fs/rock/RockRebuild.h +++ b/src/fs/rock/RockRebuild.h @@ -36,7 +36,7 @@ private: int fd; // store db file descriptor int64_t dbOffset; - int fileno; + int filen; struct _store_rebuild_data counts; diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index bf07215607..4532873e4c 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -46,8 +46,8 @@ Rock::SwapDir::get(const cache_key *key) if (!map || !theFile || !theFile->canRead()) return NULL; - sfileno fileno; - const Ipc::StoreMapSlot *const slot = map->openForReading(key, fileno); + sfileno filen; + const Ipc::StoreMapSlot *const slot = map->openForReading(key, filen); if (!slot) return NULL; @@ -57,7 +57,7 @@ Rock::SwapDir::get(const cache_key *key) StoreEntry *e = new StoreEntry(); e->lock_count = 0; e->swap_dirn = index; - e->swap_filen = fileno; + e->swap_filen = filen; e->swap_file_sz = basics.swap_file_sz; e->lastref = basics.lastref; e->timestamp = basics.timestamp; @@ -322,20 +322,20 @@ Rock::SwapDir::rebuild() { /* Add a new object to the cache with empty memory copy and pointer to disk * use to rebuild store from disk. Based on UFSSwapDir::addDiskRestore */ bool -Rock::SwapDir::addEntry(const int fileno, const DbCellHeader &header, const StoreEntry &from) +Rock::SwapDir::addEntry(const int filen, const DbCellHeader &header, const StoreEntry &from) { debugs(47, 8, HERE << &from << ' ' << from.getMD5Text() << - ", fileno="<< std::setfill('0') << std::hex << std::uppercase << - std::setw(8) << fileno); + ", filen="<< std::setfill('0') << std::hex << std::uppercase << + std::setw(8) << filen); sfileno newLocation = 0; if (Ipc::StoreMapSlot *slot = map->openForWriting(reinterpret_cast(from.key), newLocation)) { - if (fileno == newLocation) { + if (filen == newLocation) { slot->set(from); - map->extras(fileno) = header; + map->extras(filen) = header; } // else some other, newer entry got into our cell map->closeForWriting(newLocation, false); - return fileno == newLocation; + return filen == newLocation; } return false; @@ -386,16 +386,16 @@ Rock::SwapDir::createStoreIO(StoreEntry &e, StoreIOState::STFNCB *cbFile, StoreI const int64_t payloadEnd = sizeof(DbCellHeader) + header.payloadSize; assert(payloadEnd <= max_objsize); - sfileno fileno; + sfileno filen; Ipc::StoreMapSlot *const slot = - map->openForWriting(reinterpret_cast(e.key), fileno); + map->openForWriting(reinterpret_cast(e.key), filen); if (!slot) { debugs(47, 5, HERE << "Rock::SwapDir::createStoreIO: map->add failed"); return NULL; } e.swap_file_sz = header.payloadSize; // and will be copied to the map slot->set(e); - map->extras(fileno) = header; + map->extras(filen) = header; // XXX: We rely on our caller, storeSwapOutStart(), to set e.fileno. // If that does not happen, the entry will not decrement the read level! @@ -403,11 +403,11 @@ Rock::SwapDir::createStoreIO(StoreEntry &e, StoreIOState::STFNCB *cbFile, StoreI IoState *sio = new IoState(this, &e, cbFile, cbIo, data); sio->swap_dirn = index; - sio->swap_filen = fileno; + sio->swap_filen = filen; sio->payloadEnd = payloadEnd; sio->diskOffset = diskOffset(sio->swap_filen); - debugs(47,5, HERE << "dir " << index << " created new fileno " << + debugs(47,5, HERE << "dir " << index << " created new filen " << std::setfill('0') << std::hex << std::uppercase << std::setw(8) << sio->swap_filen << std::dec << " at " << sio->diskOffset); @@ -468,7 +468,7 @@ Rock::SwapDir::openStoreIO(StoreEntry &e, StoreIOState::STFNCB *cbFile, StoreIOS sio->payloadEnd = sizeof(DbCellHeader) + map->extras(e.swap_filen).payloadSize; assert(sio->payloadEnd <= max_objsize); // the payload fits the slot - debugs(47,5, HERE << "dir " << index << " has old fileno: " << + debugs(47,5, HERE << "dir " << index << " has old filen: " << std::setfill('0') << std::hex << std::uppercase << std::setw(8) << sio->swap_filen);