summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/smbd/vfs.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index dd74d79880..49609d0179 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) {