]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add check for _lseek() during _write() process 9586/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 8 Jun 2016 06:53:23 +0000 (14:53 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 8 Jun 2016 06:53:23 +0000 (14:53 +0800)
The _lseek() call may fail, which can cause uncertain
behaviour if the process goes on instead of returning
immediately.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/client/Client.cc

index 31cc936bce8dc43d0e2cf3d5756b00db7af4cf61..aa4b111f7394372b1cf82d85cc85837fa3c2574c 100644 (file)
@@ -8323,8 +8323,13 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
      * FIXME: this is racy in that we may block _after_ this point waiting for caps, and size may
      * change out from under us.
      */
-    if (f->flags & O_APPEND)
-      _lseek(f, 0, SEEK_END);
+    if (f->flags & O_APPEND) {
+      int r = _lseek(f, 0, SEEK_END);
+      if (r < 0) {
+        unlock_fh_pos(f);
+        return r;
+      }
+    }
     offset = f->pos;
     f->pos = offset+size;
     unlock_fh_pos(f);