s3/smbd: move requested_oplock_level into smbd_smb2_create_state
authorRalph Boehme <slow@samba.org>
Sat, 22 Jul 2017 16:40:16 +0000 (18:40 +0200)
committerRalph Boehme <slow@samba.org>
Sun, 23 Jul 2017 06:03:07 +0000 (08:03 +0200)
Signed-off-by: Ralph Boehme <slow@samba.org>
source3/smbd/smb2_create.c

index ff177dcd5ff36f7cf0a840e475a036fc1ad93ac1..e08a7e993bf0a7a6d76df4c38543594ccde16e4a 100644 (file)
@@ -438,6 +438,7 @@ struct smbd_smb2_create_state {
        struct deferred_open_record *open_rec;
        files_struct *result;
        bool replay_operation;
+       int requested_oplock_level;
        uint8_t out_oplock_level;
        uint32_t out_create_action;
        struct timespec out_creation_ts;
@@ -479,7 +480,6 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct smb_request *smb1req = NULL;
        int info;
-       int requested_oplock_level;
        struct smb2_create_blob *dhnc = NULL;
        struct smb2_create_blob *dh2c = NULL;
        struct smb2_create_blob *dhnq = NULL;
@@ -512,12 +512,6 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        struct smb2_create_blob *svhdx = NULL;
 #endif
 
-       if(lp_fake_oplocks(SNUM(smb2req->tcon->compat))) {
-               requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
-       } else {
-               requested_oplock_level = in_oplock_level;
-       }
-
        req = tevent_req_create(mem_ctx, &state,
                                struct smbd_smb2_create_state);
        if (req == NULL) {
@@ -553,6 +547,12 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        TALLOC_FREE(smb2req->subreq);
        smb2req->subreq = req;
 
+       if (lp_fake_oplocks(SNUM(smb2req->tcon->compat))) {
+               state->requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
+       } else {
+               state->requested_oplock_level = in_oplock_level;
+       }
+
        /* these are ignored for SMB2 */
        in_create_options &= ~(0x10);/* NTCREATEX_OPTIONS_SYNC_ALERT */
        in_create_options &= ~(0x20);/* NTCREATEX_OPTIONS_ASYNC_ALERT */
@@ -999,7 +999,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 
                if (!smb2_lease_key_valid(&lease.lease_key)) {
                        lease_ptr = NULL;
-                       requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
+                       state->requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
                }
 
                if ((smb2req->xconn->protocol < PROTOCOL_SMB3_00) &&
@@ -1123,9 +1123,9 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                struct smb_filename *smb_fname = NULL;
                uint32_t ucf_flags;
 
-               if (requested_oplock_level == SMB2_OPLOCK_LEVEL_LEASE) {
+               if (state->requested_oplock_level == SMB2_OPLOCK_LEVEL_LEASE) {
                        if (lease_ptr == NULL) {
-                               requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
+                               state->requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
                        }
                } else {
                        lease_ptr = NULL;
@@ -1200,7 +1200,8 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                                             in_create_disposition,
                                             in_create_options,
                                             in_file_attributes,
-                                            map_smb2_oplock_levels_to_samba(requested_oplock_level),
+                                            map_smb2_oplock_levels_to_samba(
+                                                    state->requested_oplock_level),
                                             lease_ptr,
                                             allocation_size,
                                             0, /* private_flags */