1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

r7972: Tidy up the posix locking in memory db code whilst I'm waiting for jht

to get back to me with a backtrace.
Jeremy.
(This used to be commit f2bcfdddc7)
This commit is contained in:
Jeremy Allison
2005-06-28 01:05:59 +00:00
committed by Gerald (Jerry) Carter
parent f2f55d703d
commit 3d306127aa

View File

@ -332,7 +332,7 @@ static BOOL delete_posix_lock_entry_by_index(files_struct *fsp, size_t entry)
if (entry < count-1) {
memmove(&locks[entry], &locks[entry+1], sizeof(*locks)*((count-1) - entry));
}
dbuf.dsize -= sizeof(*locks);
dbuf.dsize -= sizeof(struct posix_lock);
tdb_store(posix_lock_tdb, kbuf, dbuf, TDB_REPLACE);
}
@ -360,10 +360,11 @@ static BOOL add_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T s
char *tp;
dbuf.dptr = NULL;
dbuf.dsize = 0;
dbuf = tdb_fetch(posix_lock_tdb, kbuf);
*pentry_num = (size_t)(dbuf.dsize / sizeof(pl));
*pentry_num = (size_t)(dbuf.dsize / sizeof(struct posix_lock));
/*
* Add new record.
@ -374,15 +375,15 @@ static BOOL add_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T s
pl.size = size;
pl.lock_type = lock_type;
tp = SMB_REALLOC(dbuf.dptr, dbuf.dsize + sizeof(pl));
tp = SMB_REALLOC(dbuf.dptr, dbuf.dsize + sizeof(struct posix_lock));
if (!tp) {
DEBUG(0,("add_posix_lock_entry: Realloc fail !\n"));
goto fail;
} else
dbuf.dptr = tp;
memcpy(dbuf.dptr + dbuf.dsize, &pl, sizeof(pl));
dbuf.dsize += sizeof(pl);
memcpy(dbuf.dptr + dbuf.dsize, &pl, sizeof(struct posix_lock));
dbuf.dsize += sizeof(struct posix_lock);
if (tdb_store(posix_lock_tdb, kbuf, dbuf, TDB_REPLACE) == -1) {
DEBUG(0,("add_posix_lock: Failed to add lock entry on file %s\n", fsp->fsp_name));
@ -443,7 +444,7 @@ static int delete_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T
/* There are existing locks - find a match. */
locks = (struct posix_lock *)dbuf.dptr;
count = (size_t)(dbuf.dsize / sizeof(*locks));
count = (size_t)(dbuf.dsize / sizeof(struct posix_lock));
/*
* Search for and delete the first record that matches the
@ -466,9 +467,9 @@ static int delete_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T
tdb_delete(posix_lock_tdb, kbuf);
} else {
if (i < count-1) {
memmove(&locks[i], &locks[i+1], sizeof(*locks)*((count-1) - i));
memmove(&locks[i], &locks[i+1], sizeof(struct posix_lock)*((count-1) - i));
}
dbuf.dsize -= sizeof(*locks);
dbuf.dsize -= sizeof(struct posix_lock);
tdb_store(posix_lock_tdb, kbuf, dbuf, TDB_REPLACE);
}
count--;
@ -749,7 +750,7 @@ static struct lock_list *posix_lock_list(TALLOC_CTX *ctx, struct lock_list *lhea
return lhead;
locks = (struct posix_lock *)dbuf.dptr;
num_locks = (size_t)(dbuf.dsize / sizeof(*locks));
num_locks = (size_t)(dbuf.dsize / sizeof(struct posix_lock));
/*
* Check the current lock list on this dev/inode pair.