From a274c5f0b9f90981fa0fb00e00a9b9e5ca258a0c Mon Sep 17 00:00:00 2001 From: Garrick Evans Date: Sat, 12 Feb 2011 09:57:24 -0800 Subject: [PATCH] ticket 664 - update continuation handling to (re)support updating timeout --- .../scala/akka/http/JettyContinuation.scala | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/akka-http/src/main/scala/akka/http/JettyContinuation.scala b/akka-http/src/main/scala/akka/http/JettyContinuation.scala index f6d1493842..cfcdaa89c6 100644 --- a/akka-http/src/main/scala/akka/http/JettyContinuation.scala +++ b/akka-http/src/main/scala/akka/http/JettyContinuation.scala @@ -52,9 +52,10 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging Some(continuation) } + // // the timeout was reset and the continuation was resumed - // need to update the timeout and resuspend - // very important to clear the context so the request is not rebroadcast to the endpoint + // this happens when used with getAsyncContinuation + // case (false, false, false) => { continuation.setTimeout(continuation.getAttribute(TimeoutAttribute).asInstanceOf[Long]) @@ -63,18 +64,23 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging None } - // - // we don't actually expect to get this one here since the listener will finish him off - // - case (_, _, true) => { + // + // the timeout was reset and the continuation is still suspended + // this happens when used with startAsync + // + case (false, true, false) => { + + continuation.setTimeout(continuation.getAttribute(TimeoutAttribute).asInstanceOf[Long]) + continuation.removeAttribute(TimeoutAttribute) None } // - // snuh? + // unexpected continution state(s) - log and do nothing // case _ => { - continuation.cancel + log.slf4j.warn("Received continuation in unexpected state: "+continuation.isInitial+" "+continuation.isSuspended+" "+continuation.isExpired+" "+continuation.isResumed) + //continuation.cancel None } } @@ -88,6 +94,7 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging def timeout(ms:Long):Boolean = _continuation match { case None => false case Some(continuation) => + log.slf4j.info("reseting timeout...") continuation.setAttribute(TimeoutAttribute, ms) continuation.resume true