Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/lib/tdb/tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/tdb/tools/tdbbackup.c

    r986 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33   low level tdb backup and restore utility
     
    88   the Free Software Foundation; either version 3 of the License, or
    99   (at your option) any later version.
    10    
     10
    1111   This program is distributed in the hope that it will be useful,
    1212   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1313   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1414   GNU General Public License for more details.
    15    
     15
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    6262{
    6363        va_list ap;
    64    
     64
    6565        va_start(ap, format);
    6666        vfprintf(stdout, format, ap);
     
    105105  this function is also used for restore
    106106*/
    107 static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
     107static int backup_tdb(const char *old_name, const char *new_name,
     108                      int hash_size, int nolock)
    108109{
    109110        TDB_CONTEXT *tdb;
     
    123124
    124125        /* open the old tdb */
    125         tdb = tdb_open_ex(old_name, 0, 0,
     126        tdb = tdb_open_ex(old_name, 0,
     127                          TDB_DEFAULT | (nolock ? TDB_NOLOCK : 0),
    126128                          O_RDWR, 0, &log_ctx, NULL);
    127129        if (!tdb) {
     
    133135        /* create the new tdb */
    134136        unlink(tmp_name);
    135         tdb_new = tdb_open_ex(tmp_name, 
    136                               hash_size ? hash_size : tdb_hash_size(tdb), 
    137                               TDB_DEFAULT, 
    138                               O_RDWR|O_CREAT|O_EXCL, st.st_mode & 0777, 
     137        tdb_new = tdb_open_ex(tmp_name,
     138                              hash_size ? hash_size : tdb_hash_size(tdb),
     139                              TDB_DEFAULT,
     140                              O_RDWR|O_CREAT|O_EXCL, st.st_mode & 0777,
    139141                              &log_ctx, NULL);
    140142        if (!tdb_new) {
     
    193195        /* close the new tdb and re-open read-only */
    194196        tdb_close(tdb_new);
    195         tdb_new = tdb_open_ex(tmp_name, 
     197        tdb_new = tdb_open_ex(tmp_name,
    196198                              0,
    197                               TDB_DEFAULT, 
     199                              TDB_DEFAULT,
    198200                              O_RDONLY, 0,
    199201                              &log_ctx, NULL);
     
    205207                return 1;
    206208        }
    207        
     209
    208210        /* traverse the new tdb to confirm */
    209211        count2 = tdb_traverse(tdb_new, test_fn, NULL);
     
    238240
    239241        /* open the tdb */
    240         tdb = tdb_open_ex(fname, 0, 0, 
     242        tdb = tdb_open_ex(fname, 0, 0,
    241243                          O_RDONLY, 0, &log_ctx, NULL);
    242244
     
    250252        if (count < 0) {
    251253                printf("restoring %s\n", fname);
    252                 return backup_tdb(bak_name, fname, 0);
     254                return backup_tdb(bak_name, fname, 0, 0);
    253255        }
    254256
     
    280282        printf("   -v            verify mode (restore if corrupt)\n");
    281283        printf("   -n hashsize   set the new hash size for the backup\n");
    282 }
    283                
     284        printf("   -l            open without locking to back up mutex dbs\n");
     285}
    284286
    285287 int main(int argc, char *argv[])
     
    290292        int verify = 0;
    291293        int hashsize = 0;
     294        int nolock = 0;
    292295        const char *suffix = ".bak";
    293296
    294297        log_ctx.log_fn = tdb_log;
    295298
    296         while ((c = getopt(argc, argv, "vhs:n:")) != -1) {
     299        while ((c = getopt(argc, argv, "vhs:n:l")) != -1) {
    297300                switch (c) {
    298301                case 'h':
     
    308311                        hashsize = atoi(optarg);
    309312                        break;
     313                case 'l':
     314                        nolock = 1;
     315                        break;
    310316                }
    311317        }
     
    331337                } else {
    332338                        if (file_newer(fname, bak_name) &&
    333                             backup_tdb(fname, bak_name, hashsize) != 0) {
     339                            backup_tdb(fname, bak_name, hashsize,
     340                                       nolock) != 0) {
    334341                                ret = 1;
    335342                        }
  • vendor/current/lib/tdb/tools/tdbdump.c

    r414 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33   simple tdb dump util
     
    88   the Free Software Foundation; either version 3 of the License, or
    99   (at your option) any later version.
    10    
     10
    1111   This program is distributed in the hope that it will be useful,
    1212   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1313   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1414   GNU General Public License for more details.
    15    
     15
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    5252}
    5353
    54 static int dump_tdb(const char *fname, const char *keyname)
     54static void log_stderr(struct tdb_context *tdb, enum tdb_debug_level level,
     55                       const char *fmt, ...)
     56{
     57        va_list ap;
     58        const char *name = tdb_name(tdb);
     59        const char *prefix = "";
     60
     61        if (!name)
     62                name = "unnamed";
     63
     64        switch (level) {
     65        case TDB_DEBUG_ERROR:
     66                prefix = "ERROR: ";
     67                break;
     68        case TDB_DEBUG_WARNING:
     69                prefix = "WARNING: ";
     70                break;
     71        case TDB_DEBUG_TRACE:
     72                return;
     73
     74        default:
     75        case TDB_DEBUG_FATAL:
     76                prefix = "FATAL: ";
     77                break;
     78        }
     79
     80        va_start(ap, fmt);
     81        fprintf(stderr, "tdb(%s): %s", name, prefix);
     82        vfprintf(stderr, fmt, ap);
     83        va_end(ap);
     84}
     85
     86static void emergency_walk(TDB_DATA key, TDB_DATA dbuf, void *keyname)
     87{
     88        if (keyname) {
     89                if (key.dsize != strlen(keyname))
     90                        return;
     91                if (memcmp(key.dptr, keyname, key.dsize) != 0)
     92                        return;
     93        }
     94        traverse_fn(NULL, key, dbuf, NULL);
     95}
     96
     97static int dump_tdb(const char *fname, const char *keyname, bool emergency)
    5598{
    5699        TDB_CONTEXT *tdb;
    57100        TDB_DATA key, value;
    58        
    59         tdb = tdb_open(fname, 0, 0, O_RDONLY, 0);
     101        struct tdb_logging_context logfn = { log_stderr };
     102        int tdb_flags = TDB_DEFAULT;
     103
     104        /*
     105         * Note: that O_RDONLY implies TDB_NOLOCK, but we want to make it
     106         * explicit as it's important when working on databases which were
     107         * created with mutex locking.
     108         */
     109        tdb_flags |= TDB_NOLOCK;
     110
     111        tdb = tdb_open_ex(fname, 0, tdb_flags, O_RDONLY, 0, &logfn, NULL);
    60112        if (!tdb) {
    61113                printf("Failed to open %s\n", fname);
     
    63115        }
    64116
     117        if (emergency) {
     118                return tdb_rescue(tdb, emergency_walk, discard_const(keyname)) == 0;
     119        }
    65120        if (!keyname) {
    66                 tdb_traverse(tdb, traverse_fn, NULL);
     121                return tdb_traverse(tdb, traverse_fn, NULL) == -1 ? 1 : 0;
    67122        } else {
    68123                key.dptr = discard_const_p(uint8_t, keyname);
     
    85140        printf( "   -h          this help message\n");
    86141        printf( "   -k keyname  dumps value of keyname\n");
     142        printf( "   -e          emergency dump, for corrupt databases\n");
    87143}
    88144
     
    90146{
    91147        char *fname, *keyname=NULL;
     148        bool emergency = false;
    92149        int c;
    93150
     
    97154        }
    98155
    99         while ((c = getopt( argc, argv, "hk:")) != -1) {
     156        while ((c = getopt( argc, argv, "hk:e")) != -1) {
    100157                switch (c) {
    101158                case 'h':
     
    104161                case 'k':
    105162                        keyname = optarg;
     163                        break;
     164                case 'e':
     165                        emergency = true;
    106166                        break;
    107167                default:
     
    113173        fname = argv[optind];
    114174
    115         return dump_tdb(fname, keyname);
     175        return dump_tdb(fname, keyname, emergency);
    116176}
  • vendor/current/lib/tdb/tools/tdbrestore.c

    r986 r988  
    1818*/
    1919
     20#include "replace.h"
    2021#include <assert.h>
    21 #include "replace.h"
    2222#include "system/locale.h"
    2323#include "system/time.h"
     
    2525#include "system/wait.h"
    2626#include "tdb.h"
    27 
    28 #define debug_fprintf(file, fmt, ...) do {/*nothing*/} while (0)
    2927
    3028static int read_linehead(FILE *f)
     
    171169                goto fail;
    172170        }
    173         if (tdb_store(tdb, key, data, TDB_INSERT) == -1) {
     171        if (tdb_store(tdb, key, data, TDB_INSERT) != 0) {
    174172                fprintf(stderr, "TDB error: %s\n", tdb_errorstr(tdb));
    175173                goto fail;
     
    207205                return 1;
    208206        }
    209         fprintf(stderr, "EOF\n");
    210207        return 0;
    211208}
  • vendor/current/lib/tdb/tools/tdbtest.c

    r986 r988  
    2525{
    2626        gettimeofday(&tp2,NULL);
    27         return((tp2.tv_sec - tp1.tv_sec) + 
     27        return((tp2.tv_sec - tp1.tv_sec) +
    2828               (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
    2929}
     
    4141{
    4242        va_list ap;
    43    
     43
    4444        va_start(ap, format);
    4545        vfprintf(stdout, format, ap);
     
    190190        char tdata[] = "test";
    191191        TDB_DATA key, data;
    192        
     192
    193193        for (i = 0; i < 5; i++) {
    194194                snprintf(keys[i],2, "%d", i);
    195195                key.dptr = keys[i];
    196196                key.dsize = 2;
    197                
     197
    198198                data.dptr = tdata;
    199199                data.dsize = 4;
    200                
     200
    201201                if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
    202202                        fatal("tdb_store failed");
     
    249249        db = tdb_open(test_tdb, 0, TDB_CLEAR_IF_FIRST,
    250250                      O_RDWR | O_CREAT | O_TRUNC, 0600);
    251         gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST, 
     251        gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST,
    252252                         0600, NULL);
    253253
  • vendor/current/lib/tdb/tools/tdbtool.c

    r986 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33   Samba database functions
     
    1111   the Free Software Foundation; either version 3 of the License, or
    1212   (at your option) any later version.
    13    
     13
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18    
     18
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    3737char cmdline[1024];
    3838static int disable_mmap;
     39static int disable_lock;
    3940
    4041enum commands {
     
    5556        CMD_LIST_HASH_FREE,
    5657        CMD_LIST_FREE,
     58        CMD_FREELIST_SIZE,
    5759        CMD_INFO,
    5860        CMD_MMAP,
     
    6264        CMD_SYSTEM,
    6365        CMD_CHECK,
     66        CMD_REPACK,
    6467        CMD_QUIT,
    6568        CMD_HELP
     
    8891        {"list",        CMD_LIST_HASH_FREE},
    8992        {"free",        CMD_LIST_FREE},
     93        {"freelist_size",       CMD_FREELIST_SIZE},
    9094        {"info",        CMD_INFO},
    9195        {"speed",       CMD_SPEED},
     
    99103        {"q",           CMD_QUIT},
    100104        {"!",           CMD_SYSTEM},
     105        {"repack",      CMD_REPACK},
    101106        {NULL,          CMD_HELP}
    102107};
     
    112117{
    113118        gettimeofday(&tp2,NULL);
    114         return((tp2.tv_sec - tp1.tv_sec) + 
     119        return((tp2.tv_sec - tp1.tv_sec) +
    115120               (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
     121}
     122
     123#ifdef PRINTF_ATTRIBUTE
     124static void tdb_log_open(struct tdb_context *tdb, enum tdb_debug_level level,
     125                         const char *format, ...) PRINTF_ATTRIBUTE(3,4);
     126#endif
     127static void tdb_log_open(struct tdb_context *tdb, enum tdb_debug_level level,
     128                         const char *format, ...)
     129{
     130        const char *mutex_msg =
     131                "Can use mutexes only with MUTEX_LOCKING or NOLOCK\n";
     132        char *p;
     133        va_list ap;
     134
     135        p = strstr(format, mutex_msg);
     136        if (p != NULL) {
     137                /*
     138                 * Yes, this is a hack, but we don't want to see this
     139                 * message on first open, but we want to see
     140                 * everything else.
     141                 */
     142                return;
     143        }
     144
     145        va_start(ap, format);
     146        vfprintf(stderr, format, ap);
     147        va_end(ap);
    116148}
    117149
     
    159191                i++;
    160192                if (i%8 == 0) printf(" ");
    161                 if (i%16 == 0) {     
     193                if (i%16 == 0) {
    162194                        print_asc(&buf[i-16],8); printf(" ");
    163195                        print_asc(&buf[i-8],8); printf("\n");
     
    167199        if (i%16) {
    168200                int n;
    169                
     201
    170202                n = 16 - (i%16);
    171203                printf(" ");
    172204                if (n>8) printf(" ");
    173205                while (n--) printf("   ");
    174                
     206
    175207                n = i%16;
    176208                if (n > 8) n = 8;
    177209                print_asc(&buf[i-(i%16)],n); printf(" ");
    178210                n = (i%16) - n;
    179                 if (n>0) print_asc(&buf[i-n],n); 
    180                 printf("\n");   
     211                if (n>0) print_asc(&buf[i-n],n);
     212                printf("\n");
    181213        }
    182214}
     
    203235"  list                 : print the database hash table and freelist\n"
    204236"  free                 : print the database freelist\n"
     237"  freelist_size        : print the number of records in the freelist\n"
    205238"  check                : check the integrity of an opened database\n"
     239"  repack               : repack the database\n"
    206240"  speed                : perform speed tests on the database\n"
    207241"  ! command            : execute system command\n"
     
    220254static void create_tdb(const char *tdbname)
    221255{
    222         struct tdb_logging_context log_ctx;
     256        struct tdb_logging_context log_ctx = { NULL, NULL};
    223257        log_ctx.log_fn = tdb_log;
    224258
    225259        if (tdb) tdb_close(tdb);
    226         tdb = tdb_open_ex(tdbname, 0, TDB_CLEAR_IF_FIRST | (disable_mmap?TDB_NOMMAP:0),
     260        tdb = tdb_open_ex(tdbname, 0,
     261                          TDB_CLEAR_IF_FIRST |
     262                          (disable_mmap?TDB_NOMMAP:0) |
     263                          (disable_lock?TDB_NOLOCK:0),
    227264                          O_RDWR | O_CREAT | O_TRUNC, 0600, &log_ctx, NULL);
    228265        if (!tdb) {
     
    233270static void open_tdb(const char *tdbname)
    234271{
    235         struct tdb_logging_context log_ctx;
     272        struct tdb_logging_context log_ctx = { NULL, NULL };
     273        log_ctx.log_fn = tdb_log_open;
     274
     275        if (tdb) tdb_close(tdb);
     276        tdb = tdb_open_ex(tdbname, 0,
     277                          (disable_mmap?TDB_NOMMAP:0) |
     278                          (disable_lock?TDB_NOLOCK:0),
     279                          O_RDWR, 0600,
     280                          &log_ctx, NULL);
     281
    236282        log_ctx.log_fn = tdb_log;
    237 
    238         if (tdb) tdb_close(tdb);
    239         tdb = tdb_open_ex(tdbname, 0, disable_mmap?TDB_NOMMAP:0, O_RDWR, 0600,
    240                           &log_ctx, NULL);
     283        if (tdb != NULL) {
     284                tdb_set_logging_function(tdb, &log_ctx);
     285        }
     286
     287        if ((tdb == NULL) && (errno == EINVAL)) {
     288                /*
     289                 * Retry NOLOCK and readonly. There we want to see all
     290                 * error messages.
     291                 */
     292                tdb = tdb_open_ex(tdbname, 0,
     293                                  (disable_mmap?TDB_NOMMAP:0) |TDB_NOLOCK,
     294                                  O_RDONLY, 0600,
     295                                  &log_ctx, NULL);
     296        }
     297
    241298        if (!tdb) {
    242299                printf("Could not open %s: %s\n", tdbname, strerror(errno));
     
    258315        dbuf.dsize = datalen;
    259316
    260         if (tdb_store(tdb, key, dbuf, TDB_INSERT) == -1) {
     317        if (tdb_store(tdb, key, dbuf, TDB_INSERT) != 0) {
    261318                terror("insert failed");
    262319        }
     
    285342        print_rec(tdb, key, dbuf, NULL);
    286343
    287         if (tdb_store(tdb, key, dbuf, TDB_REPLACE) == -1) {
     344        if (tdb_store(tdb, key, dbuf, TDB_REPLACE) != 0) {
    288345                terror("store failed");
    289346        }
     
    307364            return;
    308365        }
    309        
     366
    310367        print_rec(tdb, key, dbuf, NULL);
    311        
     368
    312369        free( dbuf.dptr );
    313        
     370
    314371        return;
    315372}
     
    355412                return;
    356413        }
    357        
     414
    358415        print_rec(tdb, key, dbuf, NULL);
    359        
     416
    360417        dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600);
    361418        if ( !dst_tdb ) {
     
    363420                return;
    364421        }
    365        
    366         if ( tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) == -1 ) {
     422
     423        if (tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) != 0) {
    367424                terror("failed to move record");
    368425        }
    369426        else
    370427                printf("record moved\n");
    371        
     428
    372429        tdb_close( dst_tdb );
    373        
     430
    374431        return;
    375432}
     
    448505        _start_timer();
    449506        do {
    450                 long int r = random();
    451                 TDB_DATA key, dbuf;
     507                TDB_DATA key;
    452508                key.dptr = discard_const_p(uint8_t, str);
    453509                key.dsize = strlen((char *)key.dptr);
    454                 dbuf.dptr = (uint8_t *) &r;
    455                 dbuf.dsize = sizeof(r);
    456510                tdb_fetch(tdb, key);
    457511                t = _end_timer();
     
    521575        TDB_DATA dbuf;
    522576        *pkey = tdb_firstkey(the_tdb);
    523        
     577
    524578        dbuf = tdb_fetch(the_tdb, *pkey);
    525579        if (!dbuf.dptr) terror("fetch failed");
     
    533587        TDB_DATA dbuf;
    534588        *pkey = tdb_nextkey(the_tdb, *pkey);
    535        
     589
    536590        dbuf = tdb_fetch(the_tdb, *pkey);
    537         if (!dbuf.dptr) 
     591        if (!dbuf.dptr)
    538592                terror("fetch failed");
    539593        else
     
    612666                        tdb_transaction_commit(tdb);
    613667                        return 0;
     668                case CMD_REPACK:
     669                        bIterate = 0;
     670                        tdb_repack(tdb);
     671                        return 0;
    614672                case CMD_TRANSACTION_CANCEL:
    615673                        bIterate = 0;
     
    656714                        tdb_printfreelist(tdb);
    657715                        return 0;
     716                case CMD_FREELIST_SIZE: {
     717                        int size;
     718
     719                        size = tdb_freelist_size(tdb);
     720                        if (size < 0) {
     721                                printf("Error getting freelist size.\n");
     722                        } else {
     723                                printf("freelist size: %d\n", size);
     724                        }
     725
     726                        return 0;
     727                }
    658728                case CMD_INFO:
    659729                        info_tdb();
     
    694764}
    695765
    696 static char *convert_string(char *instring, size_t *sizep)
     766static char *tdb_convert_string(char *instring, size_t *sizep)
    697767{
    698768        size_t length = 0;
     
    732802        arg2 = NULL;
    733803        arg2len = 0;
     804
     805        if (argv[1] && (strcmp(argv[1], "-l") == 0)) {
     806                disable_lock = 1;
     807                argv[1] = argv[0];
     808                argv += 1;
     809                argc -= 1;
     810        }
    734811
    735812        if (argv[1]) {
     
    760837                                }
    761838                        }
    762                         if (arg1) arg1 = convert_string(arg1,&arg1len);
    763                         if (arg2) arg2 = convert_string(arg2,&arg2len);
     839                        if (arg1) arg1 = tdb_convert_string(arg1,&arg1len);
     840                        if (arg2) arg2 = tdb_convert_string(arg2,&arg2len);
    764841                        if (do_command()) break;
    765842                }
    766843                break;
    767844        case 5:
    768                 arg2 = convert_string(argv[4],&arg2len);
     845                arg2 = tdb_convert_string(argv[4],&arg2len);
    769846        case 4:
    770                 arg1 = convert_string(argv[3],&arg1len);
     847                arg1 = tdb_convert_string(argv[3],&arg1len);
    771848        case 3:
    772849                cmdname = argv[2];
  • vendor/current/lib/tdb/tools/tdbtorture.c

    r986 r988  
    11/* this tests tdb by doing lots of ops from several simultaneous
    2    writers - that stresses the locking code. 
     2   writers - that stresses the locking code.
    33*/
    44
     
    3434static int loopnum;
    3535static int count_pipe;
     36static bool mutex = false;
    3637static struct tdb_logging_context log_ctx;
    3738
     
    6061                free(ptr);
    6162        }
    62 #endif 
     63#endif
    6364}
    6465
     
    217218static void usage(void)
    218219{
    219         printf("Usage: tdbtorture [-t] [-k] [-n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]\n");
     220        printf("Usage: tdbtorture [-t] [-k] [-m] [-n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]\n");
    220221        exit(0);
    221222}
     
    231232static int run_child(const char *filename, int i, int seed, unsigned num_loops, unsigned start)
    232233{
    233         db = tdb_open_ex(filename, hash_size, TDB_DEFAULT,
     234        int tdb_flags = TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH;
     235
     236        if (mutex) {
     237                tdb_flags |= TDB_MUTEX_LOCKING;
     238        }
     239
     240        db = tdb_open_ex(filename, hash_size, tdb_flags,
    234241                         O_RDWR | O_CREAT, 0600, &log_ctx, NULL);
    235242        if (!db) {
     
    303310        log_ctx.log_fn = tdb_log;
    304311
    305         while ((c = getopt(argc, argv, "n:l:s:H:thk")) != -1) {
     312        while ((c = getopt(argc, argv, "n:l:s:H:thkm")) != -1) {
    306313                switch (c) {
    307314                case 'n':
     
    323330                        kill_random = 1;
    324331                        break;
     332                case 'm':
     333                        mutex = tdb_runtime_check_for_robust_mutexes();
     334                        if (!mutex) {
     335                                printf("tdb_runtime_check_for_robust_mutexes() returned false\n");
     336                                exit(1);
     337                        }
     338                        break;
    325339                default:
    326340                        usage();
     
    335349                seed = (getpid() + time(NULL)) & 0x7FFFFFFF;
    336350        }
     351
     352        printf("Testing with %d processes, %d loops, %d hash_size, seed=%d%s\n",
     353               num_procs, num_loops, hash_size, seed,
     354               (always_transaction ? " (all within transactions)" : ""));
    337355
    338356        if (num_procs == 1 && !kill_random) {
     
    343361
    344362        pids = (pid_t *)calloc(sizeof(pid_t), num_procs);
     363        if (pids == NULL) {
     364                perror("Unable to allocate memory for pids");
     365                exit(1);
     366        }
    345367        done = (int *)calloc(sizeof(int), num_procs);
     368        if (done == NULL) {
     369                perror("Unable to allocate memory for done");
     370                exit(1);
     371        }
    346372
    347373        if (pipe(pfds) != 0) {
     
    354380                if ((pids[i]=fork()) == 0) {
    355381                        close(pfds[0]);
    356                         if (i == 0) {
    357                                 printf("Testing with %d processes, %d loops, %d hash_size, seed=%d%s\n",
    358                                        num_procs, num_loops, hash_size, seed, always_transaction ? " (all within transactions)" : "");
    359                         }
    360382                        exit(run_child(test_tdb, i, seed, num_loops, 0));
    361383                }
     
    436458done:
    437459        if (error_count == 0) {
    438                 db = tdb_open_ex(test_tdb, hash_size, TDB_DEFAULT,
     460                int tdb_flags = TDB_DEFAULT;
     461
     462                if (mutex) {
     463                        tdb_flags |= TDB_NOLOCK;
     464                }
     465
     466                db = tdb_open_ex(test_tdb, hash_size, tdb_flags,
    439467                                 O_RDWR, 0, &log_ctx, NULL);
    440468                if (!db) {
    441                         fatal("db open failed");
     469                        fatal("db open failed\n");
     470                        exit(1);
    442471                }
    443472                if (tdb_check(db, NULL, NULL) == -1) {
    444                         printf("db check failed");
     473                        printf("db check failed\n");
    445474                        exit(1);
    446475                }
Note: See TracChangeset for help on using the changeset viewer.