s3:smbd: move max_recv to struct smbd_server_connection
authorStefan Metzmacher <metze@samba.org>
Tue, 26 May 2009 12:56:08 +0000 (14:56 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Jun 2009 15:54:37 +0000 (17:54 +0200)
metze

source3/smbd/globals.c
source3/smbd/globals.h
source3/smbd/negprot.c
source3/smbd/process.c
source3/smbd/reply.c

index 8126989bbf187088b9c9483196f273c6974296b2..6c34f9d44b3750edfe444258bd51ecbf1a5912b6 100644 (file)
@@ -115,11 +115,6 @@ bool already_got_session = false;
  *  Set by us for CORE protocol.
  */
 int max_send = BUFFER_SIZE;
-/*
- * Size of the data we can receive. Set by us.
- * Can be modified by the max xmit parameter.
- */
-int max_recv = BUFFER_SIZE;
 uint16 last_session_tag = UID_FIELD_INVALID;
 int trans_num = 0;
 pid_t mypid = 0;
index 46c52fea12044d05d75e8ed031acd034f3bcb74c..e8f26a98d02c8e75ed4b5d11e6e5b76d7dfd5379 100644 (file)
@@ -113,11 +113,6 @@ extern bool already_got_session;
  *  Set by us for CORE protocol.
  */
 extern int max_send;
-/*
- * Size of the data we can receive. Set by us.
- * Can be modified by the max xmit parameter.
- */
-extern int max_recv;
 extern uint16 last_session_tag;
 extern int trans_num;
 
@@ -330,6 +325,11 @@ struct smbd_server_connection {
                        bool spnego;
                        struct auth_context *auth_context;
                        bool done;
+                       /*
+                        * Size of the data we can receive. Set by us.
+                        * Can be modified by the max xmit parameter.
+                        */
+                       int max_recv;
                } negprot;
 
                struct smb_signing_state *signing_state;
index 4e14ee8aad4380dafc3ad345677d6febb93e32bb..85dc32447db81c395304517bab686aceb73770b1 100644 (file)
@@ -117,7 +117,7 @@ static void reply_lanman1(struct smb_request *req, uint16 choice)
 
        /* Reply, SMBlockread, SMBwritelock supported. */
        SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
-       SSVAL(req->outbuf,smb_vwv2,max_recv);
+       SSVAL(req->outbuf,smb_vwv2,sconn->smb1.negprot.max_recv);
        SSVAL(req->outbuf,smb_vwv3,lp_maxmux()); /* maxmux */
        SSVAL(req->outbuf,smb_vwv4,1);
        SSVAL(req->outbuf,smb_vwv5,raw); /* tell redirector we support
@@ -166,7 +166,7 @@ static void reply_lanman2(struct smb_request *req, uint16 choice)
 
        /* Reply, SMBlockread, SMBwritelock supported. */
        SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
-       SSVAL(req->outbuf,smb_vwv2,max_recv);
+       SSVAL(req->outbuf,smb_vwv2,sconn->smb1.negprot.max_recv);
        SSVAL(req->outbuf,smb_vwv3,lp_maxmux());
        SSVAL(req->outbuf,smb_vwv4,1);
        SSVAL(req->outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */
@@ -348,7 +348,8 @@ static void reply_nt1(struct smb_request *req, uint16 choice)
        
        SSVAL(req->outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */
        SSVAL(req->outbuf,smb_vwv2+1,1); /* num vcs */
-       SIVAL(req->outbuf,smb_vwv3+1,max_recv); /* max buffer. LOTS! */
+       SIVAL(req->outbuf,smb_vwv3+1,
+             sconn->smb1.negprot.max_recv); /* max buffer. LOTS! */
        SIVAL(req->outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
        SIVAL(req->outbuf,smb_vwv7+1,sys_getpid()); /* session key */
        SIVAL(req->outbuf,smb_vwv9+1,capabilities); /* capabilities */
index f63e36a62b16a1275ff3ef9254d38d4b15e4fa69..4c33257b9d425bf27f8d67781052a70a5674ff00 100644 (file)
@@ -2157,7 +2157,7 @@ void smbd_process(void)
 
 #endif
 
-       max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
+       smbd_server_conn->smb1.negprot.max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
 
        smbd_server_conn->smb1.fde = event_add_fd(smbd_event_context(),
                                                  smbd_server_conn,
index f6d5f11f13af4fd08b263f437b82851440e8bb23..16fc61955d8a49cb4411f7ccd6cbdd62c0a80c1a 100644 (file)
@@ -611,6 +611,7 @@ void reply_tcon(struct smb_request *req)
        const char *p;
        DATA_BLOB password_blob;
        TALLOC_CTX *ctx = talloc_tos();
+       struct smbd_server_connection *sconn = smbd_server_conn;
 
        START_PROFILE(SMBtcon);
 
@@ -654,7 +655,7 @@ void reply_tcon(struct smb_request *req)
        }
 
        reply_outbuf(req, 2, 0);
-       SSVAL(req->outbuf,smb_vwv0,max_recv);
+       SSVAL(req->outbuf,smb_vwv0,sconn->smb1.negprot.max_recv);
        SSVAL(req->outbuf,smb_vwv1,conn->cnum);
        SSVAL(req->outbuf,smb_tid,conn->cnum);
 
@@ -3154,6 +3155,7 @@ void reply_lockread(struct smb_request *req)
        files_struct *fsp;
        struct byte_range_lock *br_lck = NULL;
        char *p = NULL;
+       struct smbd_server_connection *sconn = smbd_server_conn;
 
        START_PROFILE(SMBlockread);
 
@@ -3216,11 +3218,12 @@ void reply_lockread(struct smb_request *req)
         * However the requested READ size IS affected by max_recv. Insanity.... JRA.
         */
 
-       if (numtoread > max_recv) {
+       if (numtoread > sconn->smb1.negprot.max_recv) {
                DEBUG(0,("reply_lockread: requested read size (%u) is greater than maximum allowed (%u). \
 Returning short read of maximum allowed for compatibility with Windows 2000.\n",
-                       (unsigned int)numtoread, (unsigned int)max_recv ));
-               numtoread = MIN(numtoread,max_recv);
+                       (unsigned int)numtoread,
+                       (unsigned int)sconn->smb1.negprot.max_recv));
+               numtoread = MIN(numtoread, sconn->smb1.negprot.max_recv);
        }
        nread = read_file(fsp,data,startpos,numtoread);
 
@@ -3262,6 +3265,7 @@ void reply_read(struct smb_request *req)
        int outsize = 0;
        files_struct *fsp;
        struct lock_struct lock;
+       struct smbd_server_connection *sconn = smbd_server_conn;
 
        START_PROFILE(SMBread);
 
@@ -3292,11 +3296,12 @@ void reply_read(struct smb_request *req)
        /*
         * The requested read size cannot be greater than max_recv. JRA.
         */
-       if (numtoread > max_recv) {
+       if (numtoread > sconn->smb1.negprot.max_recv) {
                DEBUG(0,("reply_read: requested read size (%u) is greater than maximum allowed (%u). \
 Returning short read of maximum allowed for compatibility with Windows 2000.\n",
-                       (unsigned int)numtoread, (unsigned int)max_recv ));
-               numtoread = MIN(numtoread,max_recv);
+                       (unsigned int)numtoread,
+                       (unsigned int)sconn->smb1.negprot.max_recv));
+               numtoread = MIN(numtoread, sconn->smb1.negprot.max_recv);
        }
 
        reply_outbuf(req, 5, numtoread+3);