From ea0d7d15272f1a80dd79970413adc390f543640b Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 19 Feb 2022 01:45:28 +0100 Subject: [PATCH] Fixed some event-server channel-transfer bugs. --- src/jagi/scgi/EventServer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/jagi/scgi/EventServer.java b/src/jagi/scgi/EventServer.java index 202b8dd..8218973 100644 --- a/src/jagi/scgi/EventServer.java +++ b/src/jagi/scgi/EventServer.java @@ -115,7 +115,7 @@ public class EventServer implements Runnable { public void handle(int events) throws IOException { if(!eof && (buf.remaining() == 0)) { - buf.rewind(); + buf.clear(); while(buf.remaining() > 0) { if(in.read(buf) < 0) break; @@ -168,7 +168,7 @@ public class EventServer implements Runnable { public void handle(int events) throws IOException { double now = Driver.current().time(); if((events & SelectionKey.OP_READ) != 0) { - buf.rewind(); + buf.clear(); if(buf.remaining() > max - cur) buf.limit(buf.position() + (int)Math.min(max - cur, Integer.MAX_VALUE)); int rv = sk.read(buf); @@ -176,7 +176,8 @@ public class EventServer implements Runnable { eof = true; } else if(rv > 0) { lastread = now; - cur += rv; + if((cur += rv) >= max) + eof = true; } buf.flip(); while(buf.remaining() > 0) -- 2.11.0