Module: check_mk
Branch: master
Commit: e846a04ce3c1a2f5603598dd012449202a85247e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e846a04ce3c1a2…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Aug 31 14:33:22 2018 +0200
Moved function where it belongs. Improved a few signatures.
Change-Id: I2985cd3af7034f77986233763a76dcf25190334d
---
livestatus/src/Logfile.cc | 39 ---------------------------------------
livestatus/src/Logfile.h | 14 ++++----------
2 files changed, 4 insertions(+), 49 deletions(-)
diff --git a/livestatus/src/Logfile.cc b/livestatus/src/Logfile.cc
index 5cce1cc..faea8a2 100644
--- a/livestatus/src/Logfile.cc
+++ b/livestatus/src/Logfile.cc
@@ -256,43 +256,4 @@ void Logfile::updateReferences() {
#endif
}
-#ifdef CMC
-std::unique_ptr<std::vector<char>> Logfile::readIntoBuffer() {
- std::unique_ptr<std::vector<char>> result;
- std::ifstream is(_path, std::ios::binary | std::ios::ate);
- if (!is) {
- generic_error ge("cannot open logfile " + _path.string());
- Warning(logger()) << ge;
- return result;
- }
-
- auto end = is.tellg();
- is.seekg(0, std::ios::beg);
- if (!is) {
- generic_error ge("cannot determine size of " + _path.string());
- Warning(logger()) << ge;
- return result;
- }
- auto size = end - is.tellg();
-
- try {
- // Remember: Zeroes at both ends, so we need a bit more space.
- result = std::make_unique<std::vector<char>>(size + 2);
- } catch (std::bad_alloc &) {
- Warning(logger()) << "cannot allocate " << size <<
" byte buffer for "
- << _path;
- return result;
- }
-
- is.read(&result->front() + 1, size);
- if (!is) {
- generic_error ge("cannot open read " + std::to_string(size) +
- " byted from " + _path.string());
- Warning(logger()) << ge;
- }
-
- return result;
-}
-#endif
-
Logger *Logfile::logger() const { return _mc->loggerLivestatus(); }
diff --git a/livestatus/src/Logfile.h b/livestatus/src/Logfile.h
index 97f6649..e188a37 100644
--- a/livestatus/src/Logfile.h
+++ b/livestatus/src/Logfile.h
@@ -50,19 +50,13 @@ using logfile_entries_t = std::map<uint64_t,
std::unique_ptr<LogEntry>>;
class Logfile {
public:
Logfile(MonitoringCore *mc, LogCache *logcache, fs::path path, bool watch);
-
- std::string path() { return _path; }
-#ifdef CMC
- // Note: The buffer is 2 bytes larger then the file, containing a zero
- // character at both ends. For StateHistoryThread::processLogfile.
- std::unique_ptr<std::vector<char>> readIntoBuffer();
-#endif
+ fs::path path() const { return _path; }
// for tricky protocol between LogCache::logLineHasBeenAdded and this class
void flush();
- time_t since() { return _since; }
- unsigned classesRead() { return _logclasses_read; }
- size_t size() { return _entries.size(); }
+ time_t since() const { return _since; }
+ unsigned classesRead() const { return _logclasses_read; }
+ size_t size() const { return _entries.size(); }
long freeMessages(unsigned logclasses);
// for TableStateHistory