mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
smbd: Move handling the 1sec sharing_violation delay into smb1 code
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>
This commit is contained in:
parent
c7e110e51a
commit
4c08043ee5
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user