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-devel

[Xen-devel] [PATCH] fs-backend: add a backend cleanup function

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] fs-backend: add a backend cleanup function
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Mon, 7 Dec 2009 15:32:58 +0000
Delivery-date: Mon, 07 Dec 2009 07:29:54 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Hi all,
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>

---

diff -r b4c47cfbb9b1 tools/fs-back/fs-backend.c
--- a/tools/fs-back/fs-backend.c        Wed Dec 02 15:02:06 2009 +0000
+++ b/tools/fs-back/fs-backend.c        Wed Dec 02 16:57:15 2009 +0000
@@ -179,6 +179,7 @@
 
 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 @@
                 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 b4c47cfbb9b1 tools/fs-back/fs-backend.h
--- a/tools/fs-back/fs-backend.h        Wed Dec 02 15:02:06 2009 +0000
+++ b/tools/fs-back/fs-backend.h        Wed Dec 02 16:57:15 2009 +0000
@@ -67,6 +67,7 @@
 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 b4c47cfbb9b1 tools/fs-back/fs-xenbus.c
--- a/tools/fs-back/fs-xenbus.c Wed Dec 02 15:02:06 2009 +0000
+++ b/tools/fs-back/fs-xenbus.c Wed Dec 02 16:57:15 2009 +0000
@@ -204,6 +204,17 @@
     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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] fs-backend: add a backend cleanup function, Stefano Stabellini <=