mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
r1978: Roll it back until I do it right.... :-).
Jeremy.
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
776c28133d
commit
f16aa99f8c
@ -27,9 +27,8 @@ extern char *OutBuffer;
|
|||||||
notify. It consists of the requesting SMB and the expiry time.
|
notify. It consists of the requesting SMB and the expiry time.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
typedef struct _blocking_lock_record {
|
typedef struct {
|
||||||
struct _blocking_lock_record *next;
|
ubi_slNode msg_next;
|
||||||
struct _blocking_lock_record *prev;
|
|
||||||
int com_type;
|
int com_type;
|
||||||
files_struct *fsp;
|
files_struct *fsp;
|
||||||
time_t expire_time;
|
time_t expire_time;
|
||||||
@ -41,7 +40,7 @@ typedef struct _blocking_lock_record {
|
|||||||
int length;
|
int length;
|
||||||
} blocking_lock_record;
|
} blocking_lock_record;
|
||||||
|
|
||||||
static blocking_lock_record *blocking_lock_queue;
|
static ubi_slList blocking_lock_queue = { NULL, (ubi_slNodePtr)&blocking_lock_queue, 0};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Destructor for the above structure.
|
Destructor for the above structure.
|
||||||
@ -91,7 +90,7 @@ BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout,
|
|||||||
int lock_num, uint16 lock_pid, SMB_BIG_UINT offset, SMB_BIG_UINT count)
|
int lock_num, uint16 lock_pid, SMB_BIG_UINT offset, SMB_BIG_UINT count)
|
||||||
{
|
{
|
||||||
static BOOL set_lock_msg;
|
static BOOL set_lock_msg;
|
||||||
blocking_lock_record *blr, *tmp;
|
blocking_lock_record *blr;
|
||||||
BOOL my_lock_ctx = False;
|
BOOL my_lock_ctx = False;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
@ -137,7 +136,7 @@ BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout,
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLIST_ADD_END(blocking_lock_queue, blr, tmp);
|
ubi_slAddTail(&blocking_lock_queue, blr);
|
||||||
|
|
||||||
/* Ensure we'll receive messages when this is unlocked. */
|
/* Ensure we'll receive messages when this is unlocked. */
|
||||||
if (!set_lock_msg) {
|
if (!set_lock_msg) {
|
||||||
@ -517,10 +516,10 @@ static BOOL blocking_lock_record_process(blocking_lock_record *blr)
|
|||||||
|
|
||||||
void remove_pending_lock_requests_by_fid(files_struct *fsp)
|
void remove_pending_lock_requests_by_fid(files_struct *fsp)
|
||||||
{
|
{
|
||||||
blocking_lock_record *blr, *next = NULL;
|
blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
|
||||||
|
blocking_lock_record *prev = NULL;
|
||||||
|
|
||||||
for(blr = blocking_lock_queue; blr; blr = next) {
|
while(blr != NULL) {
|
||||||
next = blr->next;
|
|
||||||
if(blr->fsp->fnum == fsp->fnum) {
|
if(blr->fsp->fnum == fsp->fnum) {
|
||||||
|
|
||||||
DEBUG(10,("remove_pending_lock_requests_by_fid - removing request type %d for \
|
DEBUG(10,("remove_pending_lock_requests_by_fid - removing request type %d for \
|
||||||
@ -530,8 +529,13 @@ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
|
|||||||
blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum,
|
blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum,
|
||||||
blr->offset, blr->count, True, NULL, NULL);
|
blr->offset, blr->count, True, NULL, NULL);
|
||||||
|
|
||||||
free_blocking_lock_record(blr);
|
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
|
||||||
|
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prev = blr;
|
||||||
|
blr = (blocking_lock_record *)ubi_slNext(blr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,10 +545,10 @@ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
|
|||||||
|
|
||||||
void remove_pending_lock_requests_by_mid(int mid)
|
void remove_pending_lock_requests_by_mid(int mid)
|
||||||
{
|
{
|
||||||
blocking_lock_record *blr, *next = NULL;
|
blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
|
||||||
|
blocking_lock_record *prev = NULL;
|
||||||
|
|
||||||
for(blr = blocking_lock_queue; blr; blr = next) {
|
while(blr != NULL) {
|
||||||
next = blr->next;
|
|
||||||
if(SVAL(blr->inbuf,smb_mid) == mid) {
|
if(SVAL(blr->inbuf,smb_mid) == mid) {
|
||||||
files_struct *fsp = blr->fsp;
|
files_struct *fsp = blr->fsp;
|
||||||
|
|
||||||
@ -555,8 +559,13 @@ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
|
|||||||
brl_unlock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum,
|
brl_unlock(blr->fsp->dev, blr->fsp->inode, blr->fsp->fnum,
|
||||||
blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum,
|
blr->lock_pid, sys_getpid(), blr->fsp->conn->cnum,
|
||||||
blr->offset, blr->count, True, NULL, NULL);
|
blr->offset, blr->count, True, NULL, NULL);
|
||||||
free_blocking_lock_record(blr);
|
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
|
||||||
|
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prev = blr;
|
||||||
|
blr = (blocking_lock_record *)ubi_slNext(blr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +587,7 @@ unsigned blocking_locks_timeout(unsigned default_timeout)
|
|||||||
{
|
{
|
||||||
unsigned timeout = default_timeout;
|
unsigned timeout = default_timeout;
|
||||||
time_t t;
|
time_t t;
|
||||||
blocking_lock_record *blr = blocking_lock_queue;
|
blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst(&blocking_lock_queue);
|
||||||
|
|
||||||
/* note that we avoid the time() syscall if there are no blocking locks */
|
/* note that we avoid the time() syscall if there are no blocking locks */
|
||||||
if (!blr)
|
if (!blr)
|
||||||
@ -586,11 +595,12 @@ unsigned blocking_locks_timeout(unsigned default_timeout)
|
|||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
|
|
||||||
for (; blr; blr = blr->next) {
|
while (blr) {
|
||||||
if ((blr->expire_time != (time_t)-1) &&
|
if ((blr->expire_time != (time_t)-1) &&
|
||||||
(timeout > (blr->expire_time - t))) {
|
(timeout > (blr->expire_time - t))) {
|
||||||
timeout = blr->expire_time - t;
|
timeout = blr->expire_time - t;
|
||||||
}
|
}
|
||||||
|
blr = (blocking_lock_record *)ubi_slNext(blr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout < 1)
|
if (timeout < 1)
|
||||||
@ -605,19 +615,21 @@ unsigned blocking_locks_timeout(unsigned default_timeout)
|
|||||||
|
|
||||||
void process_blocking_lock_queue(time_t t)
|
void process_blocking_lock_queue(time_t t)
|
||||||
{
|
{
|
||||||
blocking_lock_record *blr, *next = NULL;
|
blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
|
||||||
|
blocking_lock_record *prev = NULL;
|
||||||
|
|
||||||
|
if(blr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go through the queue and see if we can get any of the locks.
|
* Go through the queue and see if we can get any of the locks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (blr = blocking_lock_queue; blr; blr = next) {
|
while(blr != NULL) {
|
||||||
connection_struct *conn = NULL;
|
connection_struct *conn = NULL;
|
||||||
uint16 vuid;
|
uint16 vuid;
|
||||||
files_struct *fsp = NULL;
|
files_struct *fsp = NULL;
|
||||||
|
|
||||||
next = blr->next;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure we don't have any old chain_fsp values
|
* Ensure we don't have any old chain_fsp values
|
||||||
* sitting around....
|
* sitting around....
|
||||||
@ -646,7 +658,8 @@ void process_blocking_lock_queue(time_t t)
|
|||||||
blr->offset, blr->count, True, NULL, NULL);
|
blr->offset, blr->count, True, NULL, NULL);
|
||||||
|
|
||||||
blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
|
blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
|
||||||
free_blocking_lock_record(blr);
|
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
|
||||||
|
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +675,8 @@ void process_blocking_lock_queue(time_t t)
|
|||||||
blr->lock_pid, sys_getpid(), conn->cnum,
|
blr->lock_pid, sys_getpid(), conn->cnum,
|
||||||
blr->offset, blr->count, True, NULL, NULL);
|
blr->offset, blr->count, True, NULL, NULL);
|
||||||
|
|
||||||
free_blocking_lock_record(blr);
|
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
|
||||||
|
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,7 +691,8 @@ void process_blocking_lock_queue(time_t t)
|
|||||||
blr->lock_pid, sys_getpid(), conn->cnum,
|
blr->lock_pid, sys_getpid(), conn->cnum,
|
||||||
blr->offset, blr->count, True, NULL, NULL);
|
blr->offset, blr->count, True, NULL, NULL);
|
||||||
|
|
||||||
free_blocking_lock_record(blr);
|
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
|
||||||
|
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
|
||||||
change_to_root_user();
|
change_to_root_user();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -694,8 +709,18 @@ void process_blocking_lock_queue(time_t t)
|
|||||||
blr->lock_pid, sys_getpid(), conn->cnum,
|
blr->lock_pid, sys_getpid(), conn->cnum,
|
||||||
blr->offset, blr->count, True, NULL, NULL);
|
blr->offset, blr->count, True, NULL, NULL);
|
||||||
|
|
||||||
free_blocking_lock_record(blr);
|
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
|
||||||
|
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
|
||||||
|
change_to_root_user();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
change_to_root_user();
|
change_to_root_user();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move to the next in the list.
|
||||||
|
*/
|
||||||
|
prev = blr;
|
||||||
|
blr = (blocking_lock_record *)ubi_slNext(blr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user