got rid of off_t

This commit is contained in:
Jean-Francois Dockes 2017-02-28 20:36:01 +01:00
parent 9a9608e00b
commit bde991c08a
17 changed files with 95 additions and 82 deletions

View File

@ -17,6 +17,8 @@
#include "autoconfig.h" #include "autoconfig.h"
#include <stdint.h>
#include "cstr.h" #include "cstr.h"
#include "beaglequeuecache.h" #include "beaglequeuecache.h"
#include "circache.h" #include "circache.h"
@ -37,7 +39,7 @@ BeagleQueueCache::BeagleQueueCache(RclConfig *cnf)
LOGERR("BeagleQueueCache: cant create CirCache object\n" ); LOGERR("BeagleQueueCache: cant create CirCache object\n" );
return; return;
} }
if (!m_cache->create(off_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) { if (!m_cache->create(int64_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) {
LOGERR("BeagleQueueCache: cache file creation failed: " << (m_cache->getReason()) << "\n" ); LOGERR("BeagleQueueCache: cache file creation failed: " << (m_cache->getReason()) << "\n" );
delete m_cache; delete m_cache;
m_cache = 0; m_cache = 0;

View File

@ -669,7 +669,7 @@ FsIndexer::processonefile(RclConfig *config,
} }
LOGDEB0("processone: processing: [" << LOGDEB0("processone: processing: [" <<
displayableBytes(off_t(stp->st_size)) << "] " << fn << "\n"); displayableBytes(stp->st_size) << "] " << fn << "\n");
// Note that we used to do the full path here, but I ended up // Note that we used to do the full path here, but I ended up
// believing that it made more sense to use only the file name // believing that it made more sense to use only the file name

View File

@ -17,6 +17,7 @@
#ifndef _DIJON_FILTER_H #ifndef _DIJON_FILTER_H
#define _DIJON_FILTER_H #define _DIJON_FILTER_H
#include <stdint.h>
#include <string> #include <string>
#include <set> #include <set>
#include <map> #include <map>
@ -140,7 +141,7 @@ namespace Dijon
stat() calls The value is stored inside metaData, docsize stat() calls The value is stored inside metaData, docsize
key key
*/ */
virtual void set_docsize(off_t size) = 0; virtual void set_docsize(int64_t size) = 0;
// Going from one nested document to the next. // Going from one nested document to the next.

View File

@ -20,6 +20,7 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <stdint.h>
#include "safefcntl.h" #include "safefcntl.h"
#include <sys/types.h> #include <sys/types.h>
#include "safesysstat.h" #include "safesysstat.h"
@ -175,7 +176,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
l_mime = *imime; l_mime = *imime;
} }
off_t docsize = stp->st_size; int64_t docsize = stp->st_size;
if (!l_mime.empty()) { if (!l_mime.empty()) {
// Has mime: check for a compressed file. If so, create a // Has mime: check for a compressed file. If so, create a

View File

@ -107,13 +107,13 @@ bool MimeHandlerText::set_document_string_impl(const string& mt,
bool MimeHandlerText::skip_to_document(const string& ipath) bool MimeHandlerText::skip_to_document(const string& ipath)
{ {
char *endptr; char *endptr;
long long t = strtoll(ipath.c_str(), &endptr, 10); int64_t t = strtoll(ipath.c_str(), &endptr, 10);
if (endptr == ipath.c_str()) { if (endptr == ipath.c_str()) {
LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" << LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" <<
ipath << "]\n"); ipath << "]\n");
return false; return false;
} }
m_offs = (off_t)t; m_offs = t;
readnext(); readnext();
return true; return true;
} }

View File

@ -16,7 +16,9 @@
*/ */
#ifndef _MH_TEXT_H_INCLUDED_ #ifndef _MH_TEXT_H_INCLUDED_
#define _MH_TEXT_H_INCLUDED_ #define _MH_TEXT_H_INCLUDED_
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <string> #include <string>
@ -59,7 +61,7 @@ private:
bool m_paging; bool m_paging;
std::string m_text; std::string m_text;
std::string m_fn; std::string m_fn;
off_t m_offs; // Offset of next read in file if we're paging int64_t m_offs; // Offset of next read in file if we're paging
size_t m_pagesz; size_t m_pagesz;
std::string m_charsetfromxattr; std::string m_charsetfromxattr;

View File

@ -19,7 +19,7 @@
#include "autoconfig.h" #include "autoconfig.h"
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <string> #include <string>
#include "Filter.h" #include "Filter.h"
@ -31,7 +31,7 @@ class RclConfig;
class RecollFilter : public Dijon::Filter { class RecollFilter : public Dijon::Filter {
public: public:
RecollFilter(RclConfig *config, const std::string& id) RecollFilter(RclConfig *config, const std::string& id)
: m_config(config), m_forPreview(false), m_havedoc(false), m_id(id) { : m_config(config), m_id(id) {
} }
virtual ~RecollFilter() {} virtual ~RecollFilter() {}
@ -82,11 +82,11 @@ public:
return set_document_string(mtype, std::string(cp, sz)); return set_document_string(mtype, std::string(cp, sz));
} }
virtual void set_docsize(off_t size) { virtual void set_docsize(int64_t size) {
m_docsize = size; m_docsize = size;
} }
virtual off_t get_docsize() const { virtual int64_t get_docsize() const {
return m_docsize; return m_docsize;
} }
@ -146,15 +146,15 @@ protected:
} }
RclConfig *m_config; RclConfig *m_config;
bool m_forPreview; bool m_forPreview{false};
std::string m_dfltInputCharset; std::string m_dfltInputCharset;
std::string m_reason; std::string m_reason;
bool m_havedoc; bool m_havedoc{false};
std::string m_udi; // May be set by creator as a hint std::string m_udi; // May be set by creator as a hint
// m_id is and md5 of the filter definition line (from mimeconf) and // m_id is and md5 of the filter definition line (from mimeconf) and
// is used when fetching/returning filters to / from the cache. // is used when fetching/returning filters to / from the cache.
std::string m_id; std::string m_id;
off_t m_docsize; // Size of the top document int64_t m_docsize{0}; // Size of the top document
}; };
/** /**

View File

@ -18,6 +18,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
@ -172,7 +173,7 @@ static string sizegetter(const string& fld, const Rcl::Doc& doc)
if (it == doc.meta.end()) { if (it == doc.meta.end()) {
return string(); return string();
} }
off_t size = atoll(it->second.c_str()); int64_t size = atoll(it->second.c_str());
return displayableBytes(size) + " (" + it->second + ")"; return displayableBytes(size) + " (" + it->second + ")";
} }

View File

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <time.h> #include <time.h>
#include <stdint.h>
#include <sstream> #include <sstream>
#include <list> #include <list>
@ -205,11 +206,11 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
} }
// Size information. We print both doc and file if they differ a lot // Size information. We print both doc and file if they differ a lot
off_t fsize = -1, dsize = -1; int64_t fsize = -1, dsize = -1;
if (!doc.dbytes.empty()) if (!doc.dbytes.empty())
dsize = static_cast<off_t>(atoll(doc.dbytes.c_str())); dsize = static_cast<int64_t>(atoll(doc.dbytes.c_str()));
if (!doc.fbytes.empty()) if (!doc.fbytes.empty())
fsize = static_cast<off_t>(atoll(doc.fbytes.c_str())); fsize = static_cast<int64_t>(atoll(doc.fbytes.c_str()));
string sizebuf; string sizebuf;
if (dsize > 0) { if (dsize > 0) {
sizebuf = displayableBytes(dsize); sizebuf = displayableBytes(dsize);

View File

@ -1684,7 +1684,7 @@ void Db::waitUpdIdle()
#endif #endif
// Flush when idxflushmbs is reached // Flush when idxflushmbs is reached
bool Db::maybeflush(off_t moretext) bool Db::maybeflush(int64_t moretext)
{ {
if (m_flushMb > 0) { if (m_flushMb > 0) {
m_curtxtsz += moretext; m_curtxtsz += moretext;

View File

@ -19,6 +19,7 @@
#include "autoconfig.h" #include "autoconfig.h"
#include <stdint.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <memory>
@ -535,7 +536,7 @@ private:
const string& field = cstr_null); const string& field = cstr_null);
// Flush when idxflushmb is reached // Flush when idxflushmb is reached
bool maybeflush(off_t moretext); bool maybeflush(int64_t moretext);
bool docExists(const string& uniterm); bool docExists(const string& uniterm);
/* Copyconst and assignement private and forbidden */ /* Copyconst and assignement private and forbidden */

View File

@ -145,7 +145,7 @@ class CCScanHook {
public: public:
virtual ~CCScanHook() {} virtual ~CCScanHook() {}
enum status {Stop, Continue, Error, Eof}; enum status {Stop, Continue, Error, Eof};
virtual status takeone(off_t offs, const string& udi, virtual status takeone(int64_t offs, const string& udi,
const EntryHeaderData& d) = 0; const EntryHeaderData& d) = 0;
}; };
@ -197,22 +197,22 @@ public:
return false; return false;
} }
}; };
typedef multimap<UdiH, off_t> kh_type; typedef multimap<UdiH, int64_t> kh_type;
typedef multimap<UdiH, off_t>::value_type kh_value_type; typedef multimap<UdiH, int64_t>::value_type kh_value_type;
class CirCacheInternal { class CirCacheInternal {
public: public:
int m_fd; int m_fd;
////// These are cache persistent state and written to the first block: ////// These are cache persistent state and written to the first block:
// Maximum file size, after which we begin reusing old space // Maximum file size, after which we begin reusing old space
off_t m_maxsize; int64_t m_maxsize;
// Offset of the oldest header, or max file offset (file size) // Offset of the oldest header, or max file offset (file size)
// while the file is growing. This is the next write position. // while the file is growing. This is the next write position.
off_t m_oheadoffs; int64_t m_oheadoffs;
// Offset of last write (newest header) // Offset of last write (newest header)
off_t m_nheadoffs; int64_t m_nheadoffs;
// Pad size for newest entry. // Pad size for newest entry.
off_t m_npadsize; int64_t m_npadsize;
// Keep history or only last entry // Keep history or only last entry
bool m_uniquentries; bool m_uniquentries;
///////////////////// End header entries ///////////////////// End header entries
@ -226,7 +226,7 @@ public:
// State for rewind/next/getcurrent operation. This could/should // State for rewind/next/getcurrent operation. This could/should
// be moved to a separate iterator. // be moved to a separate iterator.
off_t m_itoffs; int64_t m_itoffs;
EntryHeaderData m_ithd; EntryHeaderData m_ithd;
// Offset cache // Offset cache
@ -234,7 +234,7 @@ public:
bool m_ofskhcplt; // Has cache been fully read since open? bool m_ofskhcplt; // Has cache been fully read since open?
// Add udi->offset translation to map // Add udi->offset translation to map
bool khEnter(const string& udi, off_t ofs) { bool khEnter(const string& udi, int64_t ofs) {
UdiH h(udi); UdiH h(udi);
LOGDEB2("Circache::khEnter: h " << (h.asHexString()) << " offs " << ((ULONG)ofs) << " udi [" << (udi) << "]\n" ); LOGDEB2("Circache::khEnter: h " << (h.asHexString()) << " offs " << ((ULONG)ofs) << " udi [" << (udi) << "]\n" );
@ -265,7 +265,7 @@ public:
// Return vector of candidate offsets for udi (possibly several // Return vector of candidate offsets for udi (possibly several
// because there may be hash collisions, and also multiple // because there may be hash collisions, and also multiple
// instances). // instances).
bool khFind(const string& udi, vector<off_t>& ofss) { bool khFind(const string& udi, vector<int64_t>& ofss) {
ofss.clear(); ofss.clear();
UdiH h(udi); UdiH h(udi);
@ -295,7 +295,7 @@ public:
return true; return true;
} }
// Clear entry for udi/offs // Clear entry for udi/offs
bool khClear(const pair<string, off_t>& ref) { bool khClear(const pair<string, int64_t>& ref) {
UdiH h(ref.first); UdiH h(ref.first);
pair<kh_type::iterator, kh_type::iterator> p = m_ofskh.equal_range(h); pair<kh_type::iterator, kh_type::iterator> p = m_ofskh.equal_range(h);
if (p.first != m_ofskh.end() && (p.first->first == h)) { if (p.first != m_ofskh.end() && (p.first->first == h)) {
@ -309,8 +309,8 @@ public:
return true; return true;
} }
// Clear entries for vector of udi/offs // Clear entries for vector of udi/offs
bool khClear(const vector<pair<string, off_t> >& udis) { bool khClear(const vector<pair<string, int64_t> >& udis) {
for (vector<pair<string, off_t> >::const_iterator it = udis.begin(); for (vector<pair<string, int64_t> >::const_iterator it = udis.begin();
it != udis.end(); it++) { it != udis.end(); it++) {
khClear(*it); khClear(*it);
} }
@ -434,7 +434,7 @@ public:
return true; return true;
} }
bool writeEntryHeader(off_t offset, const EntryHeaderData& d, bool writeEntryHeader(int64_t offset, const EntryHeaderData& d,
bool eraseData = false) { bool eraseData = false) {
if (m_fd < 0) { if (m_fd < 0) {
m_reason << "writeEntryHeader: not open "; m_reason << "writeEntryHeader: not open ";
@ -467,7 +467,7 @@ public:
return true; return true;
} }
CCScanHook::status readEntryHeader(off_t offset, EntryHeaderData& d) { CCScanHook::status readEntryHeader(int64_t offset, EntryHeaderData& d) {
if (m_fd < 0) { if (m_fd < 0) {
m_reason << "readEntryHeader: not open "; m_reason << "readEntryHeader: not open ";
return CCScanHook::Error; return CCScanHook::Error;
@ -500,14 +500,14 @@ public:
return CCScanHook::Continue; return CCScanHook::Continue;
} }
CCScanHook::status scan(off_t startoffset, CCScanHook *user, CCScanHook::status scan(int64_t startoffset, CCScanHook *user,
bool fold = false) { bool fold = false) {
if (m_fd < 0) { if (m_fd < 0) {
m_reason << "scan: not open "; m_reason << "scan: not open ";
return CCScanHook::Error; return CCScanHook::Error;
} }
off_t so0 = startoffset; int64_t so0 = startoffset;
bool already_folded = false; bool already_folded = false;
while (true) { while (true) {
@ -569,7 +569,7 @@ public:
} }
} }
bool readHUdi(off_t hoffs, EntryHeaderData& d, string& udi) { bool readHUdi(int64_t hoffs, EntryHeaderData& d, string& udi) {
if (readEntryHeader(hoffs, d) != CCScanHook::Continue) { if (readEntryHeader(hoffs, d) != CCScanHook::Continue) {
return false; return false;
} }
@ -590,9 +590,9 @@ public:
return true; return true;
} }
bool readDicData(off_t hoffs, EntryHeaderData& hd, string& dic, bool readDicData(int64_t hoffs, EntryHeaderData& hd, string& dic,
string* data) { string* data) {
off_t offs = hoffs + CIRCACHE_HEADER_SIZE; int64_t offs = hoffs + CIRCACHE_HEADER_SIZE;
// This syscall could be avoided in some cases if we saved the offset // This syscall could be avoided in some cases if we saved the offset
// at each seek. In most cases, we just read the header and we are // at each seek. In most cases, we just read the header and we are
// at the right position // at the right position
@ -674,12 +674,12 @@ string CirCache::getReason()
// physical record in the file // physical record in the file
class CCScanHookRecord : public CCScanHook { class CCScanHookRecord : public CCScanHook {
public: public:
off_t headoffs; int64_t headoffs;
off_t padsize; int64_t padsize;
CCScanHookRecord() CCScanHookRecord()
: headoffs(0), padsize(0) { : headoffs(0), padsize(0) {
} }
virtual status takeone(off_t offs, const string& udi, virtual status takeone(int64_t offs, const string& udi,
const EntryHeaderData& d) { const EntryHeaderData& d) {
headoffs = offs; headoffs = offs;
padsize = d.padsize; padsize = d.padsize;
@ -693,7 +693,7 @@ string CirCache::getpath()
return m_d->datafn(m_dir); return m_d->datafn(m_dir);
} }
bool CirCache::create(off_t maxsize, int flags) bool CirCache::create(int64_t maxsize, int flags)
{ {
LOGDEB("CirCache::create: [" << (m_dir) << "] maxsz " << (lltodecstr((long long)maxsize)) << " flags 0x" << (flags) << "\n" ); LOGDEB("CirCache::create: [" << (m_dir) << "] maxsz " << (lltodecstr((long long)maxsize)) << " flags 0x" << (flags) << "\n" );
if (m_d == 0) { if (m_d == 0) {
@ -787,7 +787,7 @@ bool CirCache::open(OpMode mode)
class CCScanHookDump : public CCScanHook { class CCScanHookDump : public CCScanHook {
public: public:
virtual status takeone(off_t offs, const string& udi, virtual status takeone(int64_t offs, const string& udi,
const EntryHeaderData& d) { const EntryHeaderData& d) {
cout << "Scan: offs " << offs << " dicsize " << d.dicsize cout << "Scan: offs " << offs << " dicsize " << d.dicsize
<< " datasize " << d.datasize << " padsize " << d.padsize << << " datasize " << d.datasize << " padsize " << d.padsize <<
@ -803,7 +803,7 @@ bool CirCache::dump()
// Start at oldest header. This is eof while the file is growing, scan will // Start at oldest header. This is eof while the file is growing, scan will
// fold to bot at once. // fold to bot at once.
off_t start = m_d->m_oheadoffs; int64_t start = m_d->m_oheadoffs;
switch (m_d->scan(start, &dumper, true)) { switch (m_d->scan(start, &dumper, true)) {
case CCScanHook::Stop: case CCScanHook::Stop:
@ -830,13 +830,13 @@ public:
string m_udi; string m_udi;
int m_targinstance; int m_targinstance;
int m_instance; int m_instance;
off_t m_offs; int64_t m_offs;
EntryHeaderData m_hd; EntryHeaderData m_hd;
CCScanHookGetter(const string& udi, int ti) CCScanHookGetter(const string& udi, int ti)
: m_udi(udi), m_targinstance(ti), m_instance(0), m_offs(0) {} : m_udi(udi), m_targinstance(ti), m_instance(0), m_offs(0) {}
virtual status takeone(off_t offs, const string& udi, virtual status takeone(int64_t offs, const string& udi,
const EntryHeaderData& d) { const EntryHeaderData& d) {
LOGDEB2("Circache:Scan: off " << (long(offs)) << " udi [" << (udi) << "] dcsz " << ((UINT)d.dicsize) << " dtsz " << ((UINT)d.datasize) << " pdsz " << ((UINT)d.padsize) << " flgs " << (d.flags) << "\n" ); LOGDEB2("Circache:Scan: off " << (long(offs)) << " udi [" << (udi) << "] dcsz " << ((UINT)d.dicsize) << " dtsz " << ((UINT)d.datasize) << " pdsz " << ((UINT)d.padsize) << " flgs " << (d.flags) << "\n" );
if (!m_udi.compare(udi)) { if (!m_udi.compare(udi)) {
@ -866,13 +866,13 @@ bool CirCache::get(const string& udi, string& dic, string *data, int instance)
if (m_d->m_ofskhcplt) { if (m_d->m_ofskhcplt) {
LOGDEB1("CirCache::get: using ofskh\n" ); LOGDEB1("CirCache::get: using ofskh\n" );
//m_d->khDump(); //m_d->khDump();
vector<off_t> ofss; vector<int64_t> ofss;
if (m_d->khFind(udi, ofss)) { if (m_d->khFind(udi, ofss)) {
LOGDEB1("Circache::get: h found, colls " << (ofss.size()) << "\n" ); LOGDEB1("Circache::get: h found, colls " << (ofss.size()) << "\n" );
int finst = 1; int finst = 1;
EntryHeaderData d_good; EntryHeaderData d_good;
off_t o_good = 0; int64_t o_good = 0;
for (vector<off_t>::iterator it = ofss.begin(); for (vector<int64_t>::iterator it = ofss.begin();
it != ofss.end(); it++) { it != ofss.end(); it++) {
LOGDEB1("Circache::get: trying offs " << ((ULONG)*it) << "\n" ); LOGDEB1("Circache::get: trying offs " << ((ULONG)*it) << "\n" );
EntryHeaderData d; EntryHeaderData d;
@ -904,7 +904,7 @@ bool CirCache::get(const string& udi, string& dic, string *data, int instance)
} }
CCScanHookGetter getter(udi, instance); CCScanHookGetter getter(udi, instance);
off_t start = m_d->m_oheadoffs; int64_t start = m_d->m_oheadoffs;
CCScanHook::status ret = m_d->scan(start, &getter, true); CCScanHook::status ret = m_d->scan(start, &getter, true);
if (ret == CCScanHook::Eof) { if (ret == CCScanHook::Eof) {
@ -944,14 +944,14 @@ bool CirCache::erase(const string& udi, bool reallyclear)
} }
} }
vector<off_t> ofss; vector<int64_t> ofss;
if (!m_d->khFind(udi, ofss)) { if (!m_d->khFind(udi, ofss)) {
// Udi not in there, erase ok // Udi not in there, erase ok
LOGDEB("CirCache::erase: khFind returns none\n" ); LOGDEB("CirCache::erase: khFind returns none\n" );
return true; return true;
} }
for (vector<off_t>::iterator it = ofss.begin(); it != ofss.end(); it++) { for (vector<int64_t>::iterator it = ofss.begin(); it != ofss.end(); it++) {
LOGDEB2("CirCache::erase: reading at " << ((unsigned long)*it) << "\n" ); LOGDEB2("CirCache::erase: reading at " << ((unsigned long)*it) << "\n" );
EntryHeaderData d; EntryHeaderData d;
string fudi; string fudi;
@ -980,15 +980,15 @@ bool CirCache::erase(const string& udi, bool reallyclear)
// entry. // entry.
class CCScanHookSpacer : public CCScanHook { class CCScanHookSpacer : public CCScanHook {
public: public:
off_t sizewanted; int64_t sizewanted;
off_t sizeseen; int64_t sizeseen;
vector<pair<string, off_t> > squashed_udis; vector<pair<string, int64_t> > squashed_udis;
CCScanHookSpacer(off_t sz) CCScanHookSpacer(int64_t sz)
: sizewanted(sz), sizeseen(0) { : sizewanted(sz), sizeseen(0) {
assert(sz > 0); assert(sz > 0);
} }
virtual status takeone(off_t offs, const string& udi, virtual status takeone(int64_t offs, const string& udi,
const EntryHeaderData& d) { const EntryHeaderData& d) {
LOGDEB2("Circache:ScanSpacer:off " << ((UINT)offs) << " dcsz " << (d.dicsize) << " dtsz " << (d.datasize) << " pdsz " << (d.padsize) << " udi[" << (udi) << "]\n" ); LOGDEB2("Circache:ScanSpacer:off " << ((UINT)offs) << " dcsz " << (d.dicsize) << " dtsz " << (d.datasize) << " pdsz " << (d.padsize) << " udi[" << (udi) << "]\n" );
sizeseen += CIRCACHE_HEADER_SIZE + d.dicsize + d.datasize + d.padsize; sizeseen += CIRCACHE_HEADER_SIZE + d.dicsize + d.datasize + d.padsize;
@ -1058,16 +1058,16 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
} }
// Characteristics for the new entry. // Characteristics for the new entry.
off_t nsize = CIRCACHE_HEADER_SIZE + dic.size() + datalen; int64_t nsize = CIRCACHE_HEADER_SIZE + dic.size() + datalen;
off_t nwriteoffs = m_d->m_oheadoffs; int64_t nwriteoffs = m_d->m_oheadoffs;
off_t npadsize = 0; int64_t npadsize = 0;
bool extending = false; bool extending = false;
LOGDEB("CirCache::put: nsz " << (nsize) << " oheadoffs " << (m_d->m_oheadoffs) << "\n" ); LOGDEB("CirCache::put: nsz " << (nsize) << " oheadoffs " << (m_d->m_oheadoffs) << "\n" );
// Check if we can recover some pad space from the (physically) previous // Check if we can recover some pad space from the (physically) previous
// entry. // entry.
off_t recovpadsize = m_d->m_oheadoffs == CIRCACHE_FIRSTBLOCK_SIZE ? int64_t recovpadsize = m_d->m_oheadoffs == CIRCACHE_FIRSTBLOCK_SIZE ?
0 : m_d->m_npadsize; 0 : m_d->m_npadsize;
if (recovpadsize != 0) { if (recovpadsize != 0) {
// Need to read the latest entry's header, to rewrite it with a // Need to read the latest entry's header, to rewrite it with a
@ -1107,7 +1107,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
} else { } else {
// Scan the file until we have enough space for the new entry, // Scan the file until we have enough space for the new entry,
// and determine the pad size up to the 1st preserved entry // and determine the pad size up to the 1st preserved entry
off_t scansize = nsize - recovpadsize; int64_t scansize = nsize - recovpadsize;
LOGDEB("CirCache::put: scanning for size " << (scansize) << " from offs " << ((UINT)m_d->m_oheadoffs) << "\n" ); LOGDEB("CirCache::put: scanning for size " << (scansize) << " from offs " << ((UINT)m_d->m_oheadoffs) << "\n" );
CCScanHookSpacer spacer(scansize); CCScanHookSpacer spacer(scansize);
switch (m_d->scan(m_d->m_oheadoffs, &spacer)) { switch (m_d->scan(m_d->m_oheadoffs, &spacer)) {
@ -1177,8 +1177,8 @@ bool CirCache::rewind(bool& eof)
eof = false; eof = false;
off_t fsize = lseek(m_d->m_fd, 0, SEEK_END); int64_t fsize = lseek(m_d->m_fd, 0, SEEK_END);
if (fsize == (off_t) - 1) { if (fsize == (int64_t) - 1) {
LOGERR("CirCache::rewind: seek to EOF failed\n" ); LOGERR("CirCache::rewind: seek to EOF failed\n" );
return false; return false;
} }
@ -1564,7 +1564,7 @@ b1:
if (argc != 1) { if (argc != 1) {
Usage(); Usage();
} }
off_t sizekb = atoi(*argv++); int64_t sizekb = atoi(*argv++);
argc--; argc--;
int flags = 0; int flags = 0;
if (op_flags & OPT_u) { if (op_flags & OPT_u) {

View File

@ -37,6 +37,7 @@
*/ */
#include <sys/types.h> #include <sys/types.h>
#include <stdint.h>
#include <string> #include <string>
@ -57,7 +58,7 @@ public:
// Truncate file (restart from scratch). // Truncate file (restart from scratch).
CC_CRTRUNCATE = 2 CC_CRTRUNCATE = 2
}; };
virtual bool create(off_t maxsize, int flags); virtual bool create(int64_t maxsize, int flags);
enum OpMode {CC_OPREAD, CC_OPWRITE}; enum OpMode {CC_OPREAD, CC_OPWRITE};
virtual bool open(OpMode mode); virtual bool open(OpMode mode);

View File

@ -298,15 +298,18 @@ public:
m_parent->reset(); m_parent->reset();
} }
private: private:
ExecCmd::Internal *m_parent; ExecCmd::Internal *m_parent{nullptr};
bool m_active; bool m_active{false};
}; };
ExecCmd::~ExecCmd() ExecCmd::~ExecCmd()
{ {
ExecCmdRsrc(this->m); if (m) {
ExecCmdRsrc r(m);
}
if (m) { if (m) {
delete m; delete m;
m = nullptr;
} }
} }
@ -455,7 +458,7 @@ int ExecCmd::startExec(const string& cmd, const vector<string>& args,
} }
// The resource manager ensures resources are freed if we return early // The resource manager ensures resources are freed if we return early
ExecCmdRsrc e(this->m); ExecCmdRsrc e(m);
if (has_input && pipe(m->m_pipein) < 0) { if (has_input && pipe(m->m_pipein) < 0) {
LOGERR("ExecCmd::startExec: pipe(2) failed. errno " << errno << "\n" ); LOGERR("ExecCmd::startExec: pipe(2) failed. errno " << errno << "\n" );
@ -746,7 +749,7 @@ int ExecCmd::doexec(const string& cmd, const vector<string>& args,
} }
// Cleanup in case we return early // Cleanup in case we return early
ExecCmdRsrc e(this->m); ExecCmdRsrc e(m);
SelectLoop myloop; SelectLoop myloop;
int ret = 0; int ret = 0;
if (input || output) { if (input || output) {
@ -948,7 +951,7 @@ int ExecCmd::getline(string& data, int timeosecs)
// overhead. // overhead.
int ExecCmd::wait() int ExecCmd::wait()
{ {
ExecCmdRsrc e(this->m); ExecCmdRsrc e(m);
int status = -1; int status = -1;
if (!m->m_killRequest && m->m_pid > 0) { if (!m->m_killRequest && m->m_pid > 0) {
if (waitpid(m->m_pid, &status, 0) < 0) { if (waitpid(m->m_pid, &status, 0) < 0) {
@ -964,7 +967,7 @@ int ExecCmd::wait()
bool ExecCmd::maybereap(int *status) bool ExecCmd::maybereap(int *status)
{ {
ExecCmdRsrc e(this->m); ExecCmdRsrc e(m);
*status = -1; *status = -1;
if (m->m_pid <= 0) { if (m->m_pid <= 0) {

View File

@ -65,7 +65,7 @@ bool file_to_string(const string& fn, string& data, string *reason)
{ {
return file_to_string(fn, data, 0, size_t(-1), reason); return file_to_string(fn, data, 0, size_t(-1), reason);
} }
bool file_to_string(const string& fn, string& data, off_t offs, size_t cnt, bool file_to_string(const string& fn, string& data, int64_t offs, size_t cnt,
string *reason) string *reason)
{ {
FileToString accum(data); FileToString accum(data);
@ -82,7 +82,7 @@ const int RDBUFSZ = 8192;
// on both linux i586 and macosx (compared to just append()) // on both linux i586 and macosx (compared to just append())
// Also tried a version with mmap, but it's actually slower on the mac and not // Also tried a version with mmap, but it's actually slower on the mac and not
// faster on linux. // faster on linux.
bool file_scan(const string& fn, FileScanDo* doer, off_t startoffs, bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs,
size_t cnttoread, string *reason) size_t cnttoread, string *reason)
{ {
if (startoffs < 0) { if (startoffs < 0) {
@ -121,7 +121,7 @@ bool file_scan(const string& fn, FileScanDo* doer, off_t startoffs,
doer->init(0, reason); doer->init(0, reason);
} }
off_t curoffs = 0; int64_t curoffs = 0;
if (startoffs > 0 && !fn.empty()) { if (startoffs > 0 && !fn.empty()) {
if (lseek(fd, startoffs, SEEK_SET) != startoffs) { if (lseek(fd, startoffs, SEEK_SET) != startoffs) {
catstrerror(reason, "lseek", errno); catstrerror(reason, "lseek", errno);
@ -233,7 +233,7 @@ Usage(void)
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
off_t offs = 0; int64_t offs = 0;
size_t cnt = size_t(-1); size_t cnt = size_t(-1);
thisprog = argv[0]; thisprog = argv[0];
argc--; argc--;

View File

@ -34,7 +34,7 @@ public:
bool file_scan(const std::string& filename, FileScanDo* doer, std::string *reason = 0); bool file_scan(const std::string& filename, FileScanDo* doer, std::string *reason = 0);
/* Same but only process count cnt from offset offs. Set cnt to size_t(-1) /* Same but only process count cnt from offset offs. Set cnt to size_t(-1)
* for no limit */ * for no limit */
bool file_scan(const std::string& fn, FileScanDo* doer, off_t offs, size_t cnt, bool file_scan(const std::string& fn, FileScanDo* doer, int64_t offs, size_t cnt,
std::string *reason = 0); std::string *reason = 0);
/** /**
@ -45,6 +45,6 @@ bool file_to_string(const std::string& filename, std::string& data, std::string
/** Read file chunk into string. Set cnt to size_t(-1) for whole file */ /** Read file chunk into string. Set cnt to size_t(-1) for whole file */
bool file_to_string(const std::string& filename, std::string& data, bool file_to_string(const std::string& filename, std::string& data,
off_t offs, size_t cnt, std::string *reason = 0); int64_t offs, size_t cnt, std::string *reason = 0);
#endif /* _READFILE_H_INCLUDED_ */ #endif /* _READFILE_H_INCLUDED_ */

View File

@ -763,7 +763,7 @@ string displayableBytes(int64_t size)
unit = " GB "; unit = " GB ";
roundable = double(size) / 1E9; roundable = double(size) / 1E9;
} }
size = off_t(round(roundable)); size = int64_t(round(roundable));
return lltodecstr(size).append(unit); return lltodecstr(size).append(unit);
} }