]> err.no Git - systemd/commitdiff
fix memleak
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Jan 2010 19:47:49 +0000 (20:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Jan 2010 19:47:49 +0000 (20:47 +0100)
job.c
manager.c
manager.h

diff --git a/job.c b/job.c
index ec0baba5ee575417e7417d63c922ae999bf1611b..bbb821489518449da20992bb8e4863a474084f91 100644 (file)
--- a/job.c
+++ b/job.c
@@ -37,7 +37,7 @@ void job_free(Job *j) {
                 hashmap_remove(j->manager->jobs, UINT32_TO_PTR(j->id));
         }
 
-        manager_transaction_delete_job(j->manager, j);
+        manager_transaction_unlink_job(j->manager, j);
 
         free(j);
 }
index 8e1c64a90c12ad1b319c9f7e2739474b203cd57c..c71bceb4846ecb1ba5276c360d717af259af1b27 100644 (file)
--- a/manager.c
+++ b/manager.c
@@ -51,6 +51,16 @@ void manager_free(Manager *m) {
         free(m);
 }
 
+static void transaction_delete_job(Manager *m, Job *j) {
+        assert(m);
+        assert(j);
+
+        manager_transaction_unlink_job(m, j);
+
+        if (!j->linked)
+                job_free(j);
+}
+
 static void transaction_abort(Manager *m) {
         Job *j;
 
@@ -58,7 +68,7 @@ static void transaction_abort(Manager *m) {
 
         while ((j = hashmap_first(m->transaction_jobs)))
                 if (j->linked)
-                        manager_transaction_delete_job(m, j);
+                        transaction_delete_job(m, j);
                 else
                         job_free(j);
 
@@ -170,7 +180,7 @@ static void transaction_merge_and_delete_job(Manager *m, Job *j, Job *other, Job
         /* Kill the other job */
         other->subject_list = NULL;
         other->object_list = NULL;
-        manager_transaction_delete_job(m, other);
+        transaction_delete_job(m, other);
 }
 
 static int transaction_merge_jobs(Manager *m) {
@@ -222,7 +232,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
                 for (k = from; k; k = (k->generation == generation ? k->marker : NULL)) {
                         if (!k->matters_to_anchor) {
                                 log_debug("Breaking order cycle by deleting job %s", name_id(k->name));
-                                manager_transaction_delete_job(m, k);
+                                transaction_delete_job(m, k);
                                 return -EAGAIN;
                         }
 
@@ -305,7 +315,7 @@ static void transaction_collect_garbage(Manager *m) {
                         if (j->object_list)
                                 continue;
 
-                        manager_transaction_delete_job(m, j);
+                        transaction_delete_job(m, j);
                         again = true;
                         break;
                 }
@@ -469,7 +479,7 @@ static Job* transaction_add_one_job(Manager *m, JobType type, Name *name, bool *
         return j;
 }
 
-void manager_transaction_delete_job(Manager *m, Job *j) {
+void manager_transaction_unlink_job(Manager *m, Job *j) {
         assert(m);
         assert(j);
 
@@ -494,8 +504,8 @@ void manager_transaction_delete_job(Manager *m, Job *j) {
                 job_dependency_free(j->object_list);
 
                 if (other) {
-                        log_debug("Deleting job %s, as dependency of job %s", name_id(j->name), name_id(other->name));
-                        manager_transaction_delete_job(m, other);
+                        log_debug("Deleting job %s dependency of job %s", name_id(other->name), name_id(j->name));
+                        transaction_delete_job(m, other);
                 }
         }
 }
index c8792b98a0843a95c843f2f71c874c6448540817..287e532b5af379bbac74319bd7aa433416626b5b 100644 (file)
--- a/manager.h
+++ b/manager.h
@@ -48,7 +48,7 @@ int manager_add_job(Manager *m, JobType type, Name *name, JobMode mode, bool for
 void manager_dump_names(Manager *s, FILE *f, const char *prefix);
 void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
 
-void manager_transaction_delete_job(Manager *m, Job *j);
+void manager_transaction_unlink_job(Manager *m, Job *j);
 
 void manager_clear_jobs(Manager *m);