diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-07-03 06:40:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:09:45 -0500 |
commit | d3fee429aee87e9c05a4a606fbf0b60b16dac782 (patch) | |
tree | 792984356cd682124de421c8d9852cfb7ddc8bff /source4/lib/tdb/include/tdb.h | |
parent | fcce0991c29338a63e3e1e50815eb981a2fa113c (diff) | |
download | samba-d3fee429aee87e9c05a4a606fbf0b60b16dac782.tar.gz samba-d3fee429aee87e9c05a4a606fbf0b60b16dac782.tar.bz2 samba-d3fee429aee87e9c05a4a606fbf0b60b16dac782.zip |
r16774: This patch modifies the tdb API to allow the logging function to be used
as part of ldb.
This allows tdb failures to be passed all the way up to Samba's DEBUG
system, which allowed easier debugging.
Unfortunately I had to extend the tdb API, as the logging function
didn't have a context pointer.
I've worked over the 'debug levels' in TDB. Most of them were 0,
which didn't seem right, as some were trace-like messages. We didn't
see any of these previously, except when accessing TDB directly.
Andrew Bartlett
(This used to be commit 58898092c1ce043f6d698db5065f372b79109e22)
Diffstat (limited to 'source4/lib/tdb/include/tdb.h')
-rw-r--r-- | source4/lib/tdb/include/tdb.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 4004c73460..785bbbe29b 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -55,6 +55,10 @@ enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY}; +/* debugging uses one of the following levels */ +enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, + TDB_DEBUG_WARNING, TDB_DEBUG_TRACE}; + typedef struct TDB_DATA { unsigned char *dptr; size_t dsize; @@ -76,19 +80,20 @@ typedef struct TDB_DATA { typedef struct tdb_context TDB_CONTEXT; typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *); -typedef void (*tdb_log_func)(struct tdb_context *, int , const char *, ...); +typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4); typedef unsigned int (*tdb_hash_func)(TDB_DATA *key); struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, - tdb_log_func log_fn, + tdb_log_func log_fn, void *log_private, tdb_hash_func hash_fn); +void *tdb_logging_private(struct tdb_context *tdb); int tdb_reopen(struct tdb_context *tdb); int tdb_reopen_all(int parent_longlived); -void tdb_logging_function(struct tdb_context *tdb, tdb_log_func); +void tdb_logging_function(struct tdb_context *tdb, tdb_log_func log_fn, void *log_private); enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); @@ -106,6 +111,7 @@ void tdb_unlockall(struct tdb_context *tdb); const char *tdb_name(struct tdb_context *tdb); int tdb_fd(struct tdb_context *tdb); tdb_log_func tdb_log_fn(struct tdb_context *tdb); +void *tdb_get_logging_private(struct tdb_context *tdb); int tdb_transaction_start(struct tdb_context *tdb); int tdb_transaction_commit(struct tdb_context *tdb); int tdb_transaction_cancel(struct tdb_context *tdb); |