From ef5317a2da322ea0076deebf1af84f79460d852f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 19 May 2010 11:36:31 -0700 Subject: [PATCH] (SIGAR-217) win32.EventLogThread needs to re-open EventLog if it has been cleared --- .../src/org/hyperic/sigar/win32/EventLogThread.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bindings/java/src/org/hyperic/sigar/win32/EventLogThread.java b/bindings/java/src/org/hyperic/sigar/win32/EventLogThread.java index d0849b45..6b8b9b37 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/EventLogThread.java +++ b/bindings/java/src/org/hyperic/sigar/win32/EventLogThread.java @@ -158,7 +158,18 @@ public class EventLogThread implements Runnable { // cleaner way to go, but we cannot interrupt // a native system call. int lastEvent = log.getNewestRecord(); + if (lastEvent < curEvent) { + logger.debug(this.logName + " EventLog has changed, re-opening"); + try { log.close(); } catch (Win32Exception e) {} + log.open(this.logName); + curEvent = log.getOldestRecord(); + lastEvent = log.getNewestRecord(); + } + if (lastEvent > curEvent) { + if (curEvent == -1) { + curEvent = 0; //log was cleared + } handleEvents(log, curEvent, lastEvent); }