Changeset 2794


Ignore:
Timestamp:
18/10/2010 21:34:25 (19 months ago)
Author:
chris
Message:

Revert [2710] and [2717], remove TDB and replace with QDBM again, to fix
build on Windows and make it easier to merge Charles' work.

Location:
box/trunk
Files:
2 deleted
8 edited
68 copied

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupd/BackupClientInodeToIDMap.cpp

    r2717 r2794  
    1111 
    1212#include <stdlib.h> 
    13  
    14 #define _PUBLIC_ 
    15 #include "tdb.h" 
     13#include <depot.h> 
    1614 
    1715#define BACKIPCLIENTINODETOIDMAP_IMPLEMENTATION 
     
    2927} IDBRecord; 
    3028 
    31 #define BOX_DBM_MESSAGE(stuff) stuff << " (tdb): " << tdb_error(mpContext) 
     29#define BOX_DBM_MESSAGE(stuff) stuff << " (qdbm): " << dperrmsg(dpecode) 
    3230 
    3331#define BOX_LOG_DBM_ERROR(stuff) \ 
     
    3937                BOX_DBM_MESSAGE(message << ": " << filename)); 
    4038 
    41 #define ASSERT_DBM(success, message, exception, subtype) \ 
    42         if(!(success)) \ 
     39#define ASSERT_DBM_OK(operation, message, filename, exception, subtype) \ 
     40        if(!(operation)) \ 
    4341        { \ 
    44                 THROW_DBM_ERROR(message, mFilename, exception, subtype); \ 
     42                THROW_DBM_ERROR(message, filename, exception, subtype); \ 
    4543        } 
    4644 
    4745#define ASSERT_DBM_OPEN() \ 
    48         if(mpContext == 0) \ 
     46        if(mpDepot == 0) \ 
    4947        { \ 
    5048                THROW_EXCEPTION_MESSAGE(BackupStoreException, InodeMapNotOpen, \ 
     
    5351 
    5452#define ASSERT_DBM_CLOSED() \ 
    55         if(mpContext != 0) \ 
     53        if(mpDepot != 0) \ 
    5654        { \ 
    5755                THROW_EXCEPTION_MESSAGE(CommonException, Internal, \ 
     
    7068        : mReadOnly(true), 
    7169          mEmpty(false), 
    72           mpContext(NULL) 
     70          mpDepot(0) 
    7371{ 
    7472} 
     
    8482BackupClientInodeToIDMap::~BackupClientInodeToIDMap() 
    8583{ 
    86         if(mpContext != NULL) 
     84        if(mpDepot != 0) 
    8785        { 
    8886                Close(); 
     
    111109         
    112110        // Open the database file 
    113         int mode = ReadOnly ? O_RDONLY : O_RDWR; 
     111        int mode = ReadOnly ? DP_OREADER : DP_OWRITER; 
    114112        if(CreateNew) 
    115113        { 
    116                 mode |= O_CREAT; 
    117         } 
    118          
    119         mpContext = tdb_open(Filename, 0, 0, mode, 0700); 
    120          
    121         ASSERT_DBM(mpContext != NULL, "Failed to open inode database", 
     114                mode |= DP_OCREAT; 
     115        } 
     116         
     117        mpDepot = dpopen(Filename, mode, 0); 
     118         
     119        ASSERT_DBM_OK(mpDepot, "Failed to open inode database", mFilename, 
    122120                BackupStoreException, BerkelyDBFailure); 
    123121         
     
    140138{ 
    141139        ASSERT_DBM_CLOSED(); 
    142         ASSERT(mpContext == NULL); 
     140        ASSERT(mpDepot == 0); 
    143141        mEmpty = true; 
    144142        mReadOnly = true; 
     
    156154{ 
    157155        ASSERT_DBM_OPEN(); 
    158         ASSERT_DBM(tdb_close(mpContext) == 0, "Failed to close inode database", 
    159                 BackupStoreException, BerkelyDBFailure); 
    160         mpContext = NULL; 
    161 } 
    162  
    163 static TDB_DATA GetDatum(void* dptr, size_t dsize) 
    164 { 
    165         TDB_DATA datum; 
    166         datum.dptr = (unsigned char *)dptr; 
    167         datum.dsize = dsize; 
    168         return datum; 
    169 } 
    170  
    171 #define GET_STRUCT_DATUM(structure) \ 
    172         GetDatum(&structure, sizeof(structure)) 
     156        ASSERT_DBM_OK(dpclose(mpDepot), "Failed to close inode database", 
     157                mFilename, BackupStoreException, BerkelyDBFailure); 
     158        mpDepot = 0; 
     159} 
    173160 
    174161// -------------------------------------------------------------------------- 
     
    190177        } 
    191178 
    192         if(mpContext == 0) 
     179        if(mpDepot == 0) 
    193180        { 
    194181                THROW_EXCEPTION(BackupStoreException, InodeMapNotOpen); 
     
    202189        rec.mInDirectory = InDirectory; 
    203190 
    204         ASSERT_DBM(tdb_store(mpContext, GET_STRUCT_DATUM(InodeRef), 
    205                 GET_STRUCT_DATUM(rec), 0) == 0, 
    206                 "Failed to add record to inode database", 
     191        ASSERT_DBM_OK(dpput(mpDepot, (const char *)&InodeRef, sizeof(InodeRef), 
     192                (const char *)&rec, sizeof(rec), DP_DOVER), 
     193                "Failed to add record to inode database", mFilename, 
    207194                BackupStoreException, BerkelyDBFailure); 
    208195} 
     
    228215        } 
    229216 
    230         if(mpContext == 0) 
     217        if(mpDepot == 0) 
    231218        { 
    232219                THROW_EXCEPTION(BackupStoreException, InodeMapNotOpen); 
     
    235222        ASSERT_DBM_OPEN(); 
    236223 
    237         TDB_DATA datum = tdb_fetch(mpContext, GET_STRUCT_DATUM(InodeRef)); 
    238         if(datum.dptr == NULL) 
     224        IDBRecord rec; 
     225         
     226        if(dpgetwb(mpDepot, (const char *)&InodeRef, sizeof(InodeRef), 
     227                0, sizeof(IDBRecord), (char *)&rec) == -1) 
    239228        { 
    240229                // key not in file 
    241230                return false; 
    242231        } 
    243  
    244         IDBRecord rec; 
    245         if(datum.dsize != sizeof(rec)) 
    246         { 
    247                 THROW_EXCEPTION_MESSAGE(CommonException, Internal, 
    248                         "Failed to get inode database entry: " 
    249                         "record has wrong size: expected " << 
    250                         sizeof(rec) << " but was " << datum.dsize << 
    251                         " in " << mFilename); 
    252         } 
    253232                 
    254         rec = *(IDBRecord *)datum.dptr; 
    255         free(datum.dptr); 
    256          
    257233        // Return data 
    258234        rObjectIDOut = rec.mObjectID; 
  • box/trunk/bin/bbackupd/BackupClientInodeToIDMap.h

    r2717 r2794  
    1818// avoid having to include the DB files when not necessary 
    1919#ifndef BACKIPCLIENTINODETOIDMAP_IMPLEMENTATION 
    20         struct TDB_CONTEXT; 
    21         struct TDB_DATUM; 
     20        class DEPOT; 
    2221#endif 
    2322 
     
    5150        bool mEmpty; 
    5251        std::string mFilename; 
    53         TDB_CONTEXT *mpContext; 
     52        DEPOT *mpDepot; 
    5453}; 
    5554 
  • box/trunk/bootstrap

    r2717 r2794  
    11#!/bin/sh 
    2  
    3 set -e 
    42 
    53aclocal -I infrastructure/m4 
    64autoheader 
    75autoconf 
    8 ( cd bundled/tdb; ./autogen.sh; ) 
  • box/trunk/configure.ac

    r2759 r2794  
    389389 
    390390cat parcels.txt | sed -e 's/#.*//' | while read cmd subdir configure_args; do 
    391         if test "$cmd" = "configure"; then 
     391        if test "$cmd" = "subdir"; then 
    392392                echo 
    393393                export CC CXX CXXFLAGS LDFLAGS LIBS 
  • box/trunk/infrastructure/makebuildenv.pl.in

    r2717 r2794  
    253253        # check directory exists 
    254254        die "Module $mod can't be found\n" unless -d $mod; 
    255  
    256         # skip bundled libraries with their own Makefile process         
    257         next if ($mod =~ m|^bundled/|); 
    258255         
    259256        # and put in lists 
     
    514511        }        
    515512         
     513 
    516514        # make include path 
    517         my $include_paths = ""; 
    518  
    519         foreach my $mod (@all_deps_for_module) 
    520         { 
    521                 if ($mod =~ m|^bundled/| and -d "$mod/include") 
    522                 { 
    523                         $include_paths .= "-I../../$mod/include "; 
    524                 } 
    525                 else 
    526                 { 
    527                         $include_paths .= "-I../../$mod "; 
    528                 } 
    529         } 
     515        my $include_paths = join(' ',map {'-I../../'.$_} @all_deps_for_module); 
    530516 
    531517        # is target a library? 
     
    789775                                $dep_target = "\$(OUTBASE)/$dep/$1.a"; 
    790776                        } 
    791                         elsif ($dep =~ m|^bundled/(.*)|) 
    792                         { 
    793                                 $dep_target = "lib$1.a"; 
    794                         } 
    795                         elsif ($dep =~ m|^bin/(.*)|) 
     777                        elsif ($dep =~ m|^.*/(.*)|) 
    796778                        { 
    797779                                $dep_target = "\$(OUTBASE)/$dep/$1$platform_exe_ext"; 
     
    799781                        else 
    800782                        { 
    801                                 die "Don't know how to add compile-time " . 
    802                                         "dependency on $dep"; 
     783                                $dep_target = "lib$dep.a"; 
    803784                        } 
    804785 
     
    821802        foreach my $dep (reverse @all_deps_for_module) 
    822803        { 
    823                 if ($dep =~ m|^lib/(.+)$|) 
     804                if ($dep =~ m|^lib\/(.+)$|) 
    824805                { 
    825806                        push @lib_files, "\$(OUTBASE)/$dep/$1.a"; 
    826807                } 
    827                 elsif ($dep =~ m|^bundled/(.+)$|) 
     808                elsif ($dep =~ m|^([^/]+)$|) 
    828809                { 
    829810                        push @lib_files, "../../$dep/lib$1.a"; 
  • box/trunk/infrastructure/makeparcels.pl.in

    r2738 r2794  
    244244                        push @parcel_deps, "$dir/docs/${name}.html"; 
    245245                } 
    246                 elsif ($type eq 'configure') 
     246                elsif ($type eq 'subdir') 
    247247                { 
    248248                        shift @args; 
     
    256256$name-clean: 
    257257        cd $name; \$(MAKE) clean 
    258  
    259258EOF 
    260259                        push @parcel_deps, "$name-build"; 
  • box/trunk/modules.txt

    r2717 r2794  
    2727 
    2828lib/backupclient        lib/server      lib/crypto      lib/compress 
    29 lib/backupstore         lib/server      lib/raidfile    lib/backupclient                bundled/tdb 
     29lib/backupstore         lib/server      lib/raidfile    lib/backupclient 
    3030 
    3131bin/bbackupobjdump      lib/backupclient lib/backupstore 
    32 bin/bbstored            lib/raidfile    lib/server      lib/backupstore lib/backupclient        bundled/tdb 
     32bin/bbstored            lib/raidfile    lib/server      lib/backupstore lib/backupclient 
    3333bin/bbstoreaccounts     lib/raidfile    lib/backupstore 
    34 bin/bbackupd            lib/server      lib/backupclient        bundled/tdb 
     34bin/bbackupd            lib/server      lib/backupclient        qdbm 
    3535bin/bbackupquery        lib/server      lib/backupclient 
    3636bin/bbackupctl          lib/server      lib/backupclient 
  • box/trunk/parcels.txt

    r2717 r2794  
    1919        html bbackupd.conf 
    2020 
     21        subdir qdbm libqdbm.a 
    2122 
    2223EXCEPT:mingw32,mingw32msvc 
     
    6667        html raidfile.conf 
    6768 
    68         configure bundled/tdb 
    69  
    7069EXCEPT:mingw32,mingw32msvc 
    7170        man bbstored.8 
Note: See TracChangeset for help on using the changeset viewer.