mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of ssh://aaron@git.10gen.com/data/gitroot/p
This commit is contained in:
commit
7fddf99109
@ -17,7 +17,7 @@ class BasicRecStore {
|
||||
uint32_t recsize;
|
||||
uint64_t leof; // logical eof, actual file might be prealloc'd further
|
||||
uint64_t firstDeleted; // 0 = no deleted recs
|
||||
uint32_t cleanShutdown; // = clean
|
||||
uint32_t cleanShutdown; // 0 = clean
|
||||
char reserved[8192-8-8-4-4-4]; // we want our records page-aligned in the file if they are a multiple of a page's size -- so we make this 8KB with that goal
|
||||
RecStoreHeader() {
|
||||
version = 65;
|
||||
@ -52,8 +52,10 @@ private:
|
||||
|
||||
inline BasicRecStore::~BasicRecStore() {
|
||||
h.cleanShutdown = 0;
|
||||
if( f.is_open() )
|
||||
if( f.is_open() ) {
|
||||
writeHeader();
|
||||
f.fsync();
|
||||
}
|
||||
}
|
||||
|
||||
inline void BasicRecStore::writeHeader() {
|
||||
|
@ -26,6 +26,7 @@ void BasicRecStore::init(const char *fn, unsigned recsize)
|
||||
}
|
||||
else {
|
||||
f.read(0, (char *) &h, sizeof(RecStoreHeader));
|
||||
massert(string("recstore was not closed cleanly: ")+fn, h.cleanShutdown==0);
|
||||
massert(string("recstore recsize mismatch, file:")+fn, h.recsize == recsize);
|
||||
massert(string("bad recstore [1], file:")+fn, (h.leof-sizeof(RecStoreHeader)) % recsize == 0);
|
||||
if( h.leof > len ) {
|
||||
|
10
util/file.h
10
util/file.h
@ -86,6 +86,7 @@ public:
|
||||
}
|
||||
return li.QuadPart;
|
||||
}
|
||||
void fsync() { FlushFileBuffers(fd); }
|
||||
};
|
||||
|
||||
#else
|
||||
@ -108,6 +109,14 @@ public:
|
||||
if( is_open() ) ::close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
#ifndef O_NOATIME
|
||||
// OSX only, presumably.
|
||||
#warning NO O_NOATIME
|
||||
#define O_NOATIME 0
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
void open(const char *filename) {
|
||||
fd = ::open(filename, O_CREAT | O_RDWR | O_NOATIME, S_IRUSR | S_IWUSR);
|
||||
if ( fd <= 0 ) {
|
||||
@ -129,6 +138,7 @@ public:
|
||||
fileofs len() {
|
||||
return lseek(fd, 0, SEEK_END);
|
||||
}
|
||||
void fsync() { ::fsync(fd); }
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user