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) } }