Implemented simulateBufferManagerCrash.

This commit is contained in:
Sears Russell 2007-07-19 16:36:17 +00:00
parent b1e6f4709f
commit f539011e9f

View file

@ -283,10 +283,33 @@ static void bhBufDeinit() {
free(freeList);
// closePageFile();
lru->deinit(lru);
bufferPoolDeInit();
}
static void bhSimulateBufferManagerCrash() {
running = 0;
pthread_cond_signal(&needFree);
pthread_join(worker, 0);
struct LH_ENTRY(list) iter;
const struct LH_ENTRY(pair_t) * next;
LH_ENTRY(openlist)(cachedPages, &iter);
while((next = LH_ENTRY(readlist)(&iter))) {
Page * p = next->value;
writelock(p->rwlatch,0);
pageFlushed(p); // normally, pageWrite() would call this...
unlock(p->rwlatch);
}
LH_ENTRY(closelist)(&iter);
LH_ENTRY(destroy)(cachedPages);
free(freeList);
lru->deinit(lru);
bufferPoolDeInit();
}
void bhBufInit() {
assert(!running);
@ -300,7 +323,7 @@ void bhBufInit() {
writeBackPage = bhWriteBackPage;
forcePages = bhForcePages;
bufDeinit = bhBufDeinit;
simulateBufferManagerCrash = bhBufDeinit;
simulateBufferManagerCrash = bhSimulateBufferManagerCrash;
bufferPoolInit();