5.4.4 log::~log



next up previous
Next: 5.4.5 log::write Up: 5.4 class log Previous: 5.4.3 log::log (The Open

5.4.4 log::~log

 

The destructor behaves differently depending on whether the open constructor or the create constructor was used. If the create constructor was used, nothing need be done. If the open constructor was used, the destructor checks to see if this transaction is the last one using the database. If so, it flushes the log tail. In any case, the log file is closed. The destructor determines the constructor that was used by checking the open_called flag. The open constructor sets this flag to true, the create constructor sets it to false. The destructor determines if this is the last transaction by examining sl_n_xact. This is admittedly a naive approach. If a transaction exited uncleanly without invoking its log destructor, this value will be wrong. This required us to assume that every transaction cleanly exits by releasing its locks and semaphores, and calling appropriate destructors.



ajitk@cs.wisc.edu, cjin@cs.wisc.edu