diff options
author | Jeremy Allison <jra@samba.org> | 2013-04-08 10:49:03 -0700 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2013-04-25 14:39:27 +0200 |
commit | 7e140cf2aa36334991b3f71c7fca6d2b8bca0e67 (patch) | |
tree | 59d28a068753fc8794f8f5a80f24cb31d940f2dc | |
parent | 05e8a7892494502d27e34e142ffb1a9883d8ea49 (diff) | |
download | samba-7e140cf2aa36334991b3f71c7fca6d2b8bca0e67.tar.gz |
Ensure the RECVFILE path in vfs_pwrite_data() operates on a blocking socket.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Apr 20 01:04:05 CEST 2013 on sn-devel-104
(cherry picked from commit 95f7fc83b251efefcc2a603b936b55e2f0308a72)
The last 13 patches address bug #9412 - SMB2 server doesn't support recvfile.
Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-0-test): Thu Apr 25 14:39:27 CEST 2013 on sn-devel-104
-rw-r--r-- | source3/smbd/vfs.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 30899ef5f50..124981c9941 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -472,14 +472,25 @@ ssize_t vfs_pwrite_data(struct smb_request *req, ssize_t ret; if (req && req->unread_bytes) { + int sockfd = req->sconn->sock; + int old_flags; SMB_ASSERT(req->unread_bytes == N); /* VFS_RECVFILE must drain the socket * before returning. */ req->unread_bytes = 0; - return SMB_VFS_RECVFILE(req->sconn->sock, + /* Ensure the socket is blocking. */ + old_flags = fcntl(sockfd, F_GETFL, 0); + if (set_blocking(sockfd, true) == -1) { + return (ssize_t)-1; + } + ret = SMB_VFS_RECVFILE(sockfd, fsp, offset, N); + if (fcntl(sockfd, F_SETFL, old_flags) == -1) { + return (ssize_t)-1; + } + return ret; } while (total < N) { |