]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move handling the 1sec sharing_violation delay into smb1 code
authorVolker Lendecke <vl@samba.org>
Tue, 30 Jul 2019 12:54:40 +0000 (14:54 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 7 Aug 2019 23:45:50 +0000 (23:45 +0000)
Simplify the flow in open_file_ntcreate, streamline it for SMB2

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/reply.c
source3/smbd/trans2.c

index 38d5b1f428b20591f90acd5612cff6ad63aed4ce..a083f3522619fc4614edd5da9e2c843bc6309110 100644 (file)
@@ -591,6 +591,12 @@ void reply_ntcreate_and_X(struct smb_request *req)
                        /* We have re-scheduled this call, no error. */
                        goto out;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
+               }
                reply_openerror(req, status);
                goto out;
        }
@@ -1243,6 +1249,12 @@ static void call_nt_transact_create(connection_struct *conn,
                        /* We have re-scheduled this call, no error. */
                        return;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               return;
+                       }
+               }
                reply_openerror(req, status);
                goto out;
        }
@@ -1732,6 +1744,12 @@ void reply_ntrename(struct smb_request *req)
                        /* We have re-scheduled this call. */
                        goto out;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
+               }
 
                reply_nterror(req, status);
                goto out;
index f54c8cf63134f1ea6d538702ab4b2af507a32a7a..e33c78748836d16840c96cd524c7de3cf6976fb9 100644 (file)
@@ -3506,38 +3506,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
                SMB_ASSERT(NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION));
 
-               /*
-                * If we're returning a share violation, ensure we
-                * cope with the braindead 1 second delay (SMB1 only).
-                */
-
-               if (!(oplock_request & INTERNAL_OPEN_ONLY) &&
-                   !conn->sconn->using_smb2 &&
-                   lp_defer_sharing_violations()) {
-                       struct timeval timeout;
-                       int timeout_usecs;
-
-                       /* this is a hack to speed up torture tests
-                          in 'make test' */
-                       timeout_usecs = lp_parm_int(SNUM(conn),
-                                                   "smbd","sharedelay",
-                                                   SHARING_VIOLATION_USEC_WAIT);
-
-                       /* This is a relative time, added to the absolute
-                          request_time value to get the absolute timeout time.
-                          Note that if this is the second or greater time we enter
-                          this codepath for this particular request mid then
-                          request_time is left as the absolute time of the *first*
-                          time this request mid was processed. This is what allows
-                          the request to eventually time out. */
-
-                       timeout = timeval_set(0, timeout_usecs);
-
-                       if (!request_timed_out(req, timeout)) {
-                               defer_open(lck, timeout, req, false, id);
-                       }
-               }
-
                TALLOC_FREE(lck);
                fd_close(fsp);
 
index 946acb130d5415cc3b1e15d38dedfeff156b6d96..5664090f38c7cf837a3a4d160b437b5f36f7a030 100644 (file)
@@ -2308,6 +2308,10 @@ void reply_open(struct smb_request *req)
                        create_options,
                        private_flags);
                if (fsp == NULL) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
                        reply_openerror(req, status);
                        goto out;
                }
@@ -2495,9 +2499,15 @@ void reply_open_and_X(struct smb_request *req)
                        create_options,
                        private_flags);
                if (fsp == NULL) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
                        reply_openerror(req, status);
                        goto out;
                }
+
+
                smb_action = FILE_WAS_OPENED;
        }
 
@@ -2748,6 +2758,12 @@ void reply_mknew(struct smb_request *req)
                        /* We have re-scheduled this call. */
                        goto out;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
+               }
                reply_openerror(req, status);
                goto out;
        }
@@ -2885,6 +2901,13 @@ void reply_ctemp(struct smb_request *req)
                                /* We have re-scheduled this call. */
                                goto out;
                        }
+                       if (NT_STATUS_EQUAL(
+                                   status, NT_STATUS_SHARING_VIOLATION)) {
+                               bool ok = defer_smb1_sharing_violation(req);
+                               if (ok) {
+                                       goto out;
+                               }
+                       }
                        reply_openerror(req, status);
                        goto out;
                }
@@ -3402,6 +3425,12 @@ void reply_unlink(struct smb_request *req)
                        /* We have re-scheduled this call. */
                        goto out;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
+               }
                reply_nterror(req, status);
                goto out;
        }
@@ -6545,6 +6574,12 @@ void reply_rmdir(struct smb_request *req)
                        /* We have re-scheduled this call. */
                        goto out;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
+               }
                reply_nterror(req, status);
                goto out;
        }
@@ -7678,6 +7713,12 @@ void reply_mv(struct smb_request *req)
                        /* We have re-scheduled this call. */
                        goto out;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
+               }
                reply_nterror(req, status);
                goto out;
        }
index 7351506272947b0d45a9d704805064cc619437de..d268558cfb8dde2d3a407533f676bc227778b515 100644 (file)
@@ -1454,9 +1454,14 @@ static void call_trans2open(connection_struct *conn,
                        create_options,
                        private_flags);
                if (fsp == NULL) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               goto out;
+                       }
                        reply_openerror(req, status);
                        goto out;
                }
+
                smb_action = FILE_WAS_OPENED;
        }
 
@@ -6370,6 +6375,12 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                        /* We have re-scheduled this call. */
                        return;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               return;
+                       }
+               }
                reply_nterror(req, status);
                return;
        }
@@ -9322,6 +9333,12 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                        /* We have re-scheduled this call. */
                        return;
                }
+               if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+                       bool ok = defer_smb1_sharing_violation(req);
+                       if (ok) {
+                               return;
+                       }
+               }
                if (NT_STATUS_EQUAL(status, NT_STATUS_EVENT_PENDING)) {
                        /* We have re-scheduled this call. */
                        return;