#define TRANSACTION_PREPARE_PROB 2
#define LOCKSTORE_PROB 5
#define TRAVERSE_PROB 20
-#define TRAVERSE_READ_PROB 20
#define TRAVERSE_MOD_PROB 100
#define TRAVERSE_ABORT_PROB 500
#define CULL_PROB 100
static union tdb_attribute log_attr;
static union tdb_attribute seed_attr;
-#ifdef PRINTF_FMT
-static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, void *private, const char *format, ...) PRINTF_FMT(4,5);
-#endif
-static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, void *private, const char *format, ...)
+static void tdb_log(struct tdb_context *tdb, enum tdb_log_level level,
+ void *private, const char *message)
{
- va_list ap;
-
- va_start(ap, format);
- vfprintf(stdout, format, ap);
- va_end(ap);
+ fputs(message, stdout);
fflush(stdout);
#if 0
{
{
char string[100];
- sprintf(string, "%u: death at %p (map_ptr %p, map_size %llu)\n",
- getpid(), info->si_addr, db->map_ptr, db->map_size);
- write(2, string, strlen(string));
- sleep(60);
+ sprintf(string, "%u: death at %p (map_ptr %p, map_size %zu)\n",
+ getpid(), info->si_addr, db->file->map_ptr,
+ (size_t)db->file->map_size);
+ if (write(2, string, strlen(string)) > 0)
+ sleep(60);
_exit(11);
}
#if LOCKSTORE_PROB
if (random() % LOCKSTORE_PROB == 0) {
tdb_chainlock(db, key);
- data = tdb_fetch(db, key);
+ tdb_fetch(db, key, &data);
if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
fatal("tdb_store failed");
}
}
#endif
-#if TRAVERSE_READ_PROB
- if (in_traverse == 0 && random() % TRAVERSE_READ_PROB == 0) {
- in_traverse++;
- tdb_traverse_read(db, NULL, NULL);
- in_traverse--;
- goto next;
- }
-#endif
-
- data = tdb_fetch(db, key);
- if (data.dptr) free(data.dptr);
+ if (tdb_fetch(db, key, &data) == TDB_SUCCESS)
+ free(data.dptr);
next:
free(k);
static void send_count_and_suicide(int sig)
{
/* This ensures our successor can continue where we left off. */
- write(count_pipe, &loopnum, sizeof(loopnum));
+ if (write(count_pipe, &loopnum, sizeof(loopnum)) != sizeof(loopnum))
+ exit(2);
/* This gives a unique signature. */
kill(getpid(), SIGUSR2);
}
}
if (error_count == 0) {
- tdb_traverse_read(db, NULL, NULL);
+ tdb_traverse(db, NULL, NULL);
#if TRANSACTION_PROB
if (always_transaction) {
while (in_transaction) {
|| WTERMSIG(status) == SIGUSR1) {
/* SIGUSR2 means they wrote to pipe. */
if (WTERMSIG(status) == SIGUSR2) {
- read(pfds[0], &done[j],
- sizeof(done[j]));
+ if (read(pfds[0], &done[j],
+ sizeof(done[j]))
+ != sizeof(done[j]))
+ err(1,
+ "Short read from child?");
}
pids[j] = fork();
if (pids[j] == 0)