From 794a5c90597dcfeffafbc5976cde812072023d0a Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 18 Feb 2022 15:15:13 +0100 Subject: [PATCH] Ensure the client watcher has been properly closed before handling its constructed requests. --- src/jagi/scgi/EventServer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jagi/scgi/EventServer.java b/src/jagi/scgi/EventServer.java index 2de2e86..202b8dd 100644 --- a/src/jagi/scgi/EventServer.java +++ b/src/jagi/scgi/EventServer.java @@ -334,6 +334,7 @@ public class EventServer implements Runnable { int headlen = 0; ByteBuffer head = null; Map env = null; + Request req = null; Client(SocketChannel sk) { this.sk = sk; @@ -401,8 +402,7 @@ public class EventServer implements Runnable { if((events & SelectionKey.OP_READ) != 0) { if((env == null) && !readhead()) return; - Request req = new Request(env, sk); - submit(() -> EventServer.this.handle(req, handler)); + req = new Request(env, sk); handoff = true; } if(Driver.current().time() > (lastread + timeout)) @@ -410,6 +410,8 @@ public class EventServer implements Runnable { } public void close() { + if(req != null) + submit(() -> EventServer.this.handle(req, handler)); if(!handoff) { try { sk.close(); -- 2.11.0