[PATCH 6/8] Stop dying in check_free_space(); rename it to low_free_space()

Denys Vlasenko dvlasenk at redhat.com
Fri Jul 26 09:23:55 UTC 2013


This allows us to still create compat coredump in abrt-hook-ccpp.
We used to just die if DUMP_LOC is too full.

While at it, removed x1.25 in abrt-hook-ccpp, it is vestigial
(we no longer do _trimming of old problems_ there.

Signed-off-by: Denys Vlasenko <dvlasenk at redhat.com>
---
 src/daemon/abrt-server.c   | 3 ++-
 src/hooks/abrt-hook-ccpp.c | 9 +++------
 src/include/libabrt.h      | 5 ++---
 src/lib/hooklib.c          | 9 ++++++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
index 1d23063..78f4814 100644
--- a/src/daemon/abrt-server.c
+++ b/src/daemon/abrt-server.c
@@ -346,7 +346,8 @@ static int create_problem_dir(GHashTable *problem_info, unsigned pid)
     /* Exit if free space is less than 1/4 of MaxCrashReportsSize */
     if (g_settings_nMaxCrashReportsSize > 0)
     {
-        check_free_space(g_settings_nMaxCrashReportsSize, g_settings_dump_location);
+        if (low_free_space(g_settings_nMaxCrashReportsSize, g_settings_dump_location))
+            exit(1);
     }
 
     /* Create temp directory with the problem data.
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index 99ce5d5..01006b2 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -618,12 +618,9 @@ int main(int argc, char** argv)
 
     if (g_settings_nMaxCrashReportsSize > 0)
     {
-        /* x1.25 and round up to 64m: go a bit up, so that usual in-daemon trimming
-         * kicks in first, and we don't "fight" with it:
-         */
-        unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4;
-        maxsize |= 63;
-        check_free_space(maxsize, g_settings_dump_location);
+        /* If free space is less than 1/4 of MaxCrashReportsSize... */
+        if (low_free_space(g_settings_nMaxCrashReportsSize, g_settings_dump_location))
+            goto create_user_core;
     }
 
     /* Check /var/tmp/abrt/last-ccpp marker, do not dump repeated crashes
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
index f033e21..9d90c19 100644
--- a/src/include/libabrt.h
+++ b/src/include/libabrt.h
@@ -44,16 +44,15 @@ int vdprintf(int d, const char *format, va_list ap);
 #endif
 
 
-#define check_free_space abrt_check_free_space
-
+#define low_free_space abrt_low_free_space
 /**
   @brief Checks if there is enough free space to store the problem data
 
   @param setting_MaxCrashReportsSize Maximum data size
   @param dump_location Location to check for the available space
 */
+int low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
 
-void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
 #define trim_problem_dirs abrt_trim_problem_dirs
 void trim_problem_dirs(const char *dirname, double cap_size, const char *exclude_path);
 #define run_unstrip_n abrt_run_unstrip_n
diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c
index 38a0e43..45beaa9 100644
--- a/src/lib/hooklib.c
+++ b/src/lib/hooklib.c
@@ -18,12 +18,13 @@
 #include <sys/statvfs.h>
 #include "libabrt.h"
 
-void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location)
+int low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location)
 {
     struct statvfs vfs;
     if (statvfs(dump_location, &vfs) != 0)
     {
-        perror_msg_and_die("statvfs('%s')", dump_location);
+        perror_msg("statvfs('%s')", dump_location);
+        return 0;
     }
 
     /* Check that at least MaxCrashReportsSize/4 MBs are free */
@@ -33,9 +34,11 @@ void check_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_loc
     unsigned long fs_free_mb_x4 = ((unsigned long long)vfs.f_bfree / (1024/4)) * vfs.f_bsize / 1024;
     if (fs_free_mb_x4 < setting_MaxCrashReportsSize)
     {
-        error_msg_and_die("Aborting dump: only %luMiB is available on %s",
+        error_msg("Only %luMiB is available on %s",
                           fs_free_mb_x4 / 4, dump_location);
+        return 1;
     }
+    return 0;
 }
 
 /* rhbz#539551: "abrt going crazy when crashing process is respawned".
-- 
1.8.1.4



More information about the Crash-catcher mailing list