Changeset 2085

Show
Ignore:
Timestamp:
31/01/2008 23:57:14 (11 months ago)
Author:
chris
Message:

Always add file size to timestamp in release mode, to help caching work
better on machines which claim to support high-res timestamps but actually
don't (e.g. Linux, MacOS X).

Never do so in debug mode, to help catch problems with the tests failing
to sleep long enough between operations on different connections that
can break caching subtly and randomly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/raidfile/RaidFileUtil.cpp

    r217 r2085  
    2323// 
    2424// Function 
    25 //              Name:    RaidFileUtil::RaidFileExists(RaidFileDiscSet &, const std::string &) 
    26 //              Purpose: Check to see the state of a RaidFile on disc (doesn't look at contents, 
    27 //                               just at existense of files) 
     25//              Name:    RaidFileUtil::RaidFileExists(RaidFileDiscSet &, 
     26//                       const std::string &, int *, int *, int64_t *) 
     27//              Purpose: Check to see the state of a RaidFile on disc 
     28//                       (doesn't look at contents, just at existence of 
     29//                       files) 
    2830//              Created: 2003/07/11 
    2931// 
     
    5557                        { 
    5658                                (*pRevisionID) = FileModificationTime(st); 
    57 #ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC 
    58                                 // On linux, the time resolution is very low for modification times. 
    59                                 // So add the size to it to give a bit more chance of it changing. 
     59#ifdef NDEBUG 
     60                                // The resolution of timestamps may be very 
     61                                // low, e.g. 1 second. So add the size to it 
     62                                // to give a bit more chance of it changing. 
    6063                                // TODO: Make this better. 
     64                                // Disabled in debug mode, to simulate 
     65                                // filesystem with 1-second timestamp 
     66                                // resolution, e.g. MacOS X HFS, Linux. 
    6167                                (*pRevisionID) += st.st_size; 
    6268#endif 
     
    7278        int setSize = rDiscSet.size(); 
    7379        int rfCount = 0; 
    74 #ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC 
     80 
    7581        // TODO: replace this with better linux revision ID detection 
    7682        int64_t revisionIDplus = 0; 
    77 #endif 
     83 
    7884        for(int f = 0; f < setSize; ++f) 
    7985        { 
     
    9399                                int64_t rid = FileModificationTime(st); 
    94100                                if(rid > revisionID) revisionID = rid; 
    95 #ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC 
    96101                                revisionIDplus += st.st_size; 
    97 #endif 
    98102                        } 
    99103                } 
     
    102106        { 
    103107                (*pRevisionID) = revisionID; 
    104 #ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC 
     108#ifdef NDEBUG 
     109                // The resolution of timestamps may be very low, e.g. 
     110                // 1 second. So add the size to it to give a bit more 
     111                // chance of it changing. 
     112                // TODO: Make this better. 
     113                // Disabled in debug mode, to simulate filesystem with 
     114                // 1-second timestamp resolution, e.g. MacOS X HFS, Linux. 
    105115                (*pRevisionID) += revisionIDplus; 
    106116#endif