NTSTATUS do_lock_spin(files_struct *fsp,connection_struct *conn, uint16 lock_pid, SMB_BIG_UINT count,SMB_BIG_UINT offset,enum brl_type lock_type) { int j, maxj = lp_lock_spin_count(); int sleeptime = lp_lock_sleep_time(); NTSTATUS status, ret; if (maxj <= 0) maxj = 1; ret = NT_STATUS_OK; /* to keep dumb compilers happy */ for (j = 0; j < maxj; j++) { status = do_lock(fsp, conn, lock_pid, count, offset, lock_type); if (!NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED) && !NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { return status; } /* if we do fail then return the first error code we got */ if (j == 0) { ret = status; } if (sleeptime) sys_usleep(sleeptime); } return ret; }
NTSTATUS do_lock_spin(files_struct *fsp, uint16 lock_pid, SMB_BIG_UINT count, SMB_BIG_UINT offset, enum brl_type lock_type, enum brl_flavour lock_flav, BOOL *my_lock_ctx) { int j, maxj = lp_lock_spin_count(); int sleeptime = lp_lock_sleep_time(); NTSTATUS status, ret; if (maxj <= 0) { maxj = 1; } ret = NT_STATUS_OK; /* to keep dumb compilers happy */ for (j = 0; j < maxj; j++) { status = do_lock(fsp, lock_pid, count, offset, lock_type, lock_flav, my_lock_ctx); if (!NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED) && !NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { return status; } /* if we do fail then return the first error code we got */ if (j == 0) { ret = status; /* Don't spin if we blocked ourselves. */ if (*my_lock_ctx) { return ret; } /* Only spin for Windows locks. */ if (lock_flav == POSIX_LOCK) { return ret; } } if (sleeptime) { sys_usleep(sleeptime); } } return ret; }