execute: free directory path if we fail to remove it because we cannot allocate a thread

(cherry picked from commit 98b47d54ce)
This commit is contained in:
Lennart Poettering
2014-03-07 00:42:58 -05:00
committed by Zbigniew Jędrzejewski-Szmek
parent 877c2fccf7
commit f0eb7735d8
+16 -2
View File
@@ -2579,6 +2579,8 @@ static void *remove_tmpdir_thread(void *p) {
}
void exec_runtime_destroy(ExecRuntime *rt) {
int r;
if (!rt)
return;
@@ -2588,13 +2590,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;
}