From 5b07fe7069347f4c442155cc737ef24bd85fa24a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 28 Aug 2009 14:06:18 +0200 Subject: daemon: log DBus calls with -v; log file creation only with -vvv Signed-off-by: Denys Vlasenko --- src/Daemon/Daemon.cpp | 116 +++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 59 deletions(-) (limited to 'src/Daemon/Daemon.cpp') diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index b6155f17..ea41302e 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -451,75 +451,73 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe event = (struct inotify_event *) &buf[i]; if (event->len) - name = &buf[i] + sizeof (struct inotify_event); - i += sizeof (struct inotify_event) + event->len; + name = &buf[i] + sizeof (*event); + i += sizeof (*event) + event->len; - log("Created file: %s", name); + /* ignore lock files and such */ + if (!(event->mask & IN_ISDIR)) + { + VERB3 log("File '%s' creation detected, ignoring", name); + continue; + } - /* we ignore the lock files */ - if (event->mask & IN_ISDIR) + log("Directory '%s' creation detected", name); + if (GetDirSize(DEBUG_DUMPS_DIR) / (1024*1024) >= g_settings_nMaxCrashReportsSize) + { +//TODO: delete oldest or biggest dir + log("Size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, g_settings_nMaxCrashReportsSize, name); + DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + continue; + } + + map_crash_info_t crashinfo; + try { - if (GetDirSize(DEBUG_DUMPS_DIR) / (1024*1024) < g_settings_nMaxCrashReportsSize) + mw_result_t res; + res = SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo); + switch (res) { - //std::string sName = name; - map_crash_info_t crashinfo; - try - { - mw_result_t res; - res = SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo); - switch (res) - { - case MW_OK: - log("New crash, saving..."); - RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]); - /* Send dbus signal */ - g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); - break; - case MW_REPORTED: - case MW_OCCURED: - log("Already saved crash, deleting..."); - /* Send dbus signal */ - g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); - DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); - break; - case MW_BLACKLISTED: - case MW_CORRUPTED: - case MW_PACKAGE_ERROR: - case MW_GPG_ERROR: - case MW_IN_DB: - case MW_FILE_ERROR: - default: - warn_client("Corrupted or bad crash, deleting..."); - DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); - break; - } - } - catch (CABRTException& e) - { - warn_client(e.what()); - if (e.type() == EXCEP_FATAL) - { - delete[] buf; - return -1; - } - } - catch (...) - { - delete[] buf; - throw; - } + case MW_OK: + log("New crash, saving..."); + RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]); + /* Send dbus signal */ + g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); + break; + case MW_REPORTED: + case MW_OCCURED: + log("Already saved crash, deleting..."); + /* Send dbus signal */ + g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); + DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + break; + case MW_BLACKLISTED: + case MW_CORRUPTED: + case MW_PACKAGE_ERROR: + case MW_GPG_ERROR: + case MW_IN_DB: + case MW_FILE_ERROR: + default: + warn_client("Corrupted or bad crash, deleting..."); + DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + break; } - else + } + catch (CABRTException& e) + { + warn_client(e.what()); + if (e.type() == EXCEP_FATAL) { - log("DebugDumps size has exceeded the limit, deleting the last dump: %s", name); - DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + delete[] buf; + return -1; } } - else + catch (...) { - log("Some file created, ignoring..."); + delete[] buf; + throw; } - } + } /* while */ + delete[] buf; return TRUE; } -- cgit