Skip to content

Commit

Permalink
Don't dispatch ISeq/InputStream sends when async sending isn't suppor…
Browse files Browse the repository at this point in the history
…ted [IMMUTANT-549]
  • Loading branch information
tobias committed Apr 8, 2015
1 parent 4a9b1bf commit 0a77c68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions web/src/immutant/web/async.clj
Expand Up @@ -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))))
Expand Down Expand Up @@ -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)]
Expand All @@ -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
Expand Down

0 comments on commit 0a77c68

Please sign in to comment.