From: Austin Clements Date: Mon, 15 Aug 2011 18:11:22 +0000 (-0400) Subject: Only commit log to disk if something was written in to it. X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=843eecfcd0c23f2b9466e5c3289c1819950ccb47;p=cs3210-lab0.git Only commit log to disk if something was written in to it. Without this, every write to the console results in log writes. --- diff --git a/log.c b/log.c index e9a16c5..6b5c329 100644 --- a/log.c +++ b/log.c @@ -143,11 +143,13 @@ begin_trans(void) void commit_trans(void) { - write_head(); // This causes all blocks till log.head to be commited - install_trans(); // Install all the transactions till head - log.lh.n = 0; - write_head(); // Reclaim log - + if (log.lh.n > 0) { + write_head(); // This causes all blocks till log.head to be commited + install_trans(); // Install all the transactions till head + log.lh.n = 0; + write_head(); // Reclaim log + } + acquire(&log.lock); log.intrans = 0; wakeup(&log);