svn commit: samba r24348 - in branches/SAMBA_3_2/source/smbd: .
vlendec at samba.org
vlendec at samba.org
Sun Aug 12 11:40:32 GMT 2007
Author: vlendec
Date: 2007-08-12 11:40:27 +0000 (Sun, 12 Aug 2007)
New Revision: 24348
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24348
Log:
Do not use inbuf/outbuf in the sendfile path of read_and_X
Modified:
branches/SAMBA_3_2/source/smbd/reply.c
Changeset:
Modified: branches/SAMBA_3_2/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/reply.c 2007-08-12 11:22:26 UTC (rev 24347)
+++ branches/SAMBA_3_2/source/smbd/reply.c 2007-08-12 11:40:27 UTC (rev 24348)
@@ -2731,15 +2731,17 @@
static int setup_readX_header(char *inbuf, char *outbuf, size_t smb_maxcnt)
{
int outsize;
- char *data = smb_buf(outbuf);
+ char *data;
+ outsize = set_message(inbuf, outbuf,12,smb_maxcnt,False);
+ data = smb_buf(outbuf);
+
SSVAL(outbuf,smb_vwv2,0xFFFF); /* Remaining - must be -1. */
SSVAL(outbuf,smb_vwv5,smb_maxcnt);
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
SSVAL(outbuf,smb_vwv7,(smb_maxcnt >> 16));
SSVAL(smb_buf(outbuf),-2,smb_maxcnt);
SCVAL(outbuf,smb_vwv0,0xFF);
- outsize = set_message(inbuf, outbuf,12,smb_maxcnt,False);
/* Reset the outgoing length, set_message truncates at 0x1FFFF. */
_smb_setlen_large(outbuf,(smb_size + 12*2 + smb_maxcnt - 4));
return outsize;
@@ -2759,15 +2761,6 @@
char *inbuf, *outbuf;
int length, len_outbuf;
- if (!reply_prep_legacy(req, &inbuf, &outbuf, &length, &len_outbuf)) {
- reply_nterror(req, NT_STATUS_NO_MEMORY);
- return;
- }
-
- set_message(inbuf, outbuf, 12, 0, True);
-
- data = smb_buf(outbuf);
-
if(SMB_VFS_FSTAT(fsp,fsp->fh->fd, &sbuf) == -1) {
reply_unixerror(req, ERRDOS, ERRnoaccess);
return;
@@ -2790,8 +2783,9 @@
* on a train in Germany :-). JRA.
*/
- if ((chain_size == 0) && (CVAL(inbuf,smb_vwv0) == 0xFF) &&
+ if ((chain_size == 0) && (CVAL(req->inbuf,smb_vwv0) == 0xFF) &&
lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
+ char headerbuf[smb_size + 12 * 2];
DATA_BLOB header;
/*
@@ -2800,12 +2794,11 @@
* correct amount of data).
*/
- setup_readX_header(inbuf,outbuf,smb_maxcnt);
- set_message(inbuf,outbuf,12,smb_maxcnt,False);
- header.data = (uint8 *)outbuf;
- header.length = data - outbuf;
- header.free = NULL;
+ header = data_blob_const(headerbuf, sizeof(headerbuf));
+ construct_reply_common((char *)req->inbuf, headerbuf);
+ setup_readX_header((char *)req->inbuf, headerbuf, smb_maxcnt);
+
if ((nread = SMB_VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fh->fd, &header, startpos, smb_maxcnt)) == -1) {
/* Returning ENOSYS means no data at all was sent. Do this as a normal read. */
if (errno == ENOSYS) {
@@ -2852,6 +2845,15 @@
normal_read:
+ if (!reply_prep_legacy(req, &inbuf, &outbuf, &length, &len_outbuf)) {
+ reply_nterror(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+
+ set_message(inbuf, outbuf, 12, 0, True);
+
+ data = smb_buf(outbuf);
+
if ((smb_maxcnt & 0xFF0000) > 0x10000) {
int sendlen = setup_readX_header(inbuf,outbuf,smb_maxcnt) - smb_maxcnt;
/* Send out the header. */
More information about the samba-cvs
mailing list