summaryrefslogtreecommitdiff
path: root/lib/tdb2
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:12:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:12:13 +0930
commitab61a57e0177ff50a22a8feea38abbf02edfd5da (patch)
treefed80e291b6f924d76019914ae9dc65c5f742207 /lib/tdb2
parentfb37849abda31b77a05718a316f52ed3fb0a8acd (diff)
downloadsamba-ab61a57e0177ff50a22a8feea38abbf02edfd5da.tar.gz
samba-ab61a57e0177ff50a22a8feea38abbf02edfd5da.tar.bz2
samba-ab61a57e0177ff50a22a8feea38abbf02edfd5da.zip
tdb2: Hand error code to logging function.
Since we've deprecated tdb_error() function (and it didn't work right from inside the logging function anyway, since we didn't set tdb->ecode yet) we need to hand it to the log function. (Imported from CCAN commit 6e3d9e8a66bf8b45150500f176452ee8e9ee9927) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb2')
-rw-r--r--lib/tdb2/private.h1
-rw-r--r--lib/tdb2/tdb.c6
-rw-r--r--lib/tdb2/tdb2.h1
-rw-r--r--lib/tdb2/test/logging.c4
-rw-r--r--lib/tdb2/test/logging.h1
-rw-r--r--lib/tdb2/test/run-seed.c1
-rw-r--r--lib/tdb2/tools/growtdb-bench.c4
-rw-r--r--lib/tdb2/tools/speed.c11
-rw-r--r--lib/tdb2/tools/tdb2tool.c10
-rw-r--r--lib/tdb2/tools/tdb2torture.c10
10 files changed, 34 insertions, 15 deletions
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 3f3860c42b..a43fa4ac56 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -355,6 +355,7 @@ struct tdb_context {
/* Logging function */
void (*log_fn)(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message,
void *data);
void *log_data;
diff --git a/lib/tdb2/tdb.c b/lib/tdb2/tdb.c
index 82b9c323d6..6f334a264b 100644
--- a/lib/tdb2/tdb.c
+++ b/lib/tdb2/tdb.c
@@ -433,11 +433,11 @@ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
va_end(ap);
if (len < 0) {
- tdb->log_fn(tdb, TDB_LOG_ERROR,
+ tdb->log_fn(tdb, TDB_LOG_ERROR, TDB_ERR_OOM,
"out of memory formatting message:", tdb->log_data);
- tdb->log_fn(tdb, level, fmt, tdb->log_data);
+ tdb->log_fn(tdb, level, ecode, fmt, tdb->log_data);
} else {
- tdb->log_fn(tdb, level, message, tdb->log_data);
+ tdb->log_fn(tdb, level, ecode, message, tdb->log_data);
free(message);
}
errno = saved_errno;
diff --git a/lib/tdb2/tdb2.h b/lib/tdb2/tdb2.h
index 93f8e9d3cb..8b127add81 100644
--- a/lib/tdb2/tdb2.h
+++ b/lib/tdb2/tdb2.h
@@ -706,6 +706,7 @@ struct tdb_attribute_log {
struct tdb_attribute_base base; /* .attr = TDB_ATTRIBUTE_LOG */
void (*fn)(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message,
void *data);
void *data;
diff --git a/lib/tdb2/test/logging.c b/lib/tdb2/test/logging.c
index f2e675e922..6927592b8a 100644
--- a/lib/tdb2/test/logging.c
+++ b/lib/tdb2/test/logging.c
@@ -15,12 +15,14 @@ union tdb_attribute tap_log_attr = {
void tap_log_fn(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message, void *priv)
{
if (suppress_logging)
return;
- diag("tdb log level %u: %s%s", level, log_prefix, message);
+ diag("tdb log level %u: %s: %s%s",
+ level, tdb_errorstr(ecode), log_prefix, message);
if (log_last)
free(log_last);
log_last = strdup(message);
diff --git a/lib/tdb2/test/logging.h b/lib/tdb2/test/logging.h
index 0fd59ba6bb..2dfea145c3 100644
--- a/lib/tdb2/test/logging.h
+++ b/lib/tdb2/test/logging.h
@@ -12,5 +12,6 @@ extern char *log_last;
void tap_log_fn(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message, void *priv);
#endif /* TDB2_TEST_LOGGING_H */
diff --git a/lib/tdb2/test/run-seed.c b/lib/tdb2/test/run-seed.c
index a9b370b6e5..e1c23a0c57 100644
--- a/lib/tdb2/test/run-seed.c
+++ b/lib/tdb2/test/run-seed.c
@@ -14,6 +14,7 @@ static int log_count = 0;
/* Normally we get a log when setting random seed. */
static void my_log_fn(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message, void *priv)
{
log_count++;
diff --git a/lib/tdb2/tools/growtdb-bench.c b/lib/tdb2/tools/growtdb-bench.c
index f7f6845a8a..ec81268bec 100644
--- a/lib/tdb2/tools/growtdb-bench.c
+++ b/lib/tdb2/tools/growtdb-bench.c
@@ -10,10 +10,12 @@
static void logfn(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message,
void *data)
{
- fprintf(stderr, "tdb:%s:%s\n", tdb_name(tdb), message);
+ fprintf(stderr, "tdb:%s:%s:%s\n",
+ tdb_name(tdb), tdb_errorstr(ecode), message);
}
int main(int argc, char *argv[])
diff --git a/lib/tdb2/tools/speed.c b/lib/tdb2/tools/speed.c
index 3222465a71..ccb5ae349d 100644
--- a/lib/tdb2/tools/speed.c
+++ b/lib/tdb2/tools/speed.c
@@ -126,11 +126,14 @@ static void dump_and_clear_stats(struct tdb_context **tdb,
*tdb = tdb_open("/tmp/speed.tdb", flags, O_RDWR, 0, attr);
}
-static void tdb_log(struct tdb_context *tdb, enum tdb_log_level level,
- const char *message, void *data)
+static void tdb_log(struct tdb_context *tdb,
+ enum tdb_log_level level,
+ enum TDB_ERROR ecode,
+ const char *message,
+ void *data)
{
- fputs(message, stderr);
- putc('\n', stderr);
+ fprintf(stderr, "tdb:%s:%s:%s\n",
+ tdb_name(tdb), tdb_errorstr(ecode), message);
}
int main(int argc, char *argv[])
diff --git a/lib/tdb2/tools/tdb2tool.c b/lib/tdb2/tools/tdb2tool.c
index cd301c80b7..9b3554de6c 100644
--- a/lib/tdb2/tools/tdb2tool.c
+++ b/lib/tdb2/tools/tdb2tool.c
@@ -126,10 +126,14 @@ static double _end_timer(void)
(tp2.tv_usec - tp1.tv_usec)*1.0e-6);
}
-static void tdb_log(struct tdb_context *tdb, enum tdb_log_level level,
- const char *message, void *priv)
+static void tdb_log(struct tdb_context *tdb,
+ enum tdb_log_level level,
+ enum TDB_ERROR ecode,
+ const char *message,
+ void *data)
{
- fputs(message, stderr);
+ fprintf(stderr, "tdb:%s:%s:%s\n",
+ tdb_name(tdb), tdb_errorstr(ecode), message);
}
/* a tdb tool for manipulating a tdb database */
diff --git a/lib/tdb2/tools/tdb2torture.c b/lib/tdb2/tools/tdb2torture.c
index f6a7a5064a..c2a4eaa0fb 100644
--- a/lib/tdb2/tools/tdb2torture.c
+++ b/lib/tdb2/tools/tdb2torture.c
@@ -42,10 +42,14 @@ static int count_pipe;
static union tdb_attribute log_attr;
static union tdb_attribute seed_attr;
-static void tdb_log(struct tdb_context *tdb, enum tdb_log_level level,
- const char *message, void *data)
+static void tdb_log(struct tdb_context *tdb,
+ enum tdb_log_level level,
+ enum TDB_ERROR ecode,
+ const char *message,
+ void *data)
{
- fputs(message, stdout);
+ printf("tdb:%s:%s:%s\n",
+ tdb_name(tdb), tdb_errorstr(ecode), message);
fflush(stdout);
#if 0
{