diff src/luan/host/WebHandler.java @ 1264:d41997776788

fix onClose issues
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 25 Sep 2018 17:03:57 -0600
parents 382c444a6c77
children 51a1987b55a3
line wrap: on
line diff
--- a/src/luan/host/WebHandler.java	Mon Sep 24 22:06:25 2018 -0600
+++ b/src/luan/host/WebHandler.java	Tue Sep 25 17:03:57 2018 -0600
@@ -32,12 +32,10 @@
 	private static final Logger logger = LoggerFactory.getLogger(WebHandler.class);
 
 	private static class LuanRef {
-		private final LuanState luan;
 		private final Handler handler;
 		private final LuanHandler luanHandler;
 
-		private LuanRef(LuanState luan,Handler handler,LuanHandler luanHandler) {
-			this.luan = luan;
+		private LuanRef(Handler handler,LuanHandler luanHandler) {
 			this.handler = handler;
 			this.luanHandler = luanHandler;
 		}
@@ -46,11 +44,11 @@
 	private static final ReferenceQueue<LuanRef> queue = new ReferenceQueue<LuanRef>();
 
 	private static class MyReference extends SoftReference<LuanRef> {
-		private LuanState luan;
+		private LuanHandler luanHandler;
 
 		private MyReference(LuanRef lr) {
 			super(lr,queue);
-			this.luan = lr.luan;
+			this.luanHandler = lr.luanHandler;
 		}
 	}
 
@@ -60,8 +58,8 @@
 			if( ref == null )
 				return;
 			//logger.info("sweep");
-			ref.luan.close();
-			ref.luan = null;
+			ref.luanHandler.close();
+			ref.luanHandler = null;
 		}
 	}
 
@@ -175,7 +173,7 @@
 		String logDir = dir + "/site/private/local/logs/web";
 		new File(logDir).mkdirs();
 
-		return new LuanRef(luan,handler,luanHandler);
+		return new LuanRef(handler,luanHandler);
 	}
 
 	public static void removeHandler(String domain) throws Exception {
@@ -183,7 +181,7 @@
 			Reference<LuanRef> ref = siteMap.remove(domain);
 			LuanRef lr = ref==null ? null : ref.get();
 			if( lr != null ) {
-				lr.luan.close();
+				lr.luanHandler.close();
 			}
 		}
 	}