Linux Container Development
 help / color / mirror / Atom feed
From: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: [PATCH 1/2] Add a 'cleanup' function to objhash object operations
Date: Tue, 15 Sep 2009 09:52:10 -0700	[thread overview]
Message-ID: <1253033531-6764-2-git-send-email-danms@us.ibm.com> (raw)
In-Reply-To: <1253033531-6764-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

This patch adds a 'cleanup' function to the object operations structure,
which is called during objhash teardown before the final reference is
dropped.  It provides a way to perform some object cleanup when checkpoint
or restart operation is finished, in scenarios where the final reference
count cannot be anticipated.

Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 checkpoint/objhash.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c
index a410346..9750483 100644
--- a/checkpoint/objhash.c
+++ b/checkpoint/objhash.c
@@ -34,6 +34,7 @@ struct ckpt_obj_ops {
 	int (*ref_users)(void *ptr);
 	int (*checkpoint)(struct ckpt_ctx *ctx, void *ptr);
 	void *(*restore)(struct ckpt_ctx *ctx);
+	void (*cleanup)(void *ptr);
 };
 
 struct ckpt_obj {
@@ -399,6 +400,8 @@ static void obj_hash_clear(struct ckpt_obj_hash *obj_hash)
 
 	for (i = 0; i < CKPT_OBJ_HASH_TOTAL; i++) {
 		hlist_for_each_entry_safe(obj, n, t, &h[i], hash) {
+			if (obj->ops->cleanup)
+				obj->ops->cleanup(obj->ptr);
 			obj->ops->ref_drop(obj->ptr);
 			kfree(obj);
 		}
-- 
1.6.2.5

  parent reply	other threads:[~2009-09-15 16:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 16:52 Avoid leaking unattached socket objects on restore Dan Smith
     [not found] ` <1253033531-6764-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-09-15 16:52   ` Dan Smith [this message]
2009-09-15 16:52   ` [PATCH 2/2] Add a cleanup routine for objhash socket objects Dan Smith
     [not found]     ` <1253033531-6764-3-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-09-15 20:04       ` Serge E. Hallyn
2009-09-15 20:21       ` Matt Helsley
     [not found]         ` <20090915202118.GC10922-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-09-15 20:38           ` Dan Smith
     [not found]             ` <87eiq8j653.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-09-15 21:51               ` Oren Laadan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1253033531-6764-2-git-send-email-danms@us.ibm.com \
    --to=danms-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox