diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2010-03-15 12:51:44 +0100 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2010-03-15 12:51:44 +0100 |
commit | 1e54d2c8a249bbb627bde27fda779cd0e48641cb (patch) | |
tree | c14717c700b341661320bca01b7ac972714fdbaa /lib/Plugins | |
parent | f916f9dc8938cd59fa8a119f245e6e61d1adf496 (diff) | |
download | abrt-1e54d2c8a249bbb627bde27fda779cd0e48641cb.tar.gz abrt-1e54d2c8a249bbb627bde27fda779cd0e48641cb.tar.xz abrt-1e54d2c8a249bbb627bde27fda779cd0e48641cb.zip |
don't read syslog if it didn't change
Diffstat (limited to 'lib/Plugins')
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 15 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsScanner.h | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index fdcc3e5e..b3fe1ec7 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -50,7 +50,7 @@ static int scan_dmesg(vector_string_t& oopsList) /* "dumpoops" tool uses these two functions too */ extern "C" { -int scan_syslog_file(vector_string_t& oopsList, const char *filename) +int scan_syslog_file(vector_string_t& oopsList, const char *filename, time_t *last_changed_p) { VERB1 log("Scanning syslog file '%s'", filename); @@ -59,7 +59,6 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename) int fd; int cnt_FoundOopses; ssize_t sz; - fd = open(filename, O_RDONLY); if (fd < 0) return 0; @@ -69,6 +68,15 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename) return 0; } + if (last_changed_p != NULL) { + if (*last_changed_p == statb.st_mtime) { + VERB1 log("Syslog file '%s' hasn't changed since last scan, skipping", filename); + close(fd); + return 0; + } + *last_changed_p = statb.st_mtime; + } + /* * In theory we have a race here, since someone could spew * to /var/log/messages before we read it in... we try to @@ -137,6 +145,7 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList) CKerneloopsScanner::CKerneloopsScanner() { int cnt_FoundOopses; + m_syslog_last_change = 0; /* Scan dmesg, on first call only */ vector_string_t oopsList; @@ -155,7 +164,7 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int forc } vector_string_t oopsList; - int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file); + int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file, &m_syslog_last_change); if (cnt_FoundOopses > 0) { save_oops_to_debug_dump(oopsList); /* diff --git a/lib/Plugins/KerneloopsScanner.h b/lib/Plugins/KerneloopsScanner.h index da856e04..2bff1343 100644 --- a/lib/Plugins/KerneloopsScanner.h +++ b/lib/Plugins/KerneloopsScanner.h @@ -33,6 +33,8 @@ class CKerneloopsScanner : public CAction { + private: + time_t m_syslog_last_change; public: CKerneloopsScanner(); virtual void Run(const char *pActionDir, const char *pArgs, int force); |