From 70ffcbaa3fca6760de3096da5bc64585eeaf9479 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Sat, 18 Aug 2012 16:47:53 -0400 Subject: [PATCH] Don't suspend requests too early for the first request. We were suspending the request before we got a chance to kick off the processing for the actual response to be run. --- .../src/main/scala/net/liftweb/http/LiftServlet.scala | 10 +++++----- .../src/main/scala/net/liftweb/http/LiftSession.scala | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala b/web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala index 11bc5a7a57..477bf910be 100644 --- a/web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala +++ b/web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala @@ -626,8 +626,6 @@ class LiftServlet extends Loggable { (renderVersion -> AjaxRequestInfo(handlerVersion, Empty, cont :: Nil, millis)) - suspendRequest() - Empty // no response available, triggers the actual AJAX computation below case AjaxRequestInfo(storedVersion, existingResponseBox @ Full(_), _, _) => @@ -646,14 +644,12 @@ class LiftServlet extends Loggable { (renderVersion -> AjaxRequestInfo(handlerVersion, Empty, cont :: Nil, millis)) - suspendRequest() - Empty // no response available, triggers the actual AJAX computation below } } toReturn or { - Full(runAjax(requestState, liftSession, Full((result: LiftResponse) => { + val result = Full(runAjax(requestState, liftSession, Full((result: LiftResponse) => { // When we get the response, synchronizedly check that the // versions are still the same in the map, and, if so, update // any waiting actors then clear the actor list and update the @@ -669,6 +665,10 @@ class LiftServlet extends Loggable { } } }))) + + suspendRequest() + + result } openOr Empty case _ => diff --git a/web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala b/web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala index 6e7aa8bd69..fc95685855 100644 --- a/web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala +++ b/web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala @@ -573,7 +573,7 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String, */ private var ajaxRequests = scala.collection.mutable.Map[String,AjaxRequestInfo]() - private[http] def withAjaxRequests[T](fn: (scala.collection.mutable.Map[String, AjaxRequestInfo]) => T) = { + private[http] def withAjaxRequests[T](fn: (scala.collection.mutable.Map[String, AjaxRequestInfo]) => T): T = { ajaxRequests.synchronized { fn(ajaxRequests) } }