From c18a62ee9d0a7c77e375b5dff3e144e53557ceaa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 12 Jun 2014 08:40:25 +0200 Subject: s3:smbd: pass smbXsrv_connection explicitly to fake_sendfile() In future (with multi-channel) a fsp can be used from multiple connections, we need to make it explicit on which we want to reply. Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Reviewed-by: Michael Adam --- source3/smbd/proto.h | 3 ++- source3/smbd/reply.c | 10 +++++----- source3/smbd/smb2_read.c | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index a44d1bd7884..3e15be02fa5 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -856,7 +856,8 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, uint32 dirtype, struct smb_filename *smb_fname, bool has_wild); void reply_unlink(struct smb_request *req); -ssize_t fake_sendfile(files_struct *fsp, off_t startpos, size_t nread); +ssize_t fake_sendfile(struct smbXsrv_connection *xconn, files_struct *fsp, + off_t startpos, size_t nread); void sendfile_short_send(files_struct *fsp, ssize_t nread, size_t headersize, diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index f3486668607..83df1044788 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3026,9 +3026,9 @@ static void fail_readraw(void) Fake (read/write) sendfile. Returns -1 on read or write fail. ****************************************************************************/ -ssize_t fake_sendfile(files_struct *fsp, off_t startpos, size_t nread) +ssize_t fake_sendfile(struct smbXsrv_connection *xconn, files_struct *fsp, + off_t startpos, size_t nread) { - struct smbXsrv_connection *xconn = fsp->conn->sconn->conn; size_t bufsize; size_t tosend = nread; char *buf; @@ -3239,7 +3239,7 @@ static void send_file_readbraw(connection_struct *conn, set_use_sendfile(SNUM(conn), False); DEBUG(0,("send_file_readbraw: sendfile not available. Faking..\n")); - if (fake_sendfile(fsp, startpos, nread) == -1) { + if (fake_sendfile(xconn, fsp, startpos, nread) == -1) { DEBUG(0,("send_file_readbraw: " "fake_sendfile failed for " "file %s (%s).\n", @@ -3774,7 +3774,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, /* Ensure we don't do this again. */ set_use_sendfile(SNUM(conn), False); DEBUG(0,("send_file_readX: sendfile not available. Faking..\n")); - nread = fake_sendfile(fsp, startpos, + nread = fake_sendfile(xconn, fsp, startpos, smb_maxcnt); if (nread == -1) { saved_errno = errno; @@ -3851,7 +3851,7 @@ normal_read: errno = saved_errno; exit_server_cleanly("send_file_readX sendfile failed"); } - nread = fake_sendfile(fsp, startpos, smb_maxcnt); + nread = fake_sendfile(xconn, fsp, startpos, smb_maxcnt); if (nread == -1) { saved_errno = errno; DEBUG(0,("send_file_readX: fake_sendfile failed for file " diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index 892fa1587d3..636f068c476 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -217,7 +217,7 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state) * Fake this up by doing read/write calls. */ set_use_sendfile(SNUM(fsp->conn), false); - nread = fake_sendfile(fsp, in_offset, in_length); + nread = fake_sendfile(xconn, fsp, in_offset, in_length); if (nread == -1) { saved_errno = errno; DEBUG(0,("smb2_sendfile_send_data: fake_sendfile " @@ -267,7 +267,7 @@ normal_read: smbXsrv_connection_dbg(xconn))); exit_server_cleanly("smb2_sendfile_send_data: write_data failed"); } - nread = fake_sendfile(fsp, in_offset, in_length); + nread = fake_sendfile(xconn, fsp, in_offset, in_length); if (nread == -1) { saved_errno = errno; DEBUG(0,("smb2_sendfile_send_data: fake_sendfile " -- cgit v1.2.1