From 0a77c6809b81a4893a58a0e9fe82469d2d574c24 Mon Sep 17 00:00:00 2001 From: Toby Crawley Date: Tue, 7 Apr 2015 21:55:54 -0400 Subject: [PATCH] Don't dispatch ISeq/InputStream sends when async sending isn't supported [IMMUTANT-549] --- project.clj | 2 +- web/src/immutant/web/async.clj | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/project.clj b/project.clj index 312f9e99..1f040de1 100644 --- a/project.clj +++ b/project.clj @@ -91,7 +91,7 @@ clj-http "1.0.1" ;; org.projectodd.wunderboss "0.4.1" - org.projectodd.wunderboss "1.x.incremental.225" + org.projectodd.wunderboss "1.x.incremental.226" ;; org.projectodd.wunderboss "0.5.1-SNAPSHOT" org.immutant :version diff --git a/web/src/immutant/web/async.clj b/web/src/immutant/web/async.clj index 11fa8d03..f13df7bb 100644 --- a/web/src/immutant/web/async.clj +++ b/web/src/immutant/web/async.clj @@ -66,8 +66,11 @@ (def ^:dynamic ^:private *dispatched?* nil) -(defmacro ^:private maybe-dispatch [& body] - `(if *dispatched?* +(defmacro ^:private maybe-dispatch [ch & body] + `(if (or *dispatched?* + ;; we can't do async sends under WF 8.x due to WFLY-3715 + (and (instance? HttpChannel ~ch) + (not (.asyncSendSupported ^HttpChannel ~ch)))) (do ~@body) (binding [*dispatched?* true] (future ~@body)))) @@ -135,7 +138,7 @@ ISeq (dispatch-message [message ch {:keys [on-success on-error close?] :as options}] - (maybe-dispatch + (maybe-dispatch ch (let [result (catch-and-notify ch on-error (loop [item (first message) items (rest message)] @@ -160,7 +163,7 @@ InputStream (dispatch-message [message ch {:keys [on-success on-error close?] :as options}] - (maybe-dispatch + (maybe-dispatch ch (let [buf-size (* 1024 16) ;; 16k is the undertow default if > 128M RAM is available buffer (byte-array buf-size) result (catch-and-notify ch on-error