changeset 1767:9157e0d5936e

minor fix
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 06 Jun 2023 20:31:19 -0600
parents 8df0b80e715e
children ad53577872cc
files src/luan/host/WebHandler.java src/luan/modules/http/LuanHandler.java
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/host/WebHandler.java	Tue Jun 06 14:33:24 2023 -0600
+++ b/src/luan/host/WebHandler.java	Tue Jun 06 20:31:19 2023 -0600
@@ -56,9 +56,14 @@
 		}
 
 		@Override public void close() {
-			Object obj = dontGc.remove(this);
+			dontGc.remove(this);
 			luanHandler.close();
 		}
+
+		protected void finalize() throws Throwable {
+			// logger.info("gc "+luanHandler.domain);
+			close();
+		}
 	}
 
 	private static final DomainHandler.Factory factory = new DomainHandler.Factory() {
--- a/src/luan/modules/http/LuanHandler.java	Tue Jun 06 14:33:24 2023 -0600
+++ b/src/luan/modules/http/LuanHandler.java	Tue Jun 06 20:31:19 2023 -0600
@@ -35,7 +35,7 @@
 	private static final Logger logger = LoggerFactory.getLogger(LuanHandler.class);
 
 	private final Luan luanInit;
-	private final String domain;
+	public final String domain;
 	private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
 	private volatile Luan currentLuan;
 	private volatile boolean isDisabled = false;
@@ -144,7 +144,7 @@
 	}
 
 	@Override public void close() {
-		synchronized(currentLuan) {
+		synchronized(closeables) {
 			for( Closeable c : closeables ) {
 				try {
 					c.close();
@@ -152,6 +152,7 @@
 					logger.error(c.toString(),e);
 				}
 			}
+			closeables.clear();
 		}
 	}
 
@@ -234,7 +235,10 @@
 		}
 
 		@Override public void addCloseable(Closeable c) throws LuanException {
-			lh().closeables.add(c);
+			List<Closeable> closeables = lh().closeables;
+			synchronized(closeables) {
+				closeables.add(c);
+			}
 		}
 
 		public void reset_luan() throws LuanException {