From 037afca5a5c9c2561e5072e118a8a384a01ee814 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 28 Feb 2008 10:47:14 +0100 Subject: [PATCH] server: Unlink remaining children inodes when deleting the parent. --- server/change.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/change.c b/server/change.c index 590a1cb6b61..22666213504 100644 --- a/server/change.c +++ b/server/change.c @@ -438,6 +438,7 @@ static void inode_set_name( struct inode *inode, const char *name ) static void free_inode( struct inode *inode ) { int subtree = 0, watches = 0; + struct inode *tmp, *next; struct dir *dir; LIST_FOR_EACH_ENTRY( dir, &inode->dirs, struct dir, in_entry ) @@ -448,7 +449,6 @@ static void free_inode( struct inode *inode ) if (!subtree && !inode->parent) { - struct inode *tmp, *next; LIST_FOR_EACH_ENTRY_SAFE( tmp, next, &inode->children, struct inode, ch_entry ) { @@ -464,6 +464,13 @@ static void free_inode( struct inode *inode ) if (inode->parent) list_remove( &inode->ch_entry ); + /* disconnect remaining children from the parent */ + LIST_FOR_EACH_ENTRY_SAFE( tmp, next, &inode->children, struct inode, ch_entry ) + { + list_remove( &tmp->ch_entry ); + tmp->parent = NULL; + } + if (inode->wd != -1) { inotify_remove_watch( get_unix_fd( inotify_fd ), inode->wd );