mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
r4186: Fix client & server to allow 127k READX calls.
Jeremy.
(This used to be commit 831cb21a87
)
This commit is contained in:
parent
00eede9a6b
commit
5b713a206b
@ -27,7 +27,7 @@
|
||||
overlap on the wire. This size gives us a nice read/write size, which
|
||||
will be a multiple of the page size on almost any system */
|
||||
#define CLI_BUFFER_SIZE (0xFFFF)
|
||||
|
||||
#define CLI_MAX_LARGE_READX_SIZE (127*1024)
|
||||
|
||||
/*
|
||||
* These definitions depend on smb.h
|
||||
|
@ -151,12 +151,7 @@ static uint32 cli_session_setup_capabilities(struct cli_state *cli)
|
||||
if (cli->use_level_II_oplocks)
|
||||
capabilities |= CAP_LEVEL_II_OPLOCKS;
|
||||
|
||||
if (cli->capabilities & CAP_UNICODE)
|
||||
capabilities |= CAP_UNICODE;
|
||||
|
||||
if (cli->capabilities & CAP_LARGE_FILES)
|
||||
capabilities |= CAP_LARGE_FILES;
|
||||
|
||||
capabilities |= (cli->capabilities & (CAP_UNICODE|CAP_LARGE_FILES|CAP_LARGE_READX|CAP_LARGE_WRITEX));
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@ -1134,6 +1129,14 @@ BOOL cli_negprot(struct cli_state *cli)
|
||||
cli->sign_info.negotiated_smb_signing = True;
|
||||
}
|
||||
|
||||
if (cli->capabilities & (CAP_LARGE_READX|CAP_LARGE_WRITEX)) {
|
||||
SAFE_FREE(cli->outbuf);
|
||||
SAFE_FREE(cli->inbuf);
|
||||
cli->outbuf = (char *)SMB_MALLOC(CLI_MAX_LARGE_READX_SIZE+SAFETY_MARGIN);
|
||||
cli->inbuf = (char *)SMB_MALLOC(CLI_MAX_LARGE_READX_SIZE+SAFETY_MARGIN);
|
||||
cli->bufsize = CLI_MAX_LARGE_READX_SIZE;
|
||||
}
|
||||
|
||||
} else if (cli->protocol >= PROTOCOL_LANMAN1) {
|
||||
cli->use_spnego = False;
|
||||
cli->sec_mode = SVAL(cli->inbuf,smb_vwv1);
|
||||
|
@ -48,6 +48,7 @@ static BOOL cli_issue_read(struct cli_state *cli, int fnum, off_t offset,
|
||||
SIVAL(cli->outbuf,smb_vwv3,offset);
|
||||
SSVAL(cli->outbuf,smb_vwv5,size);
|
||||
SSVAL(cli->outbuf,smb_vwv6,size);
|
||||
SSVAL(cli->outbuf,smb_vwv7,((size >> 16) & 1));
|
||||
SSVAL(cli->outbuf,smb_mid,cli->mid + i);
|
||||
|
||||
if (bigoffset)
|
||||
@ -75,7 +76,11 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
|
||||
* rounded down to a multiple of 1024.
|
||||
*/
|
||||
|
||||
readsize = (cli->max_xmit - (smb_size+32)) & ~1023;
|
||||
if (cli->capabilities & CAP_LARGE_READX) {
|
||||
readsize = CLI_MAX_LARGE_READX_SIZE;
|
||||
} else {
|
||||
readsize = (cli->max_xmit - (smb_size+32)) & ~1023;
|
||||
}
|
||||
|
||||
while (total < size) {
|
||||
readsize = MIN(readsize, size-total);
|
||||
@ -117,6 +122,7 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
|
||||
}
|
||||
|
||||
size2 = SVAL(cli->inbuf, smb_vwv5);
|
||||
size2 |= (SVAL(cli->inbuf, smb_vwv7) & 1);
|
||||
|
||||
if (size2 > readsize) {
|
||||
DEBUG(5,("server returned more than we wanted!\n"));
|
||||
|
@ -1177,8 +1177,7 @@ int chain_reply(char *inbuf,char *outbuf,int size,int bufsize)
|
||||
int outsize2;
|
||||
char inbuf_saved[smb_wct];
|
||||
char outbuf_saved[smb_wct];
|
||||
int wct = CVAL(outbuf,smb_wct);
|
||||
int outsize = smb_size + 2*wct + SVAL(outbuf,smb_vwv0+2*wct);
|
||||
int outsize = smb_len(outbuf);
|
||||
|
||||
/* maybe its not chained */
|
||||
if (smb_com2 == 0xFF) {
|
||||
|
@ -2148,6 +2148,7 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length
|
||||
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) & 1));
|
||||
SSVAL(smb_buf(outbuf),-2,smb_maxcnt);
|
||||
SCVAL(outbuf,smb_vwv0,0xFF);
|
||||
set_message(outbuf,12,smb_maxcnt,False);
|
||||
@ -2196,9 +2197,11 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
set_message(outbuf,12,nread,False);
|
||||
SSVAL(outbuf,smb_vwv2,0xFFFF); /* Remaining - must be -1. */
|
||||
SSVAL(outbuf,smb_vwv5,nread);
|
||||
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
|
||||
SSVAL(outbuf,smb_vwv7,((nread >> 16) & 1));
|
||||
SSVAL(smb_buf(outbuf),-2,nread);
|
||||
|
||||
DEBUG( 3, ( "send_file_readX fnum=%d max=%d nread=%d\n",
|
||||
|
Loading…
Reference in New Issue
Block a user