From 0187de2869f03614f99e61adf9c88f3e0bfb307d Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Sun, 16 Aug 2009 14:34:08 +0000 Subject: in server_rename if we do_path_lookup on the newloc and parent directory is not found, the server crashes. Signed-off-by: Anand V. Avati --- xlators/protocol/server/src/server-protocol.c | 52 ++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'xlators/protocol/server/src/server-protocol.c') diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c index 92ef6cfac..3bfffd700 100644 --- a/xlators/protocol/server/src/server-protocol.c +++ b/xlators/protocol/server/src/server-protocol.c @@ -2529,32 +2529,36 @@ server_stub_resume (call_stub_t *stub, int32_t op_ret, int32_t op_errno, switch (stub->fop) { case GF_FOP_RENAME: + if ((op_ret < 0 && stub->args.rename.old.inode == NULL) || + (op_ret < 0 && parent == NULL)) { + /* Either oldloc lookup failed OR newloc lookup + * failed and parent was not found + */ + gf_log (stub->frame->this->name, GF_LOG_DEBUG, + "%"PRId64": RENAME (%s -> %s) on %s " + "returning error: " + "%"PRId32" (%"PRId32")", + stub->frame->root->unique, + stub->args.rename.old.path, + stub->args.rename.new.path, + BOUND_XL(stub->frame)->name, + op_ret, op_errno); + + /* lookup of oldpath failed, UNWIND to + * server_rename_cbk with ret=-1 and + * errno=ENOENT + */ + server_rename_cbk (stub->frame, NULL, + stub->frame->this, + -1, ENOENT, NULL); + server_loc_wipe (&stub->args.rename.old); + server_loc_wipe (&stub->args.rename.new); + FREE (stub); + return 0; + } + if (stub->args.rename.old.inode == NULL) { /* now we are called by lookup of oldpath. */ - if (op_ret < 0) { - gf_log (stub->frame->this->name, GF_LOG_DEBUG, - "%"PRId64": RENAME (%s -> %s) on %s " - "returning error: " - "%"PRId32" (%"PRId32")", - stub->frame->root->unique, - stub->args.rename.old.path, - stub->args.rename.new.path, - BOUND_XL(stub->frame)->name, - op_ret, op_errno); - - /* lookup of oldpath failed, UNWIND to - * server_rename_cbk with ret=-1 and - * errno=ENOENT - */ - server_rename_cbk (stub->frame, NULL, - stub->frame->this, - -1, ENOENT, NULL); - server_loc_wipe (&stub->args.rename.old); - server_loc_wipe (&stub->args.rename.new); - FREE (stub); - return 0; - } - if (stub->args.rename.old.parent == NULL) stub->args.rename.old.parent = inode_ref (parent); -- cgit