WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] fs-backend: add a backend cleanup functio

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] fs-backend: add a backend cleanup function
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 08 Dec 2009 06:20:16 -0800
Delivery-date: Tue, 08 Dec 2009 06:20:23 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1260258315 0
# Node ID d988dd0f05f24ad3c5b1f6b84b28b8b3e93f6005
# Parent  696f94dfad26ca79f9d7b952df50e5d768339ea4
fs-backend: add a backend cleanup function

This patch implements a backend cleanup function in fs-backend so that
when the connection to the frontend is closed we don't leak nodes on
xenstore.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/fs-back/fs-backend.c |   14 +++++++++++++-
 tools/fs-back/fs-backend.h |    1 +
 tools/fs-back/fs-xenbus.c  |   11 +++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff -r 696f94dfad26 -r d988dd0f05f2 tools/fs-back/fs-backend.c
--- a/tools/fs-back/fs-backend.c        Tue Dec 08 07:44:45 2009 +0000
+++ b/tools/fs-back/fs-backend.c        Tue Dec 08 07:45:15 2009 +0000
@@ -179,6 +179,7 @@ void terminate_mount_request(struct fs_m
 
 static void free_mount_request(struct fs_mount *mount) {
     FS_DEBUG("free_mount_request %s\n", mount->frontend);
+    xenbus_free_backend_node(mount);
     free(mount->frontend);
     free(mount->requests);
     free(mount->freelist);
@@ -356,8 +357,19 @@ static void await_connections(void)
                 if((dom_id >= 0) && (export_id >= 0) && d == 'd') {
                     char *frontend = xs_read(xsh, XBT_NULL, 
watch_paths[XS_WATCH_PATH], NULL);
                     if (frontend) {
+                        char *p, *wp = strdup(watch_paths[XS_WATCH_PATH]);
                         handle_connection(dom_id, export_id, frontend);
-                        xs_rm(xsh, XBT_NULL, watch_paths[XS_WATCH_PATH]);
+                        xs_rm(xsh, XBT_NULL, wp);
+                        p = strrchr(wp, '/');
+                        if (p) {
+                            *p = '\0';
+                            p = strrchr(wp, '/');
+                            if (p) {
+                                *p = '\0';
+                                xs_rm(xsh, XBT_NULL, wp);
+                            }
+                        }
+                        free(wp);
                     }
                 }
             } else if (!strcmp(watch_paths[XS_WATCH_TOKEN], "frontend-state")) 
{
diff -r 696f94dfad26 -r d988dd0f05f2 tools/fs-back/fs-backend.h
--- a/tools/fs-back/fs-backend.h        Tue Dec 08 07:44:45 2009 +0000
+++ b/tools/fs-back/fs-backend.h        Tue Dec 08 07:45:15 2009 +0000
@@ -67,6 +67,7 @@ int xenbus_read_mount_request(struct fs_
 int xenbus_read_mount_request(struct fs_mount *mount, char *frontend);
 bool xenbus_write_backend_node(struct fs_mount *mount);
 bool xenbus_write_backend_state(struct fs_mount *mount, const char *state);
+void xenbus_free_backend_node(struct fs_mount *mount);
 int xenbus_frontend_state_changed(struct fs_mount *mount, const char 
*oldstate);
 bool xenbus_watch_frontend_state(struct fs_mount *mount);
 bool xenbus_unwatch_frontend_state(struct fs_mount *mount);
diff -r 696f94dfad26 -r d988dd0f05f2 tools/fs-back/fs-xenbus.c
--- a/tools/fs-back/fs-xenbus.c Tue Dec 08 07:44:45 2009 +0000
+++ b/tools/fs-back/fs-xenbus.c Tue Dec 08 07:45:15 2009 +0000
@@ -204,6 +204,17 @@ bool xenbus_write_backend_state(struct f
     return xs_write(xsh, XBT_NULL, node, state, strlen(state));
 }
 
+void xenbus_free_backend_node(struct fs_mount *mount)
+{
+    char node[1024];
+    int self_id;
+
+    assert(xsh != NULL);
+    self_id = get_self_id();
+    snprintf(node, sizeof(node), ROOT_NODE"/%d", mount->mount_id);
+    xs_rm(xsh, XBT_NULL, node);
+}
+
 bool xenbus_watch_frontend_state(struct fs_mount *mount)
 {
     char statepath[1024];

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] fs-backend: add a backend cleanup function, Xen patchbot-unstable <=