]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
* fixed getdir() on empty dir shutdown hang in client
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Thu, 15 Mar 2007 21:15:42 +0000 (21:15 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Thu, 15 Mar 2007 21:15:42 +0000 (21:15 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1244 29311d96-e01e-0410-9327-a35deaab8ce9

trunk/ceph/client/Client.cc

index 822abfd2f96371ee2eb4a0c2a01e5e9ab6066473..4e4a6a1b6b737a35a22b4d6126cae93b58184393 100644 (file)
@@ -1769,6 +1769,14 @@ int Client::getdir(const char *relpath, map<string,inode_t>& 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<string,inode_t>& contents)
       for (list<InodeStat*>::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<string,inode_t>& 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?
     // ***