Remove the global variable "chain_size"
authorVolker Lendecke <vl@samba.org>
Fri, 30 Jan 2009 22:44:21 +0000 (23:44 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 31 Jan 2009 10:09:39 +0000 (11:09 +0100)
source3/include/proto.h
source3/include/smb.h
source3/include/smb_macros.h
source3/lib/util.c
source3/smbd/aio.c
source3/smbd/blocking.c
source3/smbd/process.c
source3/smbd/reply.c

index c10db31d2acc8317e3495c810eec3d8304185ccf..d58dcef0b48f38b3cf565ce6f968c58b75199f9f 100644 (file)
@@ -7201,6 +7201,7 @@ void remove_from_common_flags2(uint32 v);
 void construct_reply_common_req(struct smb_request *req, char *outbuf);
 size_t req_wct_ofs(struct smb_request *req);
 void chain_reply(struct smb_request *req);
+bool req_is_in_chain(struct smb_request *req);
 void check_reload(time_t t);
 void smbd_process(void);
 
@@ -7275,6 +7276,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
                          uint32 dirtype, const char *name_in, bool has_wild);
 void reply_unlink(struct smb_request *req);
 void send_file_readbraw(connection_struct *conn,
+                       struct smb_request *req,
                        files_struct *fsp,
                        SMB_OFF_T startpos,
                        size_t nread,
index 94517102559e4def50391f7c1724ac0f5924c307..be6ccbf59795d47b2d6e0cfa9fb150462cc3aac1 100644 (file)
@@ -1549,11 +1549,6 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
  */
 #define COPYBUF_SIZE (8*1024)
 
-/*
- * Used in chaining code.
- */
-extern int chain_size;
-
 /*
  * Map the Core and Extended Oplock requesst bits down
  * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
index 92c60a7530da77950b2f4600a3a90c4aade65b67..fd1bba16a7a319111699d981f5bffd7c5424be5d 100644 (file)
 
 
 /* Note that chain_size must be available as an extern int to this macro. */
-#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size)
+#define smb_offset(p,buf) (PTR_DIFF(p,buf+4))
 
 #define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16))
 #define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \
index 195065a1e0bd13118efe55c26d3d948da899b3e8..df01c0306f9e7a5c57ec6d6e1c873ba6d43cbfdf 100644 (file)
@@ -57,9 +57,6 @@ extern unsigned int global_clobber_region_line;
 
 enum protocol_types Protocol = PROTOCOL_COREPLUS;
 
-/* this is used by the chaining code */
-int chain_size = 0;
-
 static enum remote_arch_types ra_type = RA_UNKNOWN;
 
 /***********************************************************************
index 4ce43c95e80f2cd04bf5b84e4be5d90f80d8d530..64d512d675dd34cd3a077942cc218d85934165bb 100644 (file)
@@ -141,8 +141,7 @@ bool schedule_aio_read_and_X(connection_struct *conn,
 
        /* Only do this on non-chained and non-chaining reads not using the
         * write cache. */
-        if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
-           || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+        if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
                return False;
        }
 
@@ -238,8 +237,7 @@ bool schedule_aio_write_and_X(connection_struct *conn,
 
        /* Only do this on non-chained and non-chaining reads not using the
         * write cache. */
-        if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
-           || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+        if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
                return False;
        }
 
index 9936fb219fce01c88271aa9a220a9b476c0d686c..ac1ff008589c9fc787cdfa045d950c6f3a1030ad 100644 (file)
@@ -47,11 +47,6 @@ typedef struct blocking_lock_record {
  Determine if this is a secondary element of a chained SMB.
   **************************************************************************/
 
-static bool in_chained_smb(void)
-{
-       return (chain_size != 0);
-}
-
 static void received_unlock_msg(struct messaging_context *msg,
                                void *private_data,
                                uint32_t msg_type,
@@ -144,7 +139,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
        blocking_lock_record *blr;
        NTSTATUS status;
 
-       if(in_chained_smb() ) {
+       if(req_is_in_chain(req)) {
                DEBUG(0,("push_blocking_lock_request: cannot queue a chained request (currently).\n"));
                return False;
        }
index d617ef19157e864b695eded741136a977dd6fa5d..c9fc1fbb6a53c3b5b76a1da33c93456240a237ce 100644 (file)
@@ -1359,8 +1359,6 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc
        connection_struct *conn;
        struct smb_request *req;
 
-       chain_size = 0;
-
        if (!(req = talloc(talloc_tos(), struct smb_request))) {
                smb_panic("could not allocate smb_request");
        }
@@ -2114,3 +2112,27 @@ void smbd_process(void)
 
        exit_server_cleanly(NULL);
 }
+
+bool req_is_in_chain(struct smb_request *req)
+{
+       if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+               /*
+                * We're right now handling a subsequent request, so we must
+                * be in a chain
+                */
+               return true;
+       }
+
+       if (!is_andx_req(req->cmd)) {
+               return false;
+       }
+
+       if (req->wct < 2) {
+               /*
+                * Okay, an illegal request, but definitely not chained :-)
+                */
+               return false;
+       }
+
+       return (CVAL(req->vwv+0, 0) != 0xFF);
+}
index 25d50470ff8f0edeb965803b93d9bee68944df01..eeb6692eb5c8f47d547c4d9c8dcd3ef2d4e1be2b 100644 (file)
@@ -2729,6 +2729,7 @@ static void reply_readbraw_error(void)
 ****************************************************************************/
 
 void send_file_readbraw(connection_struct *conn,
+                       struct smb_request *req,
                        files_struct *fsp,
                        SMB_OFF_T startpos,
                        size_t nread,
@@ -2745,7 +2746,7 @@ void send_file_readbraw(connection_struct *conn,
         * reply_readbraw has already checked the length.
         */
 
-       if ( (chain_size == 0) && (nread > 0) && (fsp->base_fsp == NULL) &&
+       if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) &&
            (fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) {
                ssize_t sendfile_read = -1;
                char header[4];
@@ -2963,7 +2964,7 @@ void reply_readbraw(struct smb_request *req)
                (unsigned long)mincount,
                (unsigned long)nread ) );
 
-       send_file_readbraw(conn, fsp, startpos, nread, mincount);
+       send_file_readbraw(conn, req, fsp, startpos, nread, mincount);
 
        DEBUG(5,("reply_readbraw finished\n"));
        END_PROFILE(SMBreadbraw);
@@ -3229,7 +3230,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
         * on a train in Germany :-). JRA.
         */
 
-       if ((chain_size == 0) && (CVAL(req->vwv+0, 0) == 0xFF) &&
+       if (!req_is_in_chain(req) &&
            !is_encrypted_packet(req->inbuf) && (fsp->base_fsp == NULL) &&
            lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
                uint8 headerbuf[smb_size + 12 * 2];