[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] fs-backend: add a backend cleanup function
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |