]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix fh leak in non-create case
authorSage Weil <sage@inktank.com>
Fri, 28 Dec 2012 23:14:25 +0000 (15:14 -0800)
committerSage Weil <sage@inktank.com>
Fri, 28 Dec 2012 23:14:25 +0000 (15:14 -0800)
We may take the O_CREAT path and get an fh from _create, but created can
still be false.  In that case, skip the final _open call.

Signed-off-by: Sage Weil <sage@inktank.com>
src/client/Client.cc

index c066a2bd90c5556b91140859baa2a0ced71643c7..aaa1c1614a45fae9ea5e2444ef9dfee7a9ddd792 100644 (file)
@@ -7169,6 +7169,8 @@ int Client::ll_create(vinodeno_t parent, const char *name, mode_t mode, int flag
   tout(cct) << mode << std::endl;
   tout(cct) << flags << std::endl;
 
+  *fhp = NULL;
+
   bool created = false;
   Inode *in = NULL;
   Inode *dir = _ll_get_inode(parent);
@@ -7199,9 +7201,11 @@ int Client::ll_create(vinodeno_t parent, const char *name, mode_t mode, int flag
     if (r < 0)
       goto out;
 
-    r = _open(in, flags, mode, fhp);
-    if (r < 0)
-      goto out;
+    if (*fhp == NULL) {
+      r = _open(in, flags, mode, fhp);
+      if (r < 0)
+       goto out;
+    }
   }
 
 out: