chiark / gitweb /
execute: free directory path if we fail to remove it because we cannot allocate a...
authorLennart Poettering <lennart@poettering.net>
Mon, 3 Mar 2014 16:11:39 +0000 (17:11 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 3 Mar 2014 16:55:32 +0000 (17:55 +0100)
src/core/execute.c

index 9de6e8726f2c42ac05e6a855cc29dadac13016d0..3312885b8775833d9b2f7219d88fb284b6a9f7b4 100644 (file)
@@ -2713,6 +2713,8 @@ static void *remove_tmpdir_thread(void *p) {
 }
 
 void exec_runtime_destroy(ExecRuntime *rt) {
+        int r;
+
         if (!rt)
                 return;
 
@@ -2722,13 +2724,25 @@ void exec_runtime_destroy(ExecRuntime *rt) {
 
         if (rt->tmp_dir) {
                 log_debug("Spawning thread to nuke %s", rt->tmp_dir);
-                asynchronous_job(remove_tmpdir_thread, rt->tmp_dir);
+
+                r = asynchronous_job(remove_tmpdir_thread, rt->tmp_dir);
+                if (r < 0) {
+                        log_warning("Failed to nuke %s: %s", rt->tmp_dir, strerror(-r));
+                        free(rt->tmp_dir);
+                }
+
                 rt->tmp_dir = NULL;
         }
 
         if (rt->var_tmp_dir) {
                 log_debug("Spawning thread to nuke %s", rt->var_tmp_dir);
-                asynchronous_job(remove_tmpdir_thread, rt->var_tmp_dir);
+
+                r = asynchronous_job(remove_tmpdir_thread, rt->var_tmp_dir);
+                if (r < 0) {
+                        log_warning("Failed to nuke %s: %s", rt->var_tmp_dir, strerror(-r));
+                        free(rt->var_tmp_dir);
+                }
+
                 rt->var_tmp_dir = NULL;
         }