Remove the chain_fsp global
authorVolker Lendecke <vl@samba.org>
Thu, 9 Oct 2008 14:55:56 +0000 (16:55 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 13 Oct 2008 17:32:39 +0000 (19:32 +0200)
source3/include/proto.h
source3/include/smb.h
source3/smbd/blocking.c
source3/smbd/files.c
source3/smbd/process.c

index f8d6f1033436cf7a96ea649205b7280cb634b740..66eb1b0facb3c234d4cfde3cecfcf5159f81d01f 100644 (file)
@@ -9594,7 +9594,6 @@ void file_sync_all(connection_struct *conn);
 void file_free(struct smb_request *req, files_struct *fsp);
 files_struct *file_fnum(uint16 fnum);
 files_struct *file_fsp(struct smb_request *req, uint16 fid);
-void file_chain_reset(void);
 NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *fsp,
                      uint32 access_mask, uint32 share_access,
                      uint32 create_options, files_struct **result);
index 6aca7526fd3e22db961ec3c8695e4197c2b8bf02..fb79e911216780a808a2019b609caf32df406845 100644 (file)
@@ -636,6 +636,7 @@ struct smb_request {
        size_t unread_bytes;
        bool encrypted;
        connection_struct *conn;
+       struct files_struct *chain_fsp;
 };
 
 /* Defines for the sent_oplock_break field above. */
index 479361a8c1020117f29c2d251dab1029c3f6e02d..9b9aa1697e2d79f6dee80330f5fa60c3eb888b92 100644 (file)
@@ -704,7 +704,6 @@ static void process_blocking_lock_queue(void)
                 * sitting around....
                 */
                chain_size = 0;
-               file_chain_reset();
                fsp = blr->fsp;
 
                conn = conn_find(SVAL(blr->inbuf,smb_tid));
index d77ee76be7461d07e60572185bce5b2ab9026cee..4a27d02cfec2891b1af1b3ff75ff86d4a300e3cf 100644 (file)
@@ -28,9 +28,6 @@ static int real_max_open_files;
 static struct bitmap *file_bmap;
 
 static files_struct *Files;
-/* a fsp to use when chaining */
-static files_struct *chain_fsp = NULL;
 
 static int files_used;
 
@@ -121,7 +118,9 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
        DEBUG(5,("allocated file structure %d, fnum = %d (%d used)\n",
                 i, fsp->fnum, files_used));
 
-       chain_fsp = fsp;
+       if (req != NULL) {
+               req->chain_fsp = fsp;
+       }
 
        /* A new fsp invalidates the positive and
          negative fsp_fi_cache as the new fsp is pushed
@@ -430,8 +429,8 @@ void file_free(struct smb_request *req, files_struct *fsp)
           information */
        ZERO_STRUCTP(fsp);
 
-       if (fsp == chain_fsp) {
-               chain_fsp = NULL;
+       if ((req != NULL) && (fsp == req->chain_fsp)) {
+               req->chain_fsp = NULL;
        }
 
        /* Closing a file can invalidate the positive cache. */
@@ -475,26 +474,17 @@ files_struct *file_fsp(struct smb_request *req, uint16 fid)
 {
        files_struct *fsp;
 
-       if (chain_fsp) {
-               return chain_fsp;
+       if ((req != NULL) && (req->chain_fsp != NULL)) {
+               return req->chain_fsp;
        }
 
        fsp = file_fnum(fid);
-       if (fsp) {
-               chain_fsp = fsp;
+       if ((fsp != NULL) && (req != NULL)) {
+               req->chain_fsp = fsp;
        }
        return fsp;
 }
 
-/****************************************************************************
- Reset the chained fsp - done at the start of a packet reply.
-****************************************************************************/
-
-void file_chain_reset(void)
-{
-       chain_fsp = NULL;
-}
-
 /****************************************************************************
  Duplicate the file handle part for a DOS or FCB open.
 ****************************************************************************/
index 32629fd3929191e9aa74d6b9a0266fac49dfdd4a..be45d7ad7cf4ff6c6ed341c96283e7c4a38fa815 100644 (file)
@@ -376,6 +376,7 @@ void init_smb_request(struct smb_request *req,
        req->unread_bytes = unread_bytes;
        req->encrypted = encrypted;
        req->conn = conn_find(req->tid);
+       req->chain_fsp = NULL;
 
        /* Ensure we have at least wct words and 2 bytes of bcc. */
        if (smb_size + req->wct*2 > req_size) {
@@ -1486,7 +1487,6 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc
        struct smb_request *req;
 
        chain_size = 0;
-       file_chain_reset();
        reset_chain_p();
 
        if (!(req = talloc(talloc_tos(), struct smb_request))) {
@@ -1733,6 +1733,7 @@ void chain_reply(struct smb_request *req)
                smb_panic("could not allocate smb_request");
        }
        init_smb_request(req2, (uint8 *)inbuf2,0, req->encrypted);
+       req2->chain_fsp = req->chain_fsp;
 
        /* process the request */
        switch_message(smb_com2, req2, new_size);