mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
Merge tridge's tdb updates.
Jeremy.
This commit is contained in:
parent
5ccf6baad7
commit
f81fdcc935
@ -372,7 +372,7 @@ int tdb_create_rwlocks(int fd, unsigned int hash_size)
|
||||
unsigned size, i;
|
||||
tdb_rwlock_t *rwlocks;
|
||||
|
||||
size = (hash_size + 1) * sizeof(tdb_rwlock_t);
|
||||
size = TDB_SPINLOCK_SIZE(hash_size);
|
||||
rwlocks = malloc(size);
|
||||
if (!rwlocks)
|
||||
return -1;
|
||||
|
@ -39,6 +39,8 @@ int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type);
|
||||
int tdb_create_rwlocks(int fd, unsigned int hash_size);
|
||||
int tdb_clear_spinlocks(TDB_CONTEXT *tdb);
|
||||
|
||||
#define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t))
|
||||
|
||||
#else /* !USE_SPINLOCKS */
|
||||
#if 0
|
||||
#define tdb_create_rwlocks(fd, hash_size) 0
|
||||
@ -50,6 +52,8 @@ int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type);
|
||||
int tdb_create_rwlocks(int fd, unsigned int hash_size);
|
||||
#endif
|
||||
int tdb_clear_spinlocks(TDB_CONTEXT *tdb);
|
||||
#define TDB_SPINLOCK_SIZE(hash_size) 0
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -77,6 +77,8 @@
|
||||
#define TDB_DEAD(r) ((r)->magic == TDB_DEAD_MAGIC)
|
||||
#define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
|
||||
#define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off))
|
||||
#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + TDB_SPINLOCK_SIZE(hash_size))
|
||||
|
||||
|
||||
/* NB assumes there is a local variable called "tdb" that is the
|
||||
* current context, also takes doubly-parenthesized print-style
|
||||
@ -663,10 +665,10 @@ static int tdb_free(TDB_CONTEXT *tdb, tdb_off offset, struct list_struct *rec)
|
||||
left:
|
||||
/* Look left */
|
||||
left = offset - sizeof(tdb_off);
|
||||
if (left > TDB_HASH_TOP(tdb->header.hash_size-1)) {
|
||||
if (left > TDB_DATA_START(tdb->header.hash_size)) {
|
||||
struct list_struct l;
|
||||
tdb_off leftsize;
|
||||
|
||||
|
||||
/* Read in tailer and jump back to header */
|
||||
if (ofs_read(tdb, left, &leftsize) == -1) {
|
||||
TDB_LOG((tdb, 0, "tdb_free: left offset read failed at %u\n", left));
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
|
Loading…
Reference in New Issue
Block a user