/* this tests tdb by doing lots of ops from several simultaneous writers - that stresses the locking code. */ #define _GNU_SOURCE #ifndef _SAMBA_BUILD_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "tdb.h" #else #include "includes.h" #include "lib/tdb/include/tdb.h" #include "system/time.h" #include "system/wait.h" #include "system/filesys.h" #endif #include #define REOPEN_PROB 30 #define DELETE_PROB 8 #define STORE_PROB 4 #define APPEND_PROB 6 #define TRANSACTION_PROB 10 #define LOCKSTORE_PROB 5 #define TRAVERSE_PROB 20 #define CULL_PROB 100 #define KEYLEN 3 #define DATALEN 100 #define LOCKLEN 20 static struct tdb_context *db; static int in_transaction; #ifdef PRINTF_ATTRIBUTE static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4); #endif static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stdout, format, ap); va_end(ap); fflush(stdout); #if 0 { char *ptr; asprintf(&ptr,"xterm -e gdb /proc/%d/exe %d", getpid(), getpid()); system(ptr); free(ptr); } #endif } static void fatal(const char *why) { perror(why); exit(1); } static char *randbuf(int len) { char *buf; int i; buf = (char *)malloc(len+1); for (i=0;i