From 89c6aabb29db9b0892cbd05c97a05ed9c5c9b4e6 Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 15 Mar 2007 21:15:42 +0000 Subject: [PATCH] * fixed getdir() on empty dir shutdown hang in client git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1244 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/Client.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/trunk/ceph/client/Client.cc b/trunk/ceph/client/Client.cc index 822abfd2f9637..4e4a6a1b6b737 100644 --- a/trunk/ceph/client/Client.cc +++ b/trunk/ceph/client/Client.cc @@ -1769,6 +1769,14 @@ int Client::getdir(const char *relpath, map& contents) assert(diri); assert(diri->inode.mode & INODE_MODE_DIR); + // add . and ..? + string dot("."); + contents[dot] = diri->inode; + if (diri != root) { + string dotdot(".."); + contents[dotdot] = diri->dn->dir->parent_inode->inode; + } + if (!reply->get_dir_in().empty()) { // only open dir if we're actually adding stuff to it! Dir *dir = diri->open_dir(); @@ -1779,7 +1787,10 @@ int Client::getdir(const char *relpath, map& contents) for (list::const_iterator pin = reply->get_dir_in().begin(); pin != reply->get_dir_in().end(); ++pin, ++pdn) { - // count entries + if (*pdn == ".") + continue; + + // count entries res++; // put in cache @@ -1793,13 +1804,10 @@ int Client::getdir(const char *relpath, map& contents) // contents to caller too! contents[*pdn] = in->inode; } + if (dir->is_empty()) + close_dir(dir); } - // add .. too? - if (diri != root && diri->dn && diri->dn->dir) { - Inode *parent = diri->dn->dir->parent_inode; - contents[".."] = parent->inode; - } // FIXME: remove items in cache that weren't in my readdir? // *** -- 2.39.5