From 096541e347e3603f14e1d3c11251e863d58d086a Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 2 Aug 2002 18:19:04 +0000 Subject: [PATCH] Fixed bug where prototype was marked as checked too early, resulting in other evaluators to use the prototype is if the code was fully parsed/compiled. --- src/helma/framework/core/TypeManager.java | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/helma/framework/core/TypeManager.java b/src/helma/framework/core/TypeManager.java index 0b1ed128..de2faa6e 100644 --- a/src/helma/framework/core/TypeManager.java +++ b/src/helma/framework/core/TypeManager.java @@ -193,11 +193,14 @@ public final class TypeManager { if (proto == null) return; - if (System.currentTimeMillis() - proto.getLastCheck() < 1000) + // if prototype has been checked in the last 1.5 seconds, return + if (System.currentTimeMillis() - proto.getLastCheck() < 1500) return; synchronized (proto) { - if (System.currentTimeMillis() - proto.getLastCheck() < 1000) + // check again because another thread may have checked the + // prototype while we were waiting for access to the synchronized section + if (System.currentTimeMillis() - proto.getLastCheck() < 1500) return; File dir = new File (appDir, proto.getName()); @@ -216,14 +219,8 @@ public final class TypeManager { } } - // fetch previous last-check timestamp and update it on prototype - // we do this here for the (not very likely but possible) case - // where files are created in the exact moment we are doing this check. - long lastcheck = proto.getLastCheck (); - proto.markChecked (); - // next we check if files have been created since last update - if (lastcheck < dir.lastModified ()) { + if (proto.getLastCheck() < dir.lastModified ()) { String[] list = dir.list(); for (int i=0; i