Implemented simulateBufferManagerCrash.
This commit is contained in:
parent
b1e6f4709f
commit
f539011e9f
1 changed files with 26 additions and 3 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue