diff --git a/src/common/datomish/transact.cljc b/src/common/datomish/transact.cljc index 04c56e69..3c369ba7 100644 --- a/src/common/datomish/transact.cljc +++ b/src/common/datomish/transact.cljc @@ -50,12 +50,18 @@ (defrecord Connection [closed? current-db transact-chan] IConnection (close [conn] - (if (compare-and-set! (:closed? conn) false true) - (do - ;; This immediately stops ! token-chan (gensym "transactor-token")) (loop [] (when-let [token ( (! (:listener-source conn) report)) - report)))] + (case sentinel + :sentinel-close + ;; Time to close the underlying DB. + ( (! (:listener-source conn) report)) + report)))))] ;; Even when report is nil (transaction not committed), pair is non-nil. (>! result pair)) (>! token-chan token) diff --git a/test/datomish/transact_test.cljc b/test/datomish/transact_test.cljc index ed211711..732e1a7c 100644 --- a/test/datomish/transact_test.cljc +++ b/test/datomish/transact_test.cljc @@ -242,4 +242,40 @@ ;; Closing a closed connection is a no-op. ( (count xs) 0)) + (is (> (count es) 0)) + (is (= {:error :transact/connection-closed} (ex-data e)))))) + (finally + ;; Closing a closed connection is a no-op. + (