diff options
| author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-09-22 12:02:02 +0200 |
|---|---|---|
| committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-09-22 12:54:41 +0200 |
| commit | fe34bea3225ddf49f4611299af7b54c6ac60fbb6 (patch) | |
| tree | 83e92bb81108b8fd7741d5a5bdcb40d0adf3ba34 /src/daemon/MiddleWare.cpp | |
| parent | 5cba622bac75cd90a846a028e47245a16043da17 (diff) | |
| download | abrt-fe34bea3225ddf49f4611299af7b54c6ac60fbb6.tar.gz abrt-fe34bea3225ddf49f4611299af7b54c6ac60fbb6.tar.xz abrt-fe34bea3225ddf49f4611299af7b54c6ac60fbb6.zip | |
add two flags to dd_opendir()
DD_CLOSE_ON_OPEN_ERR - free dump_dir structure when opening dump_dir
does not exist
DD_FAIL_QUIETLY - suppress message when dump directory does not exist
VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); is all
removed because there is error_msg("'%s' does not exist", dd->dd_dir);
in dd_opendir() which sometimes we don't want to print(DD_FAIL_QUIETLY)
example: crash dump directory trimming code running concurrently.
Second process may try to delete
a directory which is already gone. it should not complain
that it is missing.
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Acked-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon/MiddleWare.cpp')
| -rw-r--r-- | src/daemon/MiddleWare.cpp | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp index 73959102..b3f7ca8a 100644 --- a/src/daemon/MiddleWare.cpp +++ b/src/daemon/MiddleWare.cpp @@ -189,28 +189,25 @@ static bool DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_data_t& VERB3 log(" DebugDumpToCrashReport('%s')", pDebugDumpDir); struct dump_dir *dd = dd_init(); - if (dd_opendir(dd, pDebugDumpDir)) + if (!dd_opendir(dd, pDebugDumpDir, DD_CLOSE_ON_OPEN_ERR)) + return false; + + const char *const *v = must_have_files; + while (*v) { - const char *const *v = must_have_files; - while (*v) + if (!dd_exist(dd, *v)) { - if (!dd_exist(dd, *v)) - { - dd_close(dd); - throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): important file '%s' is missing", *v); - } - - v++; + dd_close(dd); + throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): important file '%s' is missing", *v); } - load_crash_data_from_debug_dump(dd, pCrashData); - dd_close(dd); - - return true; + v++; } + load_crash_data_from_debug_dump(dd, pCrashData); dd_close(dd); - return false; + + return true; } /** @@ -305,9 +302,8 @@ mw_result_t CreateCrashReport(const char *crash_id, try { struct dump_dir *dd = dd_init(); - if (!dd_opendir(dd, row->db_dump_dir)) + if (!dd_opendir(dd, row->db_dump_dir, DD_CLOSE_ON_OPEN_ERR)) { - dd_close(dd); db_row_free(row); return MW_ERROR; } @@ -462,7 +458,7 @@ report_status_t Report(const map_crash_data_t& client_report, if (comment || reproduce || backtrace) { struct dump_dir *dd = dd_init(); - if (dd_opendir(dd, pDumpDir.c_str())) + if (dd_opendir(dd, pDumpDir.c_str(), 0)) { if (comment) { @@ -732,11 +728,8 @@ static mw_result_t SavePackageDescriptionToDebugDump( VERB2 log("Crash in unpackaged executable '%s', proceeding without packaging information", pExecutable); struct dump_dir *dd = dd_init(); - if (!dd_opendir(dd, pDebugDumpDir)) - { - dd_close(dd); + if (!dd_opendir(dd, pDebugDumpDir, DD_CLOSE_ON_OPEN_ERR)) return MW_ERROR; - } dd_save_text(dd, FILENAME_PACKAGE, ""); dd_save_text(dd, FILENAME_COMPONENT, ""); @@ -857,7 +850,7 @@ static mw_result_t SavePackageDescriptionToDebugDump( } struct dump_dir *dd = dd_init(); - if (dd_opendir(dd, pDebugDumpDir)) + if (dd_opendir(dd, pDebugDumpDir, 0)) { if (rpm_pkg) { @@ -1048,11 +1041,8 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, int remote = 0; struct dump_dir *dd = dd_init(); - if (!dd_opendir(dd, pDebugDumpDir)) - { - dd_close(dd); + if (!dd_opendir(dd, pDebugDumpDir, DD_CLOSE_ON_OPEN_ERR)) return MW_ERROR; - } char *time = dd_load_text(dd, FILENAME_TIME); char *uid = dd_load_text(dd, CD_UID); @@ -1139,9 +1129,8 @@ mw_result_t FillCrashInfo(const char *crash_id, return MW_ERROR; struct dump_dir *dd = dd_init(); - if (!dd_opendir(dd, row->db_dump_dir)) + if (!dd_opendir(dd, row->db_dump_dir, DD_CLOSE_ON_OPEN_ERR)) { - dd_close(dd); db_row_free(row); return MW_ERROR; } |
